refactor: get customerBranch by id

This commit is contained in:
Thanaphon Frappet 2024-10-21 12:03:19 +07:00
parent 425fd71d2c
commit 34eeb20ea6

View file

@ -11,9 +11,11 @@ import { useQuotationForm } from 'pages/05_quotation/form';
import { useConfigStore } from 'stores/config';
import useBranchStore from 'stores/branch';
import { baseUrl } from 'stores/utils';
import useCustomerStore from 'stores/customer';
import { commaInput } from 'stores/utils';
// NOTE Import Types
import { CustomerBranch } from 'stores/customer/types';
import { BankBook, Branch } from 'stores/branch/types';
import {
QuotationPayload,
@ -31,6 +33,7 @@ const quotationForm = useQuotationForm();
const optionStore = useOptionStore();
const configStore = useConfigStore();
const branchStore = useBranchStore();
const customerStore = useCustomerStore();
const { data: config } = storeToRefs(configStore);
@ -53,7 +56,7 @@ type SummaryPrice = {
finalPrice: number;
};
const customer = ref<CustomerBranchRelation>();
const customer = ref<CustomerBranch>();
const branch = ref<Branch>();
const productList = ref<Product[]>([]);
const bankList = ref<BankBook[]>([]);
@ -128,9 +131,15 @@ onMounted(async () => {
data.value = 'data' in parsed ? parsed.data : undefined;
customer.value = parsed.meta.source.customerBranch;
if (data.value) {
const resCustomerBranch = await customerStore.getBranchById(
data.value.customerBranchId,
);
if (resCustomerBranch) {
customer.value = resCustomerBranch;
}
details.value = {
code: parsed.meta.source.code,
createdAt: parsed.meta.source.createdAt,