refactor: handle adress bangkok

This commit is contained in:
Thanaphon Frappet 2024-11-04 14:45:33 +07:00
parent 58fc722c41
commit fb1c0e9590

View file

@ -75,29 +75,36 @@ const { t } = useI18n();
const fullAddress = computed(() => {
const addressParts = [`${address.value},`];
const province = provinceOptions.value.find((v) => v.id === provinceId.value);
const district = districtOptions.value.find((v) => v.id === districtId.value);
const sDistrict = subDistrictOptions.value.find(
(v) => v.id === subDistrictId.value,
);
if (moo.value) addressParts.push(`${t('form.moo')} ${moo.value},`);
if (soi.value) addressParts.push(`${t('form.soi')} ${soi.value},`);
if (street.value) addressParts.push(`${t('form.road')} ${street.value},`);
if (moo.value) addressParts.push(`หมู่ ${moo.value},`);
if (soi.value) addressParts.push(`ซอย ${soi.value},`);
if (street.value) addressParts.push(`ถนน ${street.value},`);
if (subDistrictId.value && sDistrict) {
addressParts.push(
typeof sDistrict.name === 'string' ? `${sDistrict.name},` : '',
typeof sDistrict.name === 'string'
? `${!!province && province.id === '10' ? t('addressBangkok.subdistrict') : t('address.subdistrict')} ${sDistrict.name},`
: '',
);
}
if (districtId.value && district)
addressParts.push(
typeof district.name === 'string' ? `${district.name},` : '',
typeof district.name === 'string'
? `${!!province && province.id === '10' ? t('addressBangkok.district') : t('address.district')} ${district.name},`
: '',
);
if (provinceId.value && province) {
addressParts.push(
typeof province.name === 'string' ? `${province.name}` : '',
typeof province.name === 'string'
? ` ${!!province && province.id === '10' ? t('addressBangkok.province') : t('address.province')} ${province.name}`
: '',
);
sDistrict &&
addressParts.push(
@ -122,18 +129,24 @@ const fullAddressEN = computed(() => {
if (subDistrictId.value && sDistrict) {
addressParts.push(
typeof sDistrict.nameEN === 'string' ? `${sDistrict.nameEN},` : '',
typeof sDistrict.nameEN === 'string'
? `${sDistrict.nameEN} ${t('addressEn.subdistrict')},`
: '',
);
}
if (districtId.value && district)
addressParts.push(
typeof district.nameEN === 'string' ? `${district.nameEN},` : '',
typeof district.nameEN === 'string'
? `${district.nameEN} ${t('addressEn.district')}`
: '',
);
if (provinceId.value && province) {
addressParts.push(
typeof province.nameEN === 'string' ? `${province.nameEN}` : '',
typeof province.nameEN === 'string'
? `${province.nameEN} ${t('addressEn.province')}`
: '',
);
sDistrict &&
addressParts.push(