chore: better code

This commit is contained in:
Shariq Ansari 2024-04-24 16:34:06 +05:30
parent 87acb33cb1
commit 47714d68ce
4 changed files with 10 additions and 11 deletions

View File

@ -958,7 +958,7 @@ const defaultActions = computed(() => {
icon: h(PhoneIcon, { class: 'h-4 w-4' }), icon: h(PhoneIcon, { class: 'h-4 w-4' }),
label: __('Make a Call'), label: __('Make a Call'),
onClick: () => makeCall(doc.value.data.mobile_no), onClick: () => makeCall(doc.value.data.mobile_no),
condition: () => Boolean(callEnabled.value), condition: () => callEnabled.value,
}, },
{ {
icon: h(NoteIcon, { class: 'h-4 w-4' }), icon: h(NoteIcon, { class: 'h-4 w-4' }),
@ -974,7 +974,7 @@ const defaultActions = computed(() => {
icon: h(WhatsAppIcon, { class: 'h-4 w-4' }), icon: h(WhatsAppIcon, { class: 'h-4 w-4' }),
label: __('New WhatsApp Message'), label: __('New WhatsApp Message'),
onClick: () => (tabIndex.value = 5), onClick: () => (tabIndex.value = 5),
condition: () => Boolean(whatsappEnabled.value), condition: () => whatsappEnabled.value,
}, },
] ]
return actions.filter((action) => return actions.filter((action) =>

View File

@ -452,7 +452,7 @@ const tabs = computed(() => {
name: 'Calls', name: 'Calls',
label: __('Calls'), label: __('Calls'),
icon: PhoneIcon, icon: PhoneIcon,
condition: () => Boolean(callEnabled.value), condition: () => callEnabled.value,
}, },
{ {
name: 'Tasks', name: 'Tasks',
@ -468,7 +468,7 @@ const tabs = computed(() => {
name: 'WhatsApp', name: 'WhatsApp',
label: __('WhatsApp'), label: __('WhatsApp'),
icon: WhatsAppIcon, icon: WhatsAppIcon,
condition: () => Boolean(whatsappEnabled.value), condition: () => whatsappEnabled.value,
}, },
] ]
return tabOptions.filter((tab) => (tab.condition ? tab.condition() : true)) return tabOptions.filter((tab) => (tab.condition ? tab.condition() : true))

View File

@ -417,7 +417,7 @@ const tabs = computed(() => {
name: 'Calls', name: 'Calls',
label: __('Calls'), label: __('Calls'),
icon: PhoneIcon, icon: PhoneIcon,
condition: () => Boolean(callEnabled.value), condition: () => callEnabled.value,
}, },
{ {
name: 'Tasks', name: 'Tasks',
@ -433,8 +433,8 @@ const tabs = computed(() => {
name: 'WhatsApp', name: 'WhatsApp',
label: __('WhatsApp'), label: __('WhatsApp'),
icon: WhatsAppIcon, icon: WhatsAppIcon,
condition: () => Boolean(whatsappEnabled.value), condition: () => whatsappEnabled.value,
} },
] ]
return tabOptions.filter((tab) => (tab.condition ? tab.condition() : true)) return tabOptions.filter((tab) => (tab.condition ? tab.condition() : true))
}) })

View File

@ -7,16 +7,15 @@ createResource({
cache: 'Is Whatsapp Enabled', cache: 'Is Whatsapp Enabled',
auto: true, auto: true,
onSuccess: (data) => { onSuccess: (data) => {
whatsappEnabled.value = data whatsappEnabled.value = Boolean(data)
}, },
}) })
export const callEnabled = ref(false) export const callEnabled = ref(false)
createResource({ createResource({
url: 'crm.integrations.twilio.api.is_enabled', url: 'crm.integrations.twilio.api.is_enabled',
cache: 'Is Twilio Enabled', cache: 'Is Twilio Enabled',
auto: true, auto: true,
onSuccess: (data) => { onSuccess: (data) => {
callEnabled.value = data callEnabled.value = Boolean(data)
}, },
}) })