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: Produk,
},
{
route: LINKS.PRODUCT_DETAIL.replace(":id", `${id}`),
name: Detail Produk,
},
];
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 (