94 lines
2.9 KiB
JavaScript
94 lines
2.9 KiB
JavaScript
import React, {useContext, useEffect} from "react";
|
|
import {Button, Card, Col, Input, message, Row, Upload} from "antd";
|
|
import {FilterOutlined, PlusSquareOutlined, UploadOutlined,} from "@ant-design/icons";
|
|
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
|
import {useStore} from "../../utils/useStore";
|
|
import {observer} from "mobx-react-lite";
|
|
import {ProductComponent} from "../../component/ProductComponent";
|
|
import {LINKS} from "../../routes/app";
|
|
import {ModalLoaderContext} from "../../utils/modal";
|
|
|
|
const {Search} = Input;
|
|
|
|
export const Product = observer(() => {
|
|
const store = useStore();
|
|
const modalLoader = useContext(ModalLoaderContext);
|
|
|
|
useEffect(() => {
|
|
const init = async () => {
|
|
try {
|
|
modalLoader.setLoading(true);
|
|
await Promise.allSettled([
|
|
store.supplier.getData(),
|
|
store.category.getData(),
|
|
store.product.getDataSubCategories(),
|
|
]);
|
|
await store.product.getData();
|
|
modalLoader.setLoading(false);
|
|
} catch (e) {
|
|
modalLoader.setLoading(false);
|
|
if (e.response?.body?.message) {
|
|
message.error(e.response.body.message);
|
|
return;
|
|
}
|
|
message.error(e.message);
|
|
}
|
|
};
|
|
|
|
init();
|
|
}, []);
|
|
|
|
const routeData = [
|
|
{
|
|
route: LINKS.HOME,
|
|
name: "Home",
|
|
},
|
|
{
|
|
route: LINKS.PRODUCT,
|
|
name: <span style={{ fontWeight: "bold" }}>Product</span>,
|
|
},
|
|
];
|
|
|
|
return (
|
|
<div className={["ppob-container"].join(" ")}>
|
|
<BreadcumbComponent data={routeData} />
|
|
<Card>
|
|
<Row style={{marginBottom: 20}}>
|
|
<Col span={12}>
|
|
<Button onClick={() => {
|
|
store.product.visibleModalFilterProduct = true
|
|
}}>
|
|
<FilterOutlined/>
|
|
Filter
|
|
</Button>
|
|
</Col>
|
|
<Col span={12}>
|
|
<div style={{display: store.ui.mediaQuery.isMobile? "" :'flex',justifyContent: 'flex-end',textAlign: "right"}}>
|
|
<Search
|
|
placeholder="input search text"
|
|
style={{
|
|
width: store.ui.mediaQuery.isMobile ? 160 : 200,
|
|
marginRight: store.ui.mediaQuery.isMobile ? 0 : 10,
|
|
marginBottom: store.ui.mediaQuery.isMobile ? 10 : 0,
|
|
}}
|
|
/>
|
|
<Upload>
|
|
<Button disabled={store.product.uploadBtnProduct} style={{
|
|
marginRight: store.ui.mediaQuery.isMobile ? 0 : 10,
|
|
marginBottom: store.ui.mediaQuery.isMobile ? 10 : 0,
|
|
}} icon={<UploadOutlined/>}>
|
|
Upload Product
|
|
</Button>
|
|
</Upload>
|
|
<Button onClick={() => (store.product.visibleModalProduct = true)}>
|
|
<PlusSquareOutlined/> New
|
|
</Button>
|
|
</div>
|
|
</Col>
|
|
</Row>
|
|
<ProductComponent/>
|
|
</Card>
|
|
</div>
|
|
);
|
|
});
|