fix: work type and function

This commit is contained in:
puriphatt 2024-06-21 11:06:02 +00:00
parent a02dd8b5e0
commit 12e52e4a79

View file

@ -24,7 +24,9 @@ import { ref } from 'vue';
const useProductServiceStore = defineStore('api-product-service', () => {
// Product Type
const workNameItems = ref<string[]>([]);
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 };
});
}
}