refactor: move var out

This commit is contained in:
Methapon Metanipat 2024-10-03 09:56:50 +07:00
parent 19825019bf
commit c47bcc10cc

View file

@ -7,10 +7,7 @@ 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 = {
const DEFAULT_DATA: QuotationPayload = {
productServiceList: [],
urgent: false,
customerBranchId: '',
@ -27,8 +24,12 @@ export const useQuotationForm = defineStore('form-quotation', () => {
workName: '',
actorName: '',
status: 'CREATED',
};
let resetFormData = structuredClone(defaultFormData);
};
export const useQuotationForm = defineStore('form-quotation', () => {
const quotationStore = useQuotationStore();
let resetFormData = structuredClone(DEFAULT_DATA);
const currentFormData = ref<QuotationPayload>(structuredClone(resetFormData));
const currentFormState = ref<{
@ -46,8 +47,8 @@ export const useQuotationForm = defineStore('form-quotation', () => {
function resetForm(clean = false) {
if (clean) {
currentFormData.value = structuredClone(defaultFormData);
resetFormData = structuredClone(defaultFormData);
currentFormData.value = structuredClone(DEFAULT_DATA);
resetFormData = structuredClone(DEFAULT_DATA);
return;
}