mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
--------- Co-authored-by: Pranav <pranav@chatwoot.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import { mapGetters } from 'vuex';
|
|
import { isValidURL } from '../helper/URLHelper';
|
|
export default {
|
|
computed: {
|
|
...mapGetters({
|
|
currentChat: 'getSelectedChat',
|
|
accountId: 'getCurrentAccountId',
|
|
}),
|
|
attributes() {
|
|
return this.$store.getters['attributes/getAttributesByModel'](
|
|
this.attributeType
|
|
);
|
|
},
|
|
customAttributes() {
|
|
if (this.attributeType === 'conversation_attribute')
|
|
return this.currentChat.custom_attributes || {};
|
|
return this.contact.custom_attributes || {};
|
|
},
|
|
contactIdentifier() {
|
|
return (
|
|
this.currentChat.meta?.sender?.id ||
|
|
this.$route.params.contactId ||
|
|
this.contactId
|
|
);
|
|
},
|
|
contact() {
|
|
return this.$store.getters['contacts/getContact'](this.contactIdentifier);
|
|
},
|
|
conversationId() {
|
|
return this.currentChat.id;
|
|
},
|
|
},
|
|
methods: {
|
|
isAttributeNumber(attributeValue) {
|
|
return (
|
|
Number.isInteger(Number(attributeValue)) && Number(attributeValue) > 0
|
|
);
|
|
},
|
|
attributeDisplayType(attributeValue) {
|
|
if (this.isAttributeNumber(attributeValue)) {
|
|
return 'number';
|
|
}
|
|
if (isValidURL(attributeValue)) {
|
|
return 'link';
|
|
}
|
|
return 'text';
|
|
},
|
|
},
|
|
};
|