From fd51b9abecd9b016edb58f1d8caccf03ae12d576 Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Fri, 4 Oct 2024 16:59:38 +0700 Subject: [PATCH] refactor: edit type quotation --- src/pages/05_quotation/form.ts | 31 ++++++++++++++++++++++++++----- src/stores/quotations/types.ts | 4 +--- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/pages/05_quotation/form.ts b/src/pages/05_quotation/form.ts index d2d4cce0..1d12f1d4 100644 --- a/src/pages/05_quotation/form.ts +++ b/src/pages/05_quotation/form.ts @@ -1,4 +1,6 @@ +import { dialog } from 'stores/utils'; import { defineStore } from 'pinia'; +import { useI18n } from 'vue-i18n'; import { ref } from 'vue'; // NOTE: Import types @@ -23,10 +25,13 @@ const DEFAULT_DATA: QuotationPayload = { contactName: '', workName: '', actorName: '', + _count: { worker: 0 }, status: 'CREATED', }; export const useQuotationForm = defineStore('form-quotation', () => { + const { t } = useI18n(); + const quotationStore = useQuotationStore(); let resetFormData = structuredClone(DEFAULT_DATA); @@ -110,14 +115,30 @@ export const useQuotationForm = defineStore('form-quotation', () => { }); } - return { - currentFormData, - currentFormState, + function dialogDelete(callback: () => void) { + dialog({ + color: 'negative', + icon: 'mdi-alert', + title: t('dialog.title.confirmDelete'), + actionText: t('general.delete'), + persistent: true, + message: t('dialog.message.confirmDelete'), + action: async () => { + callback; + }, + cancel: () => {}, + }); + } + + return { + currentFormState, + currentFormData, - injectNewEmployee, isFormDataDifferent, - resetForm, + injectNewEmployee, assignFormData, + dialogDelete, + resetForm, submitQuotation, }; diff --git a/src/stores/quotations/types.ts b/src/stores/quotations/types.ts index f5b3db82..ce29ff26 100644 --- a/src/stores/quotations/types.ts +++ b/src/stores/quotations/types.ts @@ -153,7 +153,6 @@ type ServiceRelation = { export type Quotation = { _count: { worker: number }; - id: string; finalPrice: number; vat: number; @@ -189,7 +188,6 @@ export type Quotation = { export type QuotationFull = { _count: { worker: number }; - worker: { id: string; quotationId: string; @@ -254,7 +252,7 @@ export type QuotationPayload = { customerBranchId: string; urgent: boolean; worker: EmployeeWorker[]; - workerCount: number; + _count: { worker: number }; payBillDate?: Date | null; paySplit: { no: number; date: string | Date; amount: number }[]; paySplitCount?: number | null; // int