From 700701f0554c7b06985f31e9dcecc8ad51056de0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 12 Nov 2024 10:10:26 +0100 Subject: [PATCH] refactor: refs #6818 channel logic --- src/components/ui/VnLinkPhone.vue | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/components/ui/VnLinkPhone.vue b/src/components/ui/VnLinkPhone.vue index a7b2d9b77..3b3153ac3 100644 --- a/src/components/ui/VnLinkPhone.vue +++ b/src/components/ui/VnLinkPhone.vue @@ -9,29 +9,33 @@ const props = defineProps({ const config = reactive({ sip: { icon: 'phone', href: `sip:${props.phoneNumber}` }, 'say-simple': { - icon: 'help', // 'whatsapp', + icon: 'help', // 'whatsapp icon #6818', href: null, + channel: props.channel, }, }); const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip'; onBeforeMount(async () => { let url; - let channel = props.channel; - if (type === 'say-simple') - url = (await axios.get('SaySimpleConfigs/findOne')).data.url; - if (!props.channel) - channel = ( - await axios.get('SaySimpleCountries/findOne', { - params: { - filter: { fields: ['channel'], where: { countryFk: 0 } }, - }, - }) - ).data?.channel; + let { channel } = config[type]; + if (type === 'sip') return; - config[ - 'say-simple' - ].href = `${url}?customerIdentity=%2B${props.phoneNumber}&channelId=${channel}`; + if (type === 'say-simple') { + url = (await axios.get('SaySimpleConfigs/findOne')).data.url; + if (!channel) + channel = ( + await axios.get('SaySimpleCountries/findOne', { + params: { + filter: { fields: ['channel'], where: { countryFk: 0 } }, + }, + }) + ).data?.channel; + + config[ + type + ].href = `${url}?customerIdentity=%2B${props.phoneNumber}&channelId=${channel}`; + } });