From 362cb7c15a599a4f1f91b2338018e6f59729cc2f Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 3 Oct 2024 09:47:43 +0700 Subject: [PATCH] refactor: wrong code --- src/pages/05_quotation/form.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/pages/05_quotation/form.ts b/src/pages/05_quotation/form.ts index 78907dc8..fc400301 100644 --- a/src/pages/05_quotation/form.ts +++ b/src/pages/05_quotation/form.ts @@ -1,26 +1,17 @@ import { defineStore } from 'pinia'; import { ref } from 'vue'; -// NOTE at type +// NOTE: Import types import { QuotationPayload, EmployeeWorker } from 'src/stores/quotations/types'; +// NOTE: Import stores import { useQuotationStore } from 'stores/quotations'; export const useQuotationForm = defineStore('form-quotation', () => { const quotationStore = useQuotationStore(); const defaultFormData: QuotationPayload = { - productServiceList: [ - { - vat: 0, - pricePerUnit: 0, - discount: 0, - amount: 0, - productId: '', - workId: '', - serviceId: '', - }, - ], + productServiceList: [], urgent: false, customerBranchId: '', worker: [], @@ -37,7 +28,7 @@ export const useQuotationForm = defineStore('form-quotation', () => { actorName: '', status: 'CREATED', }; - const resetFormData = structuredClone(defaultFormData); + let resetFormData = structuredClone(defaultFormData); const currentFormData = ref(structuredClone(resetFormData)); @@ -59,7 +50,11 @@ export const useQuotationForm = defineStore('form-quotation', () => { currentFormData.value = structuredClone(resetFormData); } - async function assignFormData(id: string) {} + async function assignFormData(id: string) { + const data = await quotationStore.getQuotation(id); + + if (!data) return; // NOTE: Error should be handled globally by axios instance + } function submiQuotationt() {}