0
0
Fork 0

fix: #6818 VnLinkPhone using spanish prefix

This commit is contained in:
Javier Segarra 2024-11-26 22:57:47 +01:00
parent 511a5bc614
commit 21eda340a8
3 changed files with 21 additions and 3 deletions

View File

@ -1,6 +1,7 @@
<script setup>
import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
import axios from 'axios';
import { parsePhone } from 'src/filters';
const props = defineProps({
phoneNumber: { type: [String, Number], default: null },
channel: { type: Number, default: null },
@ -24,9 +25,9 @@ onBeforeMount(async () => {
.data;
if (!channel) channel = defaultChannel;
config[
type
].href = `${url}?customerIdentity=%2B${props.phoneNumber}&channelId=${channel}`;
config[type].href = `${url}?customerIdentity=%2B${parsePhone(
props.phoneNumber
)}&channelId=${channel}`;
}
});
</script>

View File

@ -12,10 +12,12 @@ import dateRange from './dateRange';
import toHour from './toHour';
import dashOrCurrency from './dashOrCurrency';
import getParamWhere from './getParamWhere';
import parsePhone from './parsePhone';
import isDialogOpened from './isDialogOpened';
export {
isDialogOpened,
parsePhone,
toLowerCase,
toLowerCamel,
toDate,

15
src/filters/parsePhone.js Normal file
View File

@ -0,0 +1,15 @@
export default function (phone, prefix = 34) {
if (phone.startsWith('+')) {
console.log('a');
return `${phone.slice(1)}`;
}
if (phone.startsWith('00')) {
console.log('b');
return `${phone.slice(2)}`;
}
if (phone.startsWith(prefix) && phone.length === prefix.length + 9) {
console.log('c');
return `${prefix}${phone.slice(prefix.length)}`;
}
return `${prefix}${phone}`;
}