From c8278c2cea337a04ecd85def2d42a4e22753900a Mon Sep 17 00:00:00 2001 From: rarsyansyahr Date: Wed, 15 Dec 2021 15:35:57 +0700 Subject: [PATCH] feat: update supplier status --- src/component/SupplierComponent.js | 8 +++++++- src/pages/Payback/Payback.js | 4 ++++ src/pages/Product/Product.js | 1 + src/store/product.js | 8 +++++++- src/store/supplier.js | 6 ++++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/component/SupplierComponent.js b/src/component/SupplierComponent.js index f12cc45..95e527c 100644 --- a/src/component/SupplierComponent.js +++ b/src/component/SupplierComponent.js @@ -51,6 +51,11 @@ export const SupplierComponent = observer((props) => { setIdData(data.id); }; + const changeStatus = (id, isActive) => { + const status = isActive ? "inactive" : "active" + store.supplier.changeStatus(id, status) + } + const columns = [ { title: "Name", @@ -69,7 +74,8 @@ export const SupplierComponent = observer((props) => { render: (text, record) => ( changeStatus(record?.id, record?.status)} > {record?.status === true ? " ACTIVE" : "INACTIVE"} diff --git a/src/pages/Payback/Payback.js b/src/pages/Payback/Payback.js index e319918..adb7056 100644 --- a/src/pages/Payback/Payback.js +++ b/src/pages/Payback/Payback.js @@ -32,24 +32,28 @@ export const Payback = observer(() => { const dummyData = [ { + key: '1', id: 1, name: "John Doe", picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", amount: "Rp. 1.000.000", }, { + key: '2', id: 1, name: "John Doe", picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", amount: "Rp. 1.000.000", }, { + key: '3', id: 1, name: "John Doe", picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", amount: "Rp. 1.000.000", }, { + key: '4',Z id: 1, name: "John Doe", picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", diff --git a/src/pages/Product/Product.js b/src/pages/Product/Product.js index 8beee01..fae9465 100644 --- a/src/pages/Product/Product.js +++ b/src/pages/Product/Product.js @@ -32,6 +32,7 @@ export const Product = observer(() => { const handleChangeTabPane = async (key) => { store.product.filterCategory = key; console.log(key); + await store.product.getData() }; const routeData = [ diff --git a/src/store/product.js b/src/store/product.js index c8f6e38..be0b059 100644 --- a/src/store/product.js +++ b/src/store/product.js @@ -27,8 +27,14 @@ export class Product { async getData() { const response = await http.get(`/product/by-categories?categories=${this.filterCategory}&page=${this.page}&pageSize=${this.pageSize}`); - this.data = response.body.data ?? [] + this.data = response.body.data.map((item, idx) => { + item.key = idx; + return item + }) ?? [] + this.total_data = response.body.total_data ?? 0 + + console.log(response.body.data, this.filterCategory); } async getDataSubCategories() { diff --git a/src/store/supplier.js b/src/store/supplier.js index 9da2048..ecebdba 100644 --- a/src/store/supplier.js +++ b/src/store/supplier.js @@ -48,6 +48,12 @@ export class Supplier { await this.getData(); return response; } + + async changeStatus(id, status) { + const response = await http.get(`/users/supplier/${id}/${status}`); + await this.getData(); + return response; + } }