feat: update supplier status

This commit is contained in:
rarsyansyahr 2021-12-15 15:35:57 +07:00
parent 5e3f8fa3a2
commit c8278c2cea
5 changed files with 25 additions and 2 deletions

View File

@ -51,6 +51,11 @@ export const SupplierComponent = observer((props) => {
setIdData(data.id); setIdData(data.id);
}; };
const changeStatus = (id, isActive) => {
const status = isActive ? "inactive" : "active"
store.supplier.changeStatus(id, status)
}
const columns = [ const columns = [
{ {
title: "Name", title: "Name",
@ -69,7 +74,8 @@ export const SupplierComponent = observer((props) => {
render: (text, record) => ( render: (text, record) => (
<Tag <Tag
color={record?.status === true ? "processing" : "#E3E8EE"} color={record?.status === true ? "processing" : "#E3E8EE"}
style={{ color: "#4F566B" }} style={{ color: "#4F566B", cursor: 'pointer' }}
onClick={() => changeStatus(record?.id, record?.status)}
> >
{record?.status === true ? " ACTIVE" : "INACTIVE"} {record?.status === true ? " ACTIVE" : "INACTIVE"}
</Tag> </Tag>

View File

@ -32,24 +32,28 @@ export const Payback = observer(() => {
const dummyData = [ const dummyData = [
{ {
key: '1',
id: 1, id: 1,
name: "John Doe", name: "John Doe",
picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg",
amount: "Rp. 1.000.000", amount: "Rp. 1.000.000",
}, },
{ {
key: '2',
id: 1, id: 1,
name: "John Doe", name: "John Doe",
picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg",
amount: "Rp. 1.000.000", amount: "Rp. 1.000.000",
}, },
{ {
key: '3',
id: 1, id: 1,
name: "John Doe", name: "John Doe",
picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg",
amount: "Rp. 1.000.000", amount: "Rp. 1.000.000",
}, },
{ {
key: '4',Z
id: 1, id: 1,
name: "John Doe", name: "John Doe",
picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg",

View File

@ -32,6 +32,7 @@ export const Product = observer(() => {
const handleChangeTabPane = async (key) => { const handleChangeTabPane = async (key) => {
store.product.filterCategory = key; store.product.filterCategory = key;
console.log(key); console.log(key);
await store.product.getData()
}; };
const routeData = [ const routeData = [

View File

@ -27,8 +27,14 @@ export class Product {
async getData() { async getData() {
const response = await http.get(`/product/by-categories?categories=${this.filterCategory}&page=${this.page}&pageSize=${this.pageSize}`); 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 this.total_data = response.body.total_data ?? 0
console.log(response.body.data, this.filterCategory);
} }
async getDataSubCategories() { async getDataSubCategories() {

View File

@ -48,6 +48,12 @@ export class Supplier {
await this.getData(); await this.getData();
return response; return response;
} }
async changeStatus(id, status) {
const response = await http.get(`/users/supplier/${id}/${status}`);
await this.getData();
return response;
}
} }