refactor: refs #6818 channel logic
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-12 10:10:26 +01:00
parent c775ba8592
commit 700701f055
1 changed files with 19 additions and 15 deletions

View File

@ -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}`;
}
});
</script>
<template>