EmailFormField.vue
5 days ago
EmployeeFormField.vue
5 days ago
FirstNameFormField.vue
5 days ago
LastNameFormField.vue
5 days ago
LocationFormField.vue
5 days ago
PhoneFormField.vue
5 days ago
ServiceFormField.vue
5 days ago
PhoneFormField.vue
83 lines
| 1 | <template> |
| 2 | <!-- Phone Number --> |
| 3 | <el-form-item |
| 4 | v-if="amCustomize[pageRenderKey].infoStep.options.phone.visibility" |
| 5 | class="am-fs__info-form__item" |
| 6 | prop="phone" |
| 7 | label-position="top" |
| 8 | style="z-index: 10" |
| 9 | > |
| 10 | <template #label> |
| 11 | <span class="am-fs__info-form__label"> |
| 12 | {{ labelsDisplay('phone_colon') }} |
| 13 | </span> |
| 14 | </template> |
| 15 | <AmInputPhone |
| 16 | v-model="infoFormData.phone" |
| 17 | v-model:country-code="countryCode" |
| 18 | :placeholder="labelsDisplay('enter_phone')" |
| 19 | :validation-error="true" |
| 20 | :phone-input-attributes="{ name: 'phone' }" |
| 21 | style="position: relative" |
| 22 | @data="handleData" |
| 23 | > |
| 24 | <template #no-results> |
| 25 | {{ labelsDisplay('no_results_found') }} |
| 26 | </template> |
| 27 | </AmInputPhone> |
| 28 | </el-form-item> |
| 29 | <!-- /Phone Number --> |
| 30 | </template> |
| 31 | |
| 32 | <script setup> |
| 33 | import AmInputPhone from '../../../_components/input-phone/AmInputPhone.vue' |
| 34 | import { useReactiveCustomize } from '../../../../assets/js/admin/useReactiveCustomize.js' |
| 35 | import { getInternationalPhoneValue } from '../../../../assets/js/common/phone' |
| 36 | |
| 37 | import { computed, inject, ref } from 'vue' |
| 38 | |
| 39 | let langKey = inject('langKey') |
| 40 | let amLabels = inject('labels') |
| 41 | |
| 42 | let pageRenderKey = inject('pageRenderKey') |
| 43 | const { amCustomize } = useReactiveCustomize() |
| 44 | |
| 45 | const amSettings = inject('settings') |
| 46 | |
| 47 | // * Label computed function |
| 48 | function labelsDisplay(label) { |
| 49 | let computedLabel = computed(() => { |
| 50 | return amCustomize.value[pageRenderKey.value].infoStep.translations && |
| 51 | amCustomize.value[pageRenderKey.value].infoStep.translations[label] && |
| 52 | amCustomize.value[pageRenderKey.value].infoStep.translations[label][langKey.value] |
| 53 | ? amCustomize.value[pageRenderKey.value].infoStep.translations[label][langKey.value] |
| 54 | : amLabels[label] |
| 55 | }) |
| 56 | |
| 57 | return computedLabel.value |
| 58 | } |
| 59 | |
| 60 | // * Form field data |
| 61 | let infoFormData = inject('infoFormData') |
| 62 | |
| 63 | let countryCode = ref( |
| 64 | amSettings.general.phoneDefaultCountryCode === 'auto' |
| 65 | ? '' |
| 66 | : amSettings.general.phoneDefaultCountryCode.toLowerCase(), |
| 67 | ) |
| 68 | |
| 69 | function handleData(phoneData) { |
| 70 | infoFormData.value.phone = getInternationalPhoneValue( |
| 71 | phoneData?.phoneNumber ?? phoneData?.e164, |
| 72 | phoneData, |
| 73 | phoneData?.countryCode |
| 74 | ) |
| 75 | } |
| 76 | </script> |
| 77 | |
| 78 | <script> |
| 79 | export default { |
| 80 | name: 'PhoneFormField', |
| 81 | } |
| 82 | </script> |
| 83 |