From 34eeb20ea6f4ddc201e278918985b90ee7b22e88 Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Mon, 21 Oct 2024 12:03:19 +0700 Subject: [PATCH] refactor: get customerBranch by id --- src/pages/05_quotation/peview/ViewForm.vue | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pages/05_quotation/peview/ViewForm.vue b/src/pages/05_quotation/peview/ViewForm.vue index e3ec346c..8534a494 100644 --- a/src/pages/05_quotation/peview/ViewForm.vue +++ b/src/pages/05_quotation/peview/ViewForm.vue @@ -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(); +const customer = ref(); const branch = ref(); const productList = ref([]); const bankList = ref([]); @@ -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,