refactor: header value is null

This commit is contained in:
Net 2024-08-21 15:13:28 +07:00
parent d8c0be7824
commit bb669a5b7d

View file

@ -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,
});