Merge
This commit is contained in:
64
src/pages/Product/Category.js
Normal file
64
src/pages/Product/Category.js
Normal file
@@ -0,0 +1,64 @@
|
||||
import React, {useContext, useEffect, useState} from "react";
|
||||
import {Button, Card, Col, Input, Row, Tabs,message} from "antd";
|
||||
import {FilterOutlined, PlusSquareOutlined} from "@ant-design/icons";
|
||||
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
||||
import {useStore} from "../../utils/useStore";
|
||||
import {observer} from "mobx-react-lite";
|
||||
import {LINKS} from "../../routes/app";
|
||||
import {CategoryComponent} from "../../component/CategoryComponent";
|
||||
import {ModalLoaderContext} from "../../utils/modal";
|
||||
|
||||
|
||||
export const Category = observer(() => {
|
||||
const store = useStore();
|
||||
const modalLoader = useContext(ModalLoaderContext);
|
||||
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
try {
|
||||
modalLoader.setLoading(true);
|
||||
await store.category.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: "Beranda",
|
||||
},
|
||||
{
|
||||
route: LINKS.CATEGORY,
|
||||
name: <span style={{ fontWeight: "bold" }}>Kategori</span>,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className={["ppob-container"].join(" ")}>
|
||||
<BreadcumbComponent data={routeData} />
|
||||
<Card>
|
||||
<Row style={{ marginBottom: 20 }}>
|
||||
<Col span={24} style={{ textAlign: "right" }}>
|
||||
<Button
|
||||
onClick={() => (store.category.visibleModalCategory = true)}
|
||||
>
|
||||
<PlusSquareOutlined /> New
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<CategoryComponent />
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -1,120 +1,324 @@
|
||||
import React,{useState,useEffect} from "react";
|
||||
import {Button, Card, Col, Input, Row, Tabs,message} from "antd";
|
||||
import {FilterOutlined, PlusSquareOutlined,} from "@ant-design/icons";
|
||||
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
||||
import {Pulsa} from "./Pulsa";
|
||||
import {PulsaModal} from "./PulsaModal";
|
||||
import {useStore} from "../../utils/useStore";
|
||||
import {observer} from "mobx-react-lite";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Col,
|
||||
Form,
|
||||
Input,
|
||||
message,
|
||||
Modal,
|
||||
Row,
|
||||
Select,
|
||||
Upload,
|
||||
} from "antd";
|
||||
import {
|
||||
FilterOutlined,
|
||||
PlusOutlined,
|
||||
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;
|
||||
const { Option } = Select;
|
||||
|
||||
|
||||
|
||||
const {TabPane} = Tabs;
|
||||
const {Search} = Input;
|
||||
|
||||
export const Product =observer(() => {
|
||||
const [visibleModal, setVisibleModal] = useState(false)
|
||||
const [initialData, setInitialData] = useState({})
|
||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
export const Product = observer(() => {
|
||||
const store = useStore();
|
||||
const modalLoader = useContext(ModalLoaderContext);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [visibleModalUpload, setVisibleModalUpload] = useState(false);
|
||||
const [excel, setExcel] = useState("");
|
||||
const [fileList, setFileList] = useState([]);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
try {
|
||||
store.supplier.page = 0;
|
||||
store.supplier.pageSize = 1000;
|
||||
modalLoader.setLoading(true);
|
||||
await Promise.allSettled([
|
||||
store.supplier.getData(),
|
||||
store.category.getData(),
|
||||
store.product.getDataSubCategories(),
|
||||
store.product.getProductPartner(),
|
||||
]);
|
||||
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();
|
||||
|
||||
return () => {
|
||||
store.supplier.pageSize = 10;
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
const callback = (key) => {
|
||||
console.log(key);
|
||||
};
|
||||
|
||||
const routeData = [
|
||||
{
|
||||
route: "/app/home",
|
||||
name: "Home",
|
||||
route: LINKS.HOME,
|
||||
name: "Beranda",
|
||||
},
|
||||
{
|
||||
route: "/app/product",
|
||||
name: <span style={{fontWeight: 'bold'}}>Product</span>,
|
||||
route: LINKS.PRODUCT,
|
||||
name: <span style={{ fontWeight: "bold" }}>Produk</span>,
|
||||
},
|
||||
];
|
||||
const onSubmit = async (data) => {
|
||||
if (initialData.id) {
|
||||
setInitialData({})
|
||||
setConfirmLoading(true);
|
||||
try {
|
||||
await store.product.update(initialData.id, data)
|
||||
message.success("Success Update Data Member")
|
||||
} catch (e) {
|
||||
message.error("Failed Update Data Member")
|
||||
}
|
||||
setConfirmLoading(false);
|
||||
setVisibleModal(false);
|
||||
} else {
|
||||
setInitialData({})
|
||||
setConfirmLoading(true);
|
||||
try {
|
||||
await store.product.create(data)
|
||||
message.success("Success Add New Member")
|
||||
} catch (e) {
|
||||
console.log(e, "apa errornya")
|
||||
message.error("Failed Add Member")
|
||||
}
|
||||
setConfirmLoading(false);
|
||||
setVisibleModal(false);
|
||||
|
||||
const dataRoute = [
|
||||
{
|
||||
route: LINKS.PRODUCT,
|
||||
name: "Produk",
|
||||
},
|
||||
];
|
||||
|
||||
const beforeUpload = (file) => {
|
||||
let isLt2M;
|
||||
let allowedFile = [
|
||||
"text/csv",
|
||||
"application/csv",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"application/vnd.ms-excel.sheet.binary.macroEnabled.12",
|
||||
"application/vnd.ms-excel",
|
||||
"application/vnd.ms-excel.sheet.macroEnabled.12",
|
||||
];
|
||||
let isValid = allowedFile.includes(file.type);
|
||||
if (!isValid) {
|
||||
message.error("You can only upload Excel file!");
|
||||
}
|
||||
}
|
||||
isLt2M = file.size / 1024 / 1024 < 10;
|
||||
if (!isLt2M) {
|
||||
message.error("File must smaller than 10MB!");
|
||||
}
|
||||
return isValid && isLt2M ? true : Upload.LIST_IGNORE;
|
||||
};
|
||||
|
||||
const uploadHandler = async (args) => {
|
||||
const file = args.file;
|
||||
try {
|
||||
const response = await store.product.uploadExcel(file);
|
||||
|
||||
if (response.status === 201) {
|
||||
message.success("Success upload excel!");
|
||||
} else {
|
||||
message.error("Failed upload excel!");
|
||||
}
|
||||
|
||||
setFileList([
|
||||
{
|
||||
uid: "-1",
|
||||
name: response.body.filename,
|
||||
status: "done",
|
||||
url: "",
|
||||
},
|
||||
]);
|
||||
setExcel(response.body.filename);
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
message.error("Failed upload excel!");
|
||||
}
|
||||
};
|
||||
|
||||
const handleChange = (info) => {
|
||||
if (info.file.status === "uploading") {
|
||||
setLoading(true);
|
||||
} else {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleUploadProduct = async (data) => {
|
||||
try {
|
||||
const response = await store.product.uploadProduct(data);
|
||||
|
||||
if (response.status === 201) {
|
||||
message.success("Success Create Product by Excel!");
|
||||
} else {
|
||||
message.error("Failed Create Product by Excel!");
|
||||
}
|
||||
return response;
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
message.error("Failed Create Product by Excel!");
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
form.resetFields();
|
||||
setFileList([]);
|
||||
setExcel("");
|
||||
setVisibleModalUpload(false);
|
||||
};
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
const request = {
|
||||
fileName: excel,
|
||||
supplierCode: data.supplierCode,
|
||||
};
|
||||
const responseUploadProduct = await handleUploadProduct(request);
|
||||
|
||||
await store.product.getData();
|
||||
setLoading(false);
|
||||
setFileList([]);
|
||||
setExcel("");
|
||||
setVisibleModalUpload(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<BreadcumbComponent data={routeData}/>
|
||||
<Card>
|
||||
<Row style={{marginBottom: 20}}>
|
||||
<div className={["ppob-container"].join(" ")}>
|
||||
<BreadcumbComponent
|
||||
data={
|
||||
store.authentication.userData.role === "Admin" ||
|
||||
store.authentication.userData.role === "Admin Partner"
|
||||
? routeData
|
||||
: dataRoute
|
||||
}
|
||||
/>
|
||||
<Card>
|
||||
<div>
|
||||
<Row style={{ marginBottom: 20 }}>
|
||||
<Col span={12}>
|
||||
<Button>
|
||||
<FilterOutlined/>
|
||||
<Button
|
||||
onClick={() => {
|
||||
store.product.visibleModalFilterProduct = true;
|
||||
}}
|
||||
>
|
||||
<FilterOutlined />
|
||||
Filter
|
||||
</Button>
|
||||
</Col>
|
||||
<Col span={12} style={{textAlign: "right"}}>
|
||||
<Search
|
||||
placeholder="input search text"
|
||||
style={{width: 200, marginRight: 10}}
|
||||
/>
|
||||
<Button onClick={() => setVisibleModal(true)}>
|
||||
<PlusSquareOutlined/> New
|
||||
</Button>
|
||||
<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,
|
||||
}}
|
||||
/> */}
|
||||
|
||||
{store.authentication.userData.role == "Admin" && (
|
||||
<div
|
||||
style={{
|
||||
display: store.ui.mediaQuery.isMobile ? "" : "flex",
|
||||
justifyContent: "flex-end",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
disabled={visibleModalUpload}
|
||||
style={{
|
||||
marginRight: store.ui.mediaQuery.isMobile ? 0 : 10,
|
||||
marginBottom: store.ui.mediaQuery.isMobile ? 10 : 10,
|
||||
}}
|
||||
icon={<PlusOutlined />}
|
||||
onClick={() => setVisibleModalUpload(true)}
|
||||
>
|
||||
Tambah Produk
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
<Tabs
|
||||
defaultActiveKey="1"
|
||||
onChange={callback}
|
||||
size="default"
|
||||
tabBarGutter="50"
|
||||
</div>
|
||||
<ProductComponent />
|
||||
</Card>
|
||||
|
||||
<Modal
|
||||
visible={visibleModalUpload}
|
||||
title={"Upload Excel Product"}
|
||||
okText={"Create"}
|
||||
cancelText="Cancel"
|
||||
onCancel={() => {
|
||||
form.resetFields();
|
||||
handleCancel();
|
||||
}}
|
||||
onOk={() => {
|
||||
form
|
||||
.validateFields()
|
||||
.then((values) => {
|
||||
console.log(values, "isi form");
|
||||
handleSubmit(values);
|
||||
form.resetFields();
|
||||
})
|
||||
.catch((info) => {
|
||||
console.error("Validate Failed:", info);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item
|
||||
name="fileName"
|
||||
label="Upload Excel Product"
|
||||
rules={[
|
||||
{ required: true, message: "Please Upload Excel Product!" },
|
||||
]}
|
||||
>
|
||||
<TabPane tab="Pulsa" key="1">
|
||||
<Pulsa/>
|
||||
</TabPane>
|
||||
<TabPane tab="Game Voucher" key="2">
|
||||
Game Voucher
|
||||
</TabPane>
|
||||
<TabPane tab="Product" key="3">
|
||||
Product
|
||||
</TabPane>
|
||||
<TabPane tab="Prduct" key="4">
|
||||
Prduct
|
||||
</TabPane>
|
||||
<TabPane tab="Prdct" key="5">
|
||||
Prdct
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</Card>
|
||||
<PulsaModal visible={visibleModal}
|
||||
confirmLoading={confirmLoading}
|
||||
initialData={initialData}
|
||||
onCreate={async (data) => {
|
||||
onSubmit(data)
|
||||
}}
|
||||
onCancel={() => {
|
||||
setInitialData({})
|
||||
setVisibleModal(false);
|
||||
}}/>
|
||||
</div>
|
||||
<Upload
|
||||
fileList={fileList}
|
||||
onChange={handleChange}
|
||||
beforeUpload={(file) => beforeUpload(file)}
|
||||
customRequest={(args) => uploadHandler(args)}
|
||||
onRemove={(file) => {
|
||||
setLoading(false);
|
||||
setFileList([]);
|
||||
setExcel("");
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
disabled={loading}
|
||||
style={{
|
||||
marginRight: store.ui.mediaQuery.isMobile ? 0 : 10,
|
||||
}}
|
||||
icon={<UploadOutlined />}
|
||||
>
|
||||
Upload Product
|
||||
</Button>
|
||||
</div>
|
||||
</Upload>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="supplierCode"
|
||||
label="Supplier Code"
|
||||
rules={[{ required: true, message: "Please input Supplier Code!" }]}
|
||||
>
|
||||
<Select>
|
||||
{store.supplier.data.map((data) => (
|
||||
<Option key={data.id} value={data.code}>
|
||||
{data.name}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
171
src/pages/Product/ProductDetail.js
Normal file
171
src/pages/Product/ProductDetail.js
Normal file
@@ -0,0 +1,171 @@
|
||||
import React, { useContext, useEffect } from "react";
|
||||
import { Card, Col, Row, Table, Typography, Tag } from "antd";
|
||||
import { BreadcumbComponent } from "../../component/BreadcumbComponent";
|
||||
import { LINKS } from "../../routes/app";
|
||||
import { useStore } from "../../utils/useStore";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { format, parseISO } from "date-fns";
|
||||
import { ModalLoaderContext } from "../../utils/modal";
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
export const ProductDetail = observer(() => {
|
||||
const store = useStore();
|
||||
const { id } = useParams();
|
||||
const modalLoader = useContext(ModalLoaderContext);
|
||||
|
||||
const routeData = [
|
||||
{
|
||||
route: LINKS.HOME,
|
||||
name: "Beranda",
|
||||
},
|
||||
{
|
||||
route: LINKS.PRODUCT,
|
||||
name: <span style={{ fontWeight: "bold" }}>Produk</span>,
|
||||
},
|
||||
{
|
||||
route: LINKS.PRODUCT_DETAIL.replace(":id", `${id}`),
|
||||
name: <span style={{ fontWeight: "bold" }}>Detail Produk</span>,
|
||||
},
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
modalLoader.setLoading(true);
|
||||
await Promise.allSettled([
|
||||
store.product.getPriceHistoryByProduct(id),
|
||||
store.product.getDetailProduct(id),
|
||||
]);
|
||||
modalLoader.setLoading(false);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: "Markup Price",
|
||||
dataIndex: "mark_up_price",
|
||||
key: "mark_up_price",
|
||||
render: (text) =>
|
||||
new Intl.NumberFormat("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
}).format(text),
|
||||
},
|
||||
{
|
||||
title: "Price",
|
||||
dataIndex: "price",
|
||||
key: "price",
|
||||
render: (text) =>
|
||||
new Intl.NumberFormat("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
}).format(text),
|
||||
},
|
||||
{
|
||||
title: "Tanggal Berlaku",
|
||||
dataIndex: "startDate",
|
||||
key: "startDate",
|
||||
render: (text) => {
|
||||
return (
|
||||
<Text>{text ? format(parseISO(text), "dd MMMM yyyy") : "-"}</Text>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Tanggal Berakhir",
|
||||
dataIndex: "endDate",
|
||||
key: "endDate",
|
||||
render: (text) => {
|
||||
return (
|
||||
<Text>
|
||||
{text ? format(parseISO(text), "dd MMMM yyyy") : "Sampai Sekarang"}
|
||||
</Text>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const styleSaldoTitle = store.ui.mediaQuery.isDesktop
|
||||
? {
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
}
|
||||
: { fontSize: "0.75rem" };
|
||||
const styleSaldoContent = store.ui.mediaQuery.isDesktop
|
||||
? {
|
||||
fontSize: "1.25rem",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
}
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div className={[""].join(" ")}>
|
||||
<BreadcumbComponent data={routeData} />
|
||||
<Card>
|
||||
<Title strong>Product Detail</Title>
|
||||
<Row style={{ marginBottom: 20 }}>
|
||||
<Col lg={12} xs={24}>
|
||||
<Row>
|
||||
<Col span={12}>
|
||||
<Text strong>Kode</Text>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Text>{store.product?.dataDetailProduct?.code}</Text>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Text strong>Nama Produk</Text>
|
||||
</Col>
|
||||
<Col span={10}>
|
||||
<Text>{store.product?.dataDetailProduct?.name}</Text>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Text strong>Supplier</Text>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Text>{store.product?.dataDetailProduct?.supplier?.name}</Text>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Text strong>Status</Text>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Text>{store.product?.dataDetailProduct?.status}</Text>
|
||||
</Col>
|
||||
</Row>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col span={24}>
|
||||
<div>
|
||||
<Title strong level={3}>
|
||||
Product Price History
|
||||
</Title>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={store.product.dataPriceHistory}
|
||||
bordered
|
||||
pagination={{
|
||||
pageSize: store.product.pageSizePriceHistory,
|
||||
total: store.product.totalDataPriceHistory,
|
||||
current: store.product.pagePriceHistory + 1,
|
||||
showSizeChanger: true,
|
||||
simple: false,
|
||||
}}
|
||||
onChange={async (page) => {
|
||||
let pageNumber = page.current;
|
||||
store.product.pageSizePriceHistory = page.pageSize;
|
||||
store.product.pagePriceHistory = pageNumber - 1;
|
||||
modalLoader.setLoading(true);
|
||||
await store.product.getPriceHistoryByProduct(id);
|
||||
modalLoader.setLoading(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
<div />
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
69
src/pages/Product/Subcategory.js
Normal file
69
src/pages/Product/Subcategory.js
Normal file
@@ -0,0 +1,69 @@
|
||||
import React, { useContext, useEffect } from "react";
|
||||
import { Button, Card, Col, Input, message, Row } from "antd";
|
||||
import { PlusSquareOutlined } from "@ant-design/icons";
|
||||
import { BreadcumbComponent } from "../../component/BreadcumbComponent";
|
||||
import { useStore } from "../../utils/useStore";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { LINKS } from "../../routes/app";
|
||||
import { SubcategoryComponent } from "../../component/SubcategoryComponent";
|
||||
import { ModalLoaderContext } from "../../utils/modal";
|
||||
|
||||
const { Search } = Input;
|
||||
|
||||
export const Subcategory = observer(() => {
|
||||
const store = useStore();
|
||||
const modalLoader = useContext(ModalLoaderContext);
|
||||
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
try {
|
||||
modalLoader.setLoading(true);
|
||||
await 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 getData = async () => {
|
||||
await store.category.getData();
|
||||
await store.subcategory.getData();
|
||||
};
|
||||
|
||||
const routeData = [
|
||||
{
|
||||
route: LINKS.HOME,
|
||||
name: "Beranda",
|
||||
},
|
||||
{
|
||||
route: LINKS.SUBCATEGORY,
|
||||
name: <span style={{ fontWeight: "bold" }}>Sub Kategori</span>,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className={["ppob-container"].join(" ")}>
|
||||
<BreadcumbComponent data={routeData} />
|
||||
<Card>
|
||||
<Row style={{ marginBottom: 20 }}>
|
||||
<Col span={24} style={{ textAlign: "right" }}>
|
||||
<Button
|
||||
onClick={() => (store.subcategory.visibleModalSubcategory = true)}
|
||||
>
|
||||
<PlusSquareOutlined /> New
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
<SubcategoryComponent />
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user