feat: store it full response as source

This commit is contained in:
Methapon Metanipat 2024-10-18 14:57:57 +07:00
parent c22dc7d945
commit 42cc0175f8
3 changed files with 5 additions and 0 deletions

View file

@ -284,6 +284,7 @@ async function storeDataLocal(id: string) {
JSON.stringify({ JSON.stringify({
data: quotationFormData.value, data: quotationFormData.value,
meta: { meta: {
source: quotationFormState.value.source,
createdBy: quotationFormState.value.createdBy('tha'), createdBy: quotationFormState.value.createdBy('tha'),
}, },
}), }),

View file

@ -637,6 +637,7 @@ function storeDataLocal() {
JSON.stringify({ JSON.stringify({
data: quotationFormData.value, data: quotationFormData.value,
meta: { meta: {
source: quotationFormState.value.source,
createdBy: quotationFormState.value.createdBy('tha'), createdBy: quotationFormState.value.createdBy('tha'),
}, },
}), }),

View file

@ -70,6 +70,7 @@ export const useQuotationForm = defineStore('form-quotation', () => {
); );
const currentFormState = ref<{ const currentFormState = ref<{
mode: null | 'info' | 'create' | 'edit'; mode: null | 'info' | 'create' | 'edit';
source?: QuotationFull;
createdBy: (locale: string) => string; createdBy: (locale: string) => string;
}>({ }>({
mode: null, mode: null,
@ -105,6 +106,8 @@ export const useQuotationForm = defineStore('form-quotation', () => {
if (!data) return; // NOTE: Error should be handled globally by axios instance if (!data) return; // NOTE: Error should be handled globally by axios instance
currentFormState.value.source = data;
quotationFull.value = data; quotationFull.value = data;
resetFormData = Object.assign(data, { resetFormData = Object.assign(data, {
productServiceList: data.productServiceList.map((v) => ({ productServiceList: data.productServiceList.map((v) => ({