feat: remove action column and handler filter modal product
This commit is contained in:
parent
51e92559e8
commit
068444fb07
|
@ -1,5 +1,5 @@
|
||||||
import React, {useState} from "react";
|
import React, {useState} from "react";
|
||||||
import {Button, Col, Form, Input, message, Modal, Row, Select, Space, Table, Tag, Typography} from "antd";
|
import {Button, Col, Form, Input, message, Modal, Row, Select, Table, Tag, Typography} from "antd";
|
||||||
import {observer} from "mobx-react-lite";
|
import {observer} from "mobx-react-lite";
|
||||||
import {ExclamationCircleOutlined} from "@ant-design/icons";
|
import {ExclamationCircleOutlined} from "@ant-design/icons";
|
||||||
import {useHistory} from "react-router-dom";
|
import {useHistory} from "react-router-dom";
|
||||||
|
@ -81,23 +81,7 @@ export const ProductComponent = observer((props) => {
|
||||||
{record?.status === "ACTIVE" ? " Ya" : "Tidak"}
|
{record?.status === "ACTIVE" ? " Ya" : "Tidak"}
|
||||||
</Tag>
|
</Tag>
|
||||||
),
|
),
|
||||||
},
|
}
|
||||||
{
|
|
||||||
title: "Action",
|
|
||||||
key: "action",
|
|
||||||
render: (text, record) => (
|
|
||||||
<Space size="middle">
|
|
||||||
<Button
|
|
||||||
onClick={() => handleEditButton(record)}
|
|
||||||
>Edit</Button>
|
|
||||||
<Button
|
|
||||||
onClick={() => handleDelete(record.id)}
|
|
||||||
>
|
|
||||||
Delete
|
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const deleteData = async (id) => {
|
const deleteData = async (id) => {
|
||||||
|
@ -331,8 +315,10 @@ export const ProductComponent = observer((props) => {
|
||||||
<Select
|
<Select
|
||||||
mode={"multiple"}
|
mode={"multiple"}
|
||||||
placeholder="Choose Category"
|
placeholder="Choose Category"
|
||||||
onChange={(val) => {
|
onChange={async (val) => {
|
||||||
setFilterCategories(val);
|
setFilterCategories(val);
|
||||||
|
store.product.filterByCategory = val;
|
||||||
|
await store.product.getDataSubCategories();
|
||||||
}}
|
}}
|
||||||
style={{marginBottom: "20px", width: "100%"}}
|
style={{marginBottom: "20px", width: "100%"}}
|
||||||
>
|
>
|
||||||
|
@ -353,7 +339,7 @@ export const ProductComponent = observer((props) => {
|
||||||
}}
|
}}
|
||||||
style={{marginBottom: "20px", width: "100%"}}
|
style={{marginBottom: "20px", width: "100%"}}
|
||||||
>
|
>
|
||||||
{store.category.dataSubCategories.map((item) => (
|
{store.product.dataSubCategories.map((item) => (
|
||||||
<Option value={item.id} key={item.id}>
|
<Option value={item.id} key={item.id}>
|
||||||
{item.name}
|
{item.name}
|
||||||
</Option>
|
</Option>
|
||||||
|
|
|
@ -22,9 +22,7 @@ export const Product = observer(() => {
|
||||||
await Promise.allSettled([
|
await Promise.allSettled([
|
||||||
store.supplier.getData(),
|
store.supplier.getData(),
|
||||||
store.product.getDataCategories(),
|
store.product.getDataCategories(),
|
||||||
store.product.getDataSubCategories(),
|
|
||||||
store.category.getData(),
|
store.category.getData(),
|
||||||
store.category.getDataSubCategories(),
|
|
||||||
]);
|
]);
|
||||||
await store.product.getData();
|
await store.product.getData();
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|
|
@ -22,6 +22,7 @@ export class Product {
|
||||||
pageSizeSubCategories = 10
|
pageSizeSubCategories = 10
|
||||||
dataSubCategories = [];
|
dataSubCategories = [];
|
||||||
total_dataSubCategories = 0;
|
total_dataSubCategories = 0;
|
||||||
|
filterByCategory = null;
|
||||||
|
|
||||||
constructor(ctx) {
|
constructor(ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
@ -44,7 +45,7 @@ export class Product {
|
||||||
|
|
||||||
async getDataSubCategories() {
|
async getDataSubCategories() {
|
||||||
try {
|
try {
|
||||||
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
const response = await http.get(`/product/sub-categories?category=${this.filterByCategory}&page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
||||||
this.dataSubCategories = response.body.data.map((item, idx) => {
|
this.dataSubCategories = response.body.data.map((item, idx) => {
|
||||||
item.key = idx;
|
item.key = idx;
|
||||||
return item
|
return item
|
||||||
|
|
Loading…
Reference in New Issue
Block a user