From 12e52e4a79b98c4779cbf67baae050947e1f69a8 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Fri, 21 Jun 2024 11:06:02 +0000 Subject: [PATCH] fix: work type and function --- src/stores/product-service/index.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/stores/product-service/index.ts b/src/stores/product-service/index.ts index 6e448954..31c0841f 100644 --- a/src/stores/product-service/index.ts +++ b/src/stores/product-service/index.ts @@ -24,7 +24,9 @@ import { ref } from 'vue'; const useProductServiceStore = defineStore('api-product-service', () => { // Product Type - const workNameItems = ref([]); + const workNameItems = ref<{ id: string; name: string; isEdit: boolean }[]>( + [], + ); async function fetchStatsProductType() { const res = await api.get('/product-type/stats'); @@ -589,6 +591,7 @@ const useProductServiceStore = defineStore('api-product-service', () => { if (!res) return false; if (res.status === 201) { + await fetchListOfWork(); return res.data; } @@ -616,18 +619,20 @@ const useProductServiceStore = defineStore('api-product-service', () => { }); if (res.status === 200) { + await fetchListOfWork(); return res.data; } return false; } - async function deleteWork(serviceId: string) { - const res = await api.delete(`/work/${serviceId}`); + async function deleteWork(workId: string) { + const res = await api.delete(`/work/${workId}`); if (!res) return false; if (res.status === 200) { + await fetchListOfWork(); return res.data; } @@ -674,7 +679,9 @@ const useProductServiceStore = defineStore('api-product-service', () => { const res = await fetchListWork(); if (res) { - workNameItems.value = res.result.map((item) => item.name); + workNameItems.value = res.result.map((item) => { + return { id: item.id, name: item.name, isEdit: false }; + }); } }