From 7693d193f03c504efdc2278be8799c278f0a73ca Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 10:36:18 +0100 Subject: [PATCH] feat: refs #6818 add URL handling vn-link-phone --- src/components/ui/VnLinkPhone.vue | 14 ++++++++--- .../components/common/VnLinkPhone.spec.js | 25 +++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/components/ui/VnLinkPhone.vue b/src/components/ui/VnLinkPhone.vue index c5023f69e..c5d5df394 100644 --- a/src/components/ui/VnLinkPhone.vue +++ b/src/components/ui/VnLinkPhone.vue @@ -2,6 +2,7 @@ import { ref, 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 }, @@ -14,13 +15,14 @@ const config = reactive({ sip: { icon: 'phone', href: `sip:${props.phoneNumber}` }, 'say-simple': { icon: 'vn:saysimple', - href: null, + url: null, channel: props.channel, }, }); const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip'; onBeforeMount(async () => { + if (!phone.value) return; let { channel } = config[type]; if (type === 'say-simple') { @@ -31,9 +33,14 @@ onBeforeMount(async () => { phone.value = await parsePhone(props.phoneNumber, props.country.toLowerCase()); config[ type - ].href = `${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`; + ].url = `${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`; } }); + +function handleClick() { + if (config[type].url) useOpenURL(config[type].url); + else if (config[type].href) window.location.href = config[type].href; +}