refactor: edit type quotation

This commit is contained in:
Thanaphon Frappet 2024-10-04 16:59:38 +07:00
parent 4a6a97a413
commit fd51b9abec
2 changed files with 27 additions and 8 deletions

View file

@ -1,4 +1,6 @@
import { dialog } from 'stores/utils';
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { useI18n } from 'vue-i18n';
import { ref } from 'vue'; import { ref } from 'vue';
// NOTE: Import types // NOTE: Import types
@ -23,10 +25,13 @@ const DEFAULT_DATA: QuotationPayload = {
contactName: '', contactName: '',
workName: '', workName: '',
actorName: '', actorName: '',
_count: { worker: 0 },
status: 'CREATED', status: 'CREATED',
}; };
export const useQuotationForm = defineStore('form-quotation', () => { export const useQuotationForm = defineStore('form-quotation', () => {
const { t } = useI18n();
const quotationStore = useQuotationStore(); const quotationStore = useQuotationStore();
let resetFormData = structuredClone(DEFAULT_DATA); let resetFormData = structuredClone(DEFAULT_DATA);
@ -110,14 +115,30 @@ export const useQuotationForm = defineStore('form-quotation', () => {
}); });
} }
return { function dialogDelete(callback: () => void) {
currentFormData, dialog({
currentFormState, 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, isFormDataDifferent,
resetForm, injectNewEmployee,
assignFormData, assignFormData,
dialogDelete,
resetForm,
submitQuotation, submitQuotation,
}; };

View file

@ -153,7 +153,6 @@ type ServiceRelation = {
export type Quotation = { export type Quotation = {
_count: { worker: number }; _count: { worker: number };
id: string; id: string;
finalPrice: number; finalPrice: number;
vat: number; vat: number;
@ -189,7 +188,6 @@ export type Quotation = {
export type QuotationFull = { export type QuotationFull = {
_count: { worker: number }; _count: { worker: number };
worker: { worker: {
id: string; id: string;
quotationId: string; quotationId: string;
@ -254,7 +252,7 @@ export type QuotationPayload = {
customerBranchId: string; customerBranchId: string;
urgent: boolean; urgent: boolean;
worker: EmployeeWorker[]; worker: EmployeeWorker[];
workerCount: number; _count: { worker: number };
payBillDate?: Date | null; payBillDate?: Date | null;
paySplit: { no: number; date: string | Date; amount: number }[]; paySplit: { no: number; date: string | Date; amount: number }[];
paySplitCount?: number | null; // int paySplitCount?: number | null; // int