import axios from 'axios'; export default async function parsePhone(phone, country) { if (phone.startsWith('+')) return `${phone.slice(1)}`; if (phone.startsWith('00')) return `${phone.slice(2)}`; try { const prefix = ( await axios.get(`Prefixes/${country.toLowerCase()}`) ).data?.prefix.replace(/^0+/, ''); if (phone.startsWith(prefix)) return phone; return `${prefix}${phone}`; } catch (e) { return null; } }