diff --git a/src/stores/customer/index.ts b/src/stores/customer/index.ts index affdeae2..4bb524e8 100644 --- a/src/stores/customer/index.ts +++ b/src/stores/customer/index.ts @@ -360,14 +360,31 @@ const useCustomerStore = defineStore('api-customer', () => { } async function createBranch( - data: CustomerBranchCreate & { customerId: string }, + data: CustomerBranchCreate & { id?: string; customerId: string }, flow?: { sessionId?: string; refTransactionId?: string; transactionId?: string; }, ) { - const { id, statusSave, code, file, ...payload } = data; + const { + customerCode, + registerCompanyName, + statusSave, + code, + file, + ...payload + } = data; + + if (payload.citizenId !== '') { + delete payload['registerDate']; + delete payload['registerName']; + delete payload['registerNameEN']; + delete payload['authorizedCapital']; + delete payload['legalPersonNo']; + } else { + delete payload['citizenId']; + } const res = await api.post('/customer-branch', payload, { headers: { @@ -385,14 +402,32 @@ const useCustomerStore = defineStore('api-customer', () => { async function editBranchById( id: string, - data: Partial, + data: Partial, flow?: { sessionId?: string; refTransactionId?: string; transactionId?: string; }, ) { - const { code, branchNo, file, ...payload } = data; + const { + customerCode, + registerCompanyName, + statusSave, + code, + status, + file, + ...payload + } = data; + + if (payload.citizenId !== null) { + delete payload['registerDate']; + delete payload['registerName']; + delete payload['registerNameEN']; + delete payload['authorizedCapital']; + delete payload['legalPersonNo']; + } else { + delete payload['citizenId']; + } const res = await api.put( `/customer-branch/${id}`,