fix: wrong detect customer type

This commit is contained in:
Methapon Metanipat 2024-08-28 08:48:19 +07:00
parent 425bd0b784
commit 15277d3a03

View file

@ -312,6 +312,7 @@ export const useCustomerForm = defineStore('form-customer', () => {
export const useCustomerBranchForm = defineStore('form-customer-branch', () => {
const customerStore = useCustomerStore();
const customerFormStore = useCustomerForm();
const defaultFormData: CustomerBranchCreate & { id?: string } = {
code: '',
@ -442,6 +443,10 @@ export const useCustomerBranchForm = defineStore('form-customer-branch', () => {
if (!currentFormData.value.id) {
const res = await customerStore.createBranch({
...currentFormData.value,
citizenId:
customerFormStore.currentFormData.customerType === 'CORP'
? undefined
: currentFormData.value.citizenId,
customerId: state.value.currentCustomerId,
});
if (res) return res;