refactor: add function

This commit is contained in:
Thanaphon Frappet 2024-10-03 09:41:06 +07:00
parent 4428dad765
commit 5c8d783fe1

View file

@ -4,6 +4,10 @@ import { ref } from 'vue';
// NOTE at type
import { QuotationPayload, EmployeeWorker } from 'src/stores/quotations/types';
import { useQuotationStore } from 'stores/quotations';
const quotationStore = useQuotationStore();
export const useQuotationForm = defineStore('form-quotation', () => {
const defaultFormData: QuotationPayload = {
service: [
@ -52,6 +56,21 @@ export const useQuotationForm = defineStore('form-quotation', () => {
return JSON.stringify(resetData) !== JSON.stringify(currData);
}
function resetForm(clean = false) {
if (clean) {
currentFormData.value = structuredClone(defaultFormData);
resetFormData = structuredClone(defaultFormData);
return;
}
currentFormData.value = structuredClone(resetFormData);
}
async function assignFormData(id: string) {}
function submiQuotationt() {}
function injectNewEmployee(data: EmployeeWorker) {
currentFormData.value.worker.push({
alienReferencNumber: data.alienReferencNumber,
@ -73,5 +92,10 @@ export const useQuotationForm = defineStore('form-quotation', () => {
currentFormData,
injectNewEmployee,
isFormDataDifferent,
resetForm,
assignFormData,
submiQuotationt,
};
});