diff --git a/src/components/ui/VnLinkPhone.vue b/src/components/ui/VnLinkPhone.vue index 4068498cd..027244609 100644 --- a/src/components/ui/VnLinkPhone.vue +++ b/src/components/ui/VnLinkPhone.vue @@ -2,6 +2,7 @@ import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue'; import axios from 'axios'; import { parsePhone } from 'src/filters'; +import useOpenURL from 'src/composables/useOpenURL'; const props = defineProps({ phoneNumber: { type: [String, Number], default: null }, channel: { type: Number, default: null }, @@ -11,25 +12,31 @@ const config = reactive({ sip: { icon: 'phone', href: `sip:${props.phoneNumber}` }, 'say-simple': { icon: 'vn:saysimple', - href: null, channel: props.channel, + url: null, }, }); const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip'; onBeforeMount(async () => { - let { channel } = config[type]; + let { channel, url } = config[type]; if (type === 'say-simple') { - const { url, defaultChannel } = (await axios.get('SaySimpleConfigs/findOne')) - .data; - if (!channel) channel = defaultChannel; - - config[type].href = `${url}?customerIdentity=%2B${parsePhone( - props.phoneNumber - )}&channelId=${channel}`; + const { url: defaultUrl, defaultChannel } = ( + await axios.get('SaySimpleConfigs/findOne') + ).data; + if (!channel) config[type].channel = defaultChannel; + if (!url) config[type].url = defaultUrl; } }); + +function openSaySimple() { + useOpenURL( + `${config[type].url}?customerIdentity=%2B${parsePhone( + props.phoneNumber + )}&channelId=${config[type].channel}` + ); +}