From 247549e17690061a21e2fc0e70dce94cee0e28c8 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:29:31 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E0=B9=80=E0=B8=9B=E0=B8=A5=E0=B8=B5?= =?UTF-8?q?=E0=B9=88=E0=B8=A2=E0=B8=99=20=E0=B8=AA=E0=B8=96=E0=B8=B2?= =?UTF-8?q?=E0=B8=99=E0=B8=B0=E0=B8=82=E0=B8=AD=E0=B8=87=20=20=E0=B8=AA?= =?UTF-8?q?=E0=B8=B4=E0=B8=99=E0=B8=84=E0=B9=89=E0=B8=B2=E0=B9=81=E0=B8=A5?= =?UTF-8?q?=E0=B8=B0=E0=B8=9A=E0=B8=A3=E0=B8=B4=E0=B8=81=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/04_product-service/MainPage.vue | 25 +++++++++++++++++++++++ src/stores/product-service/index.ts | 9 +++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index 6b3ffa0a..72fcd87c 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -335,6 +335,21 @@ const itemCard = [ }, ]; +async function toggleStatusProduct(id: string, status: Status) { + await editProduct(id, { + status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE', + }); + + await fetchListOfProduct(currentIdType.value); +} + +async function toggleStatusService(id: string, status: Status) { + await editService(id, { + status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE', + }); + + await fetchListOfService(); +} async function toggleStatusType(id: string, status: Status) { await editProductServiceType(id, { status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE', @@ -1202,6 +1217,11 @@ watch(currentStatus, async () => { typeProduct="product" :title="i.name" :isDisabled="i.status === 'INACTIVE' ? true : false" + @toggleStatus=" + () => { + toggleStatusProduct(i.id, i.status); + } + " @menuViewDetail=" () => { currentIdProduct = i.id; @@ -1255,6 +1275,11 @@ watch(currentStatus, async () => { :title="i.name" :isDisabled="i.status === 'INACTIVE' ? true : false" :created-at="i.createdAt" + @toggleStatus=" + () => { + toggleStatusService(i.id, i.status); + } + " @menuViewDetail=" () => { currentIdService = i.id; diff --git a/src/stores/product-service/index.ts b/src/stores/product-service/index.ts index 406150e0..3e0bbd8e 100644 --- a/src/stores/product-service/index.ts +++ b/src/stores/product-service/index.ts @@ -303,7 +303,7 @@ const useProductServiceStore = defineStore('api-product-service', () => { } async function createProduct(data: ProductCreate) { - const { image, ...payload } = data; + const { image, status, ...payload } = data; const res = await api.post( '/product', @@ -340,7 +340,7 @@ const useProductServiceStore = defineStore('api-product-service', () => { async function editProduct( productId: string, - data: ProductCreate & { status: string }, + data: Partial, ) { const { image, code, ...payload } = data; @@ -502,7 +502,10 @@ const useProductServiceStore = defineStore('api-product-service', () => { } } - async function editService(serviceId: string, data: ServiceCreate) { + async function editService( + serviceId: string, + data: Partial, + ) { const { image, code, ...payload } = data; const res = await api.put(