From bb669a5b7d16858382f4c9681dd7e2a0ccc78c9b Mon Sep 17 00:00:00 2001 From: Net Date: Wed, 21 Aug 2024 15:13:28 +0700 Subject: [PATCH] refactor: header value is null --- src/pages/03_customer-management/form.ts | 38 +++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index 42382f5e..70c6373b 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -113,7 +113,7 @@ export const useCustomerForm = defineStore('form-customer', () => { state.value.defaultCustomerImageUrl = `${apiBaseUrl}/customer/${id}/image`; resetFormData.registeredBranchId = data.registeredBranchId; - resetFormData.code = data.code; + resetFormData.code = data.code || ''; resetFormData.status = data.status; resetFormData.customerType = data.customerType; resetFormData.namePrefix = data.namePrefix; @@ -127,7 +127,7 @@ export const useCustomerForm = defineStore('form-customer', () => { resetFormData.customerBranch = data.branch.map((v) => ({ id: v.id, - code: v.code, + code: v.code || '', customerCode: '', provinceId: v.provinceId, districtId: v.districtId, @@ -149,12 +149,12 @@ export const useCustomerForm = defineStore('form-customer', () => { workplace: v.workplace, status: v.status, customerId: v.customerId, - citizenId: v.citizenId, - authorizedCapital: v.authorizedCapital, + citizenId: v.citizenId || '', + authorizedCapital: v.authorizedCapital || '', registerDate: new Date(v.registerDate), // Convert the string to a Date object - registerNameEN: v.registerNameEN, - registerName: v.registerName, - legalPersonNo: v.legalPersonNo, + registerNameEN: v.registerNameEN || '', + registerName: v.registerName || '', + legalPersonNo: v.legalPersonNo || '', registerCompanyName: '', statusSave: true, file: undefined, @@ -168,7 +168,13 @@ export const useCustomerForm = defineStore('form-customer', () => { currentFormData.value.customerBranch?.push({ id: '', - code: currentFormData.value.customerBranch?.[0].code, + code: + currentFormData.value.customerBranch.length !== 0 + ? currentFormData.value.customerBranch?.[0].code === null + ? '' + : currentFormData.value.customerBranch?.[0].code + : '', + customerCode: '', provinceId: '', districtId: '', @@ -191,17 +197,21 @@ export const useCustomerForm = defineStore('form-customer', () => { status: 'CREATED', customerId: '', citizenId: - currentFormData.value.customerBranch?.[0].citizenId === null - ? '' - : currentFormData.value.customerBranch?.[0].citizenId, + currentFormData.value.customerBranch.length !== 0 + ? currentFormData.value.customerBranch?.[0].citizenId === null + ? '' + : currentFormData.value.customerBranch?.[0].citizenId + : '', authorizedCapital: '', registerDate: new Date(), // Convert the string to a Date object registerNameEN: '', registerName: '', legalPersonNo: - currentFormData.value.customerBranch?.[0].legalPersonNo === null - ? '' - : currentFormData.value.customerBranch?.[0].legalPersonNo, + currentFormData.value.customerBranch.length !== 0 + ? currentFormData.value.customerBranch?.[0].legalPersonNo === null + ? '' + : currentFormData.value.customerBranch?.[0].legalPersonNo + : '', registerCompanyName: '', file: undefined, });