refactor: format address add address EN
This commit is contained in:
parent
a2720d0f76
commit
ed56228964
2 changed files with 9 additions and 5 deletions
|
|
@ -91,6 +91,7 @@ const fullAddress = computed(() => {
|
||||||
if (province && district && sDistrict) {
|
if (province && district && sDistrict) {
|
||||||
const fullAddress = formatAddress({
|
const fullAddress = formatAddress({
|
||||||
address: address.value,
|
address: address.value,
|
||||||
|
addressEN: addressEN.value,
|
||||||
moo: moo.value ? moo.value : '',
|
moo: moo.value ? moo.value : '',
|
||||||
mooEN: mooEN.value ? mooEN.value : '',
|
mooEN: mooEN.value ? mooEN.value : '',
|
||||||
soi: soi.value ? soi.value : '',
|
soi: soi.value ? soi.value : '',
|
||||||
|
|
@ -116,6 +117,7 @@ const fullAddressEN = computed(() => {
|
||||||
if (province && district && sDistrict) {
|
if (province && district && sDistrict) {
|
||||||
const fullAddress = formatAddress({
|
const fullAddress = formatAddress({
|
||||||
address: address.value,
|
address: address.value,
|
||||||
|
addressEN: addressEN.value,
|
||||||
moo: moo.value ? moo.value : '',
|
moo: moo.value ? moo.value : '',
|
||||||
mooEN: mooEN.value ? mooEN.value : '',
|
mooEN: mooEN.value ? mooEN.value : '',
|
||||||
soi: soi.value ? soi.value : '',
|
soi: soi.value ? soi.value : '',
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { District, Province, SubDistrict } from 'src/stores/address';
|
||||||
|
|
||||||
export function formatAddress(opt: {
|
export function formatAddress(opt: {
|
||||||
address: string;
|
address: string;
|
||||||
|
addressEN: string;
|
||||||
moo?: string;
|
moo?: string;
|
||||||
mooEN?: string;
|
mooEN?: string;
|
||||||
soi?: string;
|
soi?: string;
|
||||||
|
|
@ -15,19 +16,20 @@ export function formatAddress(opt: {
|
||||||
en?: boolean;
|
en?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const addressParts = [`${opt.address},`];
|
let addressParts: string[];
|
||||||
|
|
||||||
if (opt.en) {
|
if (opt.en) {
|
||||||
// en
|
// en
|
||||||
if (opt.moo) addressParts.push(`Moo ${opt.mooEN},`);
|
addressParts = [`${opt.addressEN},`];
|
||||||
if (opt.soi) addressParts.push(`Soi ${opt.soiEN},`);
|
if (opt.mooEN) addressParts.push(`Moo ${opt.mooEN},`);
|
||||||
if (opt.street) addressParts.push(`${opt.streetEN} Rd.`);
|
if (opt.soiEN) addressParts.push(`Soi ${opt.soiEN},`);
|
||||||
|
if (opt.streetEN) addressParts.push(`${opt.streetEN} Rd.`);
|
||||||
|
|
||||||
addressParts.push(`${opt.subDistrict.nameEN} sub-district,`);
|
addressParts.push(`${opt.subDistrict.nameEN} sub-district,`);
|
||||||
addressParts.push(`${opt.district.nameEN} district,`);
|
addressParts.push(`${opt.district.nameEN} district,`);
|
||||||
addressParts.push(`${opt.province.nameEN},`);
|
addressParts.push(`${opt.province.nameEN},`);
|
||||||
} else {
|
} else {
|
||||||
// th
|
// th
|
||||||
|
addressParts = [`${opt.address},`];
|
||||||
if (opt.moo) addressParts.push(`หมู่ ${opt.moo},`);
|
if (opt.moo) addressParts.push(`หมู่ ${opt.moo},`);
|
||||||
if (opt.soi) addressParts.push(`ซอย ${opt.soi},`);
|
if (opt.soi) addressParts.push(`ซอย ${opt.soi},`);
|
||||||
if (opt.street) addressParts.push(`ถนน ${opt.street},`);
|
if (opt.street) addressParts.push(`ถนน ${opt.street},`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue