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`; state.value.defaultCustomerImageUrl = `${apiBaseUrl}/customer/${id}/image`;
resetFormData.registeredBranchId = data.registeredBranchId; resetFormData.registeredBranchId = data.registeredBranchId;
resetFormData.code = data.code; resetFormData.code = data.code || '';
resetFormData.status = data.status; resetFormData.status = data.status;
resetFormData.customerType = data.customerType; resetFormData.customerType = data.customerType;
resetFormData.namePrefix = data.namePrefix; resetFormData.namePrefix = data.namePrefix;
@ -127,7 +127,7 @@ export const useCustomerForm = defineStore('form-customer', () => {
resetFormData.customerBranch = data.branch.map((v) => ({ resetFormData.customerBranch = data.branch.map((v) => ({
id: v.id, id: v.id,
code: v.code, code: v.code || '',
customerCode: '', customerCode: '',
provinceId: v.provinceId, provinceId: v.provinceId,
districtId: v.districtId, districtId: v.districtId,
@ -149,12 +149,12 @@ export const useCustomerForm = defineStore('form-customer', () => {
workplace: v.workplace, workplace: v.workplace,
status: v.status, status: v.status,
customerId: v.customerId, customerId: v.customerId,
citizenId: v.citizenId, citizenId: v.citizenId || '',
authorizedCapital: v.authorizedCapital, authorizedCapital: v.authorizedCapital || '',
registerDate: new Date(v.registerDate), // Convert the string to a Date object registerDate: new Date(v.registerDate), // Convert the string to a Date object
registerNameEN: v.registerNameEN, registerNameEN: v.registerNameEN || '',
registerName: v.registerName, registerName: v.registerName || '',
legalPersonNo: v.legalPersonNo, legalPersonNo: v.legalPersonNo || '',
registerCompanyName: '', registerCompanyName: '',
statusSave: true, statusSave: true,
file: undefined, file: undefined,
@ -168,7 +168,13 @@ export const useCustomerForm = defineStore('form-customer', () => {
currentFormData.value.customerBranch?.push({ currentFormData.value.customerBranch?.push({
id: '', 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: '', customerCode: '',
provinceId: '', provinceId: '',
districtId: '', districtId: '',
@ -191,17 +197,21 @@ export const useCustomerForm = defineStore('form-customer', () => {
status: 'CREATED', status: 'CREATED',
customerId: '', customerId: '',
citizenId: citizenId:
currentFormData.value.customerBranch?.[0].citizenId === null currentFormData.value.customerBranch.length !== 0
? '' ? currentFormData.value.customerBranch?.[0].citizenId === null
: currentFormData.value.customerBranch?.[0].citizenId, ? ''
: currentFormData.value.customerBranch?.[0].citizenId
: '',
authorizedCapital: '', authorizedCapital: '',
registerDate: new Date(), // Convert the string to a Date object registerDate: new Date(), // Convert the string to a Date object
registerNameEN: '', registerNameEN: '',
registerName: '', registerName: '',
legalPersonNo: legalPersonNo:
currentFormData.value.customerBranch?.[0].legalPersonNo === null currentFormData.value.customerBranch.length !== 0
? '' ? currentFormData.value.customerBranch?.[0].legalPersonNo === null
: currentFormData.value.customerBranch?.[0].legalPersonNo, ? ''
: currentFormData.value.customerBranch?.[0].legalPersonNo
: '',
registerCompanyName: '', registerCompanyName: '',
file: undefined, file: undefined,
}); });