Merge branch 'develop' of https://gitlab.com/empatnusabangsa/ppob/ppob-frontend into devops-staging

This commit is contained in:
Fadli 2022-05-11 18:57:49 +07:00
commit 0a33fe117a
2 changed files with 520 additions and 499 deletions

View File

@ -64,30 +64,40 @@ export const ProductComponent = observer((props) => {
dataIndex: "current_price_price", dataIndex: "current_price_price",
key: "current_price_price", key: "current_price_price",
render: (text) => render: (text) =>
new Intl.NumberFormat("id-ID", { new Intl.NumberFormat("id-ID", {
style: "currency", style: "currency",
currency: "IDR", currency: "IDR",
}).format(text), }).format(text),
}, },
{ {
title: "Harga Jual", title: "Harga Jual",
dataIndex: "mark_up_price", dataIndex: "mark_up_price",
key: "mark_up_price", key: "mark_up_price",
render: (text) => render: (text) =>
new Intl.NumberFormat("id-ID", { new Intl.NumberFormat("id-ID", {
style: "currency", style: "currency",
currency: "IDR", currency: "IDR",
}).format(text), }).format(text),
}, },
{ {
title: "Harga", title: "Harga",
dataIndex: "price", dataIndex: "price",
key: "price", key: "price",
render: (text) => render: (text) =>
new Intl.NumberFormat("id-ID", { new Intl.NumberFormat("id-ID", {
style: "currency", style: "currency",
currency: "IDR", currency: "IDR",
}).format(text), }).format(text),
},
{
title: "Biaya Admin",
dataIndex: "admin_price",
key: "admin_price",
render: (text) =>
new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(text),
}, },
{ {
title: "Supplier", title: "Supplier",
@ -104,27 +114,27 @@ export const ProductComponent = observer((props) => {
dataIndex: "tersedia", dataIndex: "tersedia",
key: "tersedia", key: "tersedia",
render: (text, record) => ( render: (text, record) => (
<Tag <Tag
color={record?.product_status === "ACTIVE" ? "blue" : "#E3E8EE"} color={record?.product_status === "ACTIVE" ? "blue" : "#E3E8EE"}
style={{ color: "#4F566B" }} style={{ color: "#4F566B" }}
> >
{record?.product_status === "ACTIVE" ? " Tersedia" : "Tidak"} {record?.product_status === "ACTIVE" ? " Tersedia" : "Tidak"}
</Tag> </Tag>
), ),
}, },
{ {
title: "Tindakan", title: "Tindakan",
key: "action", key: "action",
render: (text, record) => ( render: (text, record) => (
<Button <Button
onClick={async () => { onClick={async () => {
history.push( history.push(
LINKS.PRODUCT_DETAIL.replace(":id", record.product_id) LINKS.PRODUCT_DETAIL.replace(":id", record.product_id)
); );
}} }}
> >
Detail Detail
</Button> </Button>
), ),
}, },
]; ];
@ -180,10 +190,10 @@ export const ProductComponent = observer((props) => {
try { try {
const response = await store.product.update(idData, data); const response = await store.product.update(idData, data);
response?.body?.statusCode === 201 || response?.body?.statusCode === 200 response?.body?.statusCode === 201 || response?.body?.statusCode === 200
? message.success( ? message.success(
response?.body?.message || "Berhasil Ubah Data Produk" response?.body?.message || "Berhasil Ubah Data Produk"
) )
: message.error(response?.body?.message || "Gagal Ubah Data Produk"); : message.error(response?.body?.message || "Gagal Ubah Data Produk");
} catch (e) { } catch (e) {
message.error(e.response?.body?.message || "Gagal Ubah Data Produk"); message.error(e.response?.body?.message || "Gagal Ubah Data Produk");
} }
@ -196,8 +206,8 @@ export const ProductComponent = observer((props) => {
try { try {
const response = await store.product.create(data); const response = await store.product.create(data);
response?.body?.statusCode === 201 || response?.body?.statusCode === 200 response?.body?.statusCode === 201 || response?.body?.statusCode === 200
? message.success(response?.body?.message || "Berhasil Tambah Produk") ? message.success(response?.body?.message || "Berhasil Tambah Produk")
: message.error(response?.body?.message || "Gagal Tambah Produk"); : message.error(response?.body?.message || "Gagal Tambah Produk");
} catch (e) { } catch (e) {
console.log(e, "apa errornya"); console.log(e, "apa errornya");
message.error(e.response?.body?.message || "Gagal Tambah Produk"); message.error(e.response?.body?.message || "Gagal Tambah Produk");
@ -217,8 +227,8 @@ export const ProductComponent = observer((props) => {
setFilterSupplier([]); setFilterSupplier([]);
setFilterSubCategories([]); setFilterSubCategories([]);
store.authentication.userData.role === "Admin Partner" store.authentication.userData.role === "Admin Partner"
? await store.product.getProductPartner() ? await store.product.getProductPartner()
: await store.product.getData(); : await store.product.getData();
//await store.product.getData(); //await store.product.getData();
modalLoader.setLoading(false); modalLoader.setLoading(false);
}; };
@ -235,8 +245,8 @@ export const ProductComponent = observer((props) => {
store.product.filterSubCategory = filterSubCategories; store.product.filterSubCategory = filterSubCategories;
modalLoader.setLoading(true); modalLoader.setLoading(true);
store.authentication.userData.role === "Admin Partner" store.authentication.userData.role === "Admin Partner"
? await store.product.getProductPartner(filterSubCategories) ? await store.product.getProductPartner(filterSubCategories)
: await store.product.getData(); : await store.product.getData();
//await store.product.getData(); //await store.product.getData();
modalLoader.setLoading(false); modalLoader.setLoading(false);
//store.product.page=1 //store.product.page=1
@ -244,12 +254,12 @@ export const ProductComponent = observer((props) => {
const footerLayoutFilter = [ const footerLayoutFilter = [
<Button <Button
key={"remove"} key={"remove"}
onClick={handleRemoveFilter} onClick={handleRemoveFilter}
style={{ style={{
backgroundColor: "#e74e5e", backgroundColor: "#e74e5e",
color: "#fff", color: "#fff",
}} }}
> >
Hapus Filter Hapus Filter
</Button>, </Button>,
@ -257,12 +267,12 @@ export const ProductComponent = observer((props) => {
Batal Batal
</Button>, </Button>,
<Button <Button
key={"submit"} key={"submit"}
onClick={handleSubmitFilter} onClick={handleSubmitFilter}
style={{ style={{
backgroundColor: "#4e79e7", backgroundColor: "#4e79e7",
color: "#fff", color: "#fff",
}} }}
> >
Terapkan Terapkan
</Button>, </Button>,
@ -274,292 +284,293 @@ export const ProductComponent = observer((props) => {
}, },
}); });
return ( return (
<div> <div>
{store.ui.mediaQuery.isDesktop && ( {store.ui.mediaQuery.isDesktop && (
<Table <Table
style={{ style={{
cursor: "pointer", cursor: "pointer",
textAlign: "center", textAlign: "center",
width: store.ui.mediaQuery.isMobile ? 250 : "", width: store.ui.mediaQuery.isMobile ? 250 : "",
}} }}
columns={columns} columns={columns}
dataSource={ dataSource={
store.authentication.userData.role === "Admin Partner" store.authentication.userData.role === "Admin Partner"
? store.product.dataProductPartner ? store.product.dataProductPartner
: store.product.data : store.product.data
} }
onRow={handleClickRow} onRow={handleClickRow}
pagination={{ pagination={{
pageSize: store.authentication.userData.role === "Admin" ? store.product.pageSize : store.product.pageSizeProductPartner, pageSize: store.authentication.userData.role === "Admin" ? store.product.pageSize : store.product.pageSizeProductPartner,
total: total:
store.authentication.userData.role === "Admin Partner" store.authentication.userData.role === "Admin Partner"
? store.product.total_data_partner ? store.product.total_data_partner
: store.product.total_data, : store.product.total_data,
current: store.authentication.userData.role === "Admin" ? store.product.page + 1 : store.product.pageProductPartner + 1, current: store.authentication.userData.role === "Admin" ? store.product.page + 1 : store.product.pageProductPartner + 1,
showSizeChanger: true, showSizeChanger: true,
simple: false, simple: false,
}} }}
onChange={async (page) => { onChange={async (page) => {
let pageNumber = page.current; let pageNumber = page.current;
store.authentication.userData.role === "Admin" ? store.product.pageSize = page.pageSize : store.product.pageSizeProductPartner = page.pageSize; store.authentication.userData.role === "Admin" ? store.product.pageSize = page.pageSize : store.product.pageSizeProductPartner = page.pageSize;
store.authentication.userData.role === "Admin" ? store.product.page = pageNumber - 1 : store.product.pageProductPartner = pageNumber - 1 store.authentication.userData.role === "Admin" ? store.product.page = pageNumber - 1 : store.product.pageProductPartner = pageNumber - 1
modalLoader.setLoading(true); store.product.filterSubCategory = filterSubCategories
store.authentication.userData.role === "Admin Partner" modalLoader.setLoading(true);
? await store.product.getProductPartner( store.authentication.userData.role === "Admin Partner"
// store.authentication.profileData.id ? await store.product.getProductPartner(
) // store.authentication.profileData.id
: await store.product.getData(); )
modalLoader.setLoading(false); : await store.product.getData();
}} modalLoader.setLoading(false);
/> }}
)} />
{store.ui.mediaQuery.isMobile && ( )}
<List {store.ui.mediaQuery.isMobile && (
itemLayout="horizontal" <List
position={"top"} itemLayout="horizontal"
pagination={{ position={"top"}
onChange: async (page, pageSize) => { pagination={{
store.authentication.userData.role === "Admin" ? store.product.pageSize = pageSize : store.product.pageSizeProductPartner = pageSize; onChange: async (page, pageSize) => {
store.authentication.userData.role === "Admin" ? store.product.page = page - 1 : store.product.pageProductPartner = page - 1 store.authentication.userData.role === "Admin" ? store.product.pageSize = pageSize : store.product.pageSizeProductPartner = pageSize;
modalLoader.setLoading(true); store.authentication.userData.role === "Admin" ? store.product.page = page - 1 : store.product.pageProductPartner = page - 1
store.authentication.userData.role === "Admin Partner" modalLoader.setLoading(true);
? await store.product.getProductPartner( store.authentication.userData.role === "Admin Partner"
// store.authentication.profileData.id ? await store.product.getProductPartner(
) // store.authentication.profileData.id
: await store.product.getData(); )
//await store.product.getData(); : await store.product.getData();
modalLoader.setLoading(false); //await store.product.getData();
}, modalLoader.setLoading(false);
pageSize: store.authentication.userData.role === "Admin" ? store.product.pageSize : store.product.pageSizeProductPartner, },
total: store.authentication.userData.role === "Admin Partner" pageSize: store.authentication.userData.role === "Admin" ? store.product.pageSize : store.product.pageSizeProductPartner,
? store.product.total_data_partner total: store.authentication.userData.role === "Admin Partner"
: store.product.total_data, ? store.product.total_data_partner
current: store.authentication.userData.role === "Admin" ? store.product.page + 1 : store.product.pageProductPartner + 1, : store.product.total_data,
style: { marginBottom: "1rem", marginRight: "1rem" }, current: store.authentication.userData.role === "Admin" ? store.product.page + 1 : store.product.pageProductPartner + 1,
}} style: { marginBottom: "1rem", marginRight: "1rem" },
dataSource={ }}
store.authentication.userData.role === "Admin Partner" dataSource={
? store.product.dataProductPartner store.authentication.userData.role === "Admin Partner"
: store.product.data ? store.product.dataProductPartner
} : store.product.data
style={{ padding: 0 }} }
renderItem={(item) => { style={{ padding: 0 }}
return ( renderItem={(item) => {
<div> return (
<List.Item <div>
key={item.id} <List.Item
style={{ key={item.id}
backgroundColor: "#ffffff", style={{
paddingTop: 0, backgroundColor: "#ffffff",
paddingBottom: 0, paddingTop: 0,
display: "flex", paddingBottom: 0,
flexDirection: "row", display: "flex",
alignItems: "center", flexDirection: "row",
justifyContent: "center", alignItems: "center",
}} justifyContent: "center",
>
<List.Item.Meta
className={[""].join(" ")}
title={item.product_code}
description={
<div style={{}}>
<p>
<small>{item.product_name}</small> <br />
{/* <small>Harga Beli : {item.current_price_price}</small>
<br /> */}
<small>Harga Jual : {item.mark_up_price}</small>
<br />
<Button
onClick={async () => {
history.push(
LINKS.PRODUCT_DETAIL.replace(
":id",
item.product_id
)
);
}} }}
> >
Detail <List.Item.Meta
</Button> className={[""].join(" ")}
</p> title={item.product_code}
<p></p> description={
<div style={{}}>
<p>
<small>{item.product_name}</small> <br />
{/* <small>Harga Beli : {item.current_price_price}</small>
<br /> */}
<small>Harga Jual : {item.mark_up_price}</small>
<br />
<Button
onClick={async () => {
history.push(
LINKS.PRODUCT_DETAIL.replace(
":id",
item.product_id
)
);
}}
>
Detail
</Button>
</p>
<p></p>
</div>
}
/>
<div style={{ marginRight: 16 }}>
<p
style={{
fontSize: 9,
margin: 0,
}}
>
<Tag
color={
item?.product_status === "ACTIVE" ? "blue" : "#E3E8EE"
}
style={{ color: "#4F566B" }}
>
{item?.product_status === "ACTIVE"
? " Tersedia"
: "Tidak"}
</Tag>
</p>
</div>
</List.Item>
<Divider plain style={{ margin: 0 }} />
</div> </div>
} );
/> }}
<div style={{ marginRight: 16 }}> />
<p )}
style={{ <Modal
fontSize: 9, visible={store.product.visibleModalProduct}
margin: 0, title={idData ? "Edit Product" : "Create a new Product"}
}} okText={idData ? "Edit" : "Create"}
> cancelText="Batal"
<Tag onCancel={() => {
color={
item?.product_status === "ACTIVE" ? "blue" : "#E3E8EE"
}
style={{ color: "#4F566B" }}
>
{item?.product_status === "ACTIVE"
? " Tersedia"
: "Tidak"}
</Tag>
</p>
</div>
</List.Item>
<Divider plain style={{ margin: 0 }} />
</div>
);
}}
/>
)}
<Modal
visible={store.product.visibleModalProduct}
title={idData ? "Edit Product" : "Create a new Product"}
okText={idData ? "Edit" : "Create"}
cancelText="Batal"
onCancel={() => {
form.resetFields();
handleCancel();
}}
onOk={() => {
form
.validateFields()
.then((values) => {
console.log(values, "isi form");
handleSubmit(values);
form.resetFields(); form.resetFields();
}) handleCancel();
.catch((info) => { }}
console.error("Validate Failed:", info); onOk={() => {
}); form
}} .validateFields()
> .then((values) => {
<Form form={form} layout="vertical"> console.log(values, "isi form");
<Form.Item handleSubmit(values);
name="name" form.resetFields();
label="Name" })
rules={[{ required: true, message: "Please input name!" }]} .catch((info) => {
> console.error("Validate Failed:", info);
<Input /> });
</Form.Item> }}
<Form.Item >
name="price" <Form form={form} layout="vertical">
label="Price" <Form.Item
rules={[{ required: true, message: "Please input price!" }]} name="name"
> label="Name"
<InputNumber rules={[{ required: true, message: "Please input name!" }]}
style={{ width: "100%" }} >
formatter={(value) => <Input />
`Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",") </Form.Item>
} <Form.Item
parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")} name="price"
/> label="Price"
</Form.Item> rules={[{ required: true, message: "Please input price!" }]}
<Form.Item >
name="markUpPrice" <InputNumber
label="Mark Up Price" style={{ width: "100%" }}
rules={[{ required: true, message: "Please input mark up price!" }]} formatter={(value) =>
> `Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
<InputNumber }
style={{ width: "100%" }} parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")}
formatter={(value) => />
`Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",") </Form.Item>
} <Form.Item
parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")} name="markUpPrice"
/> label="Mark Up Price"
</Form.Item> rules={[{ required: true, message: "Please input mark up price!" }]}
<Form.Item >
name="code" <InputNumber
label="Code" style={{ width: "100%" }}
rules={[{ required: true, message: "Please input code!" }]} formatter={(value) =>
> `Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
<Input /> }
</Form.Item> parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")}
<Form.Item />
name="status" </Form.Item>
label="Status" <Form.Item
rules={[{ required: true, message: "Please select Status!" }]} name="code"
> label="Code"
<Select placeholder="Select Sub Category" allowClear> rules={[{ required: true, message: "Please input code!" }]}
<Option value="ACTIVE">AKTIF</Option> >
<Option value="INACTIVE">INAKTIF</Option> <Input />
</Select> </Form.Item>
</Form.Item> <Form.Item
<Form.Item name="status"
name="subCategoriesId" label="Status"
label="Sub categories" rules={[{ required: true, message: "Please select Status!" }]}
rules={[ >
{ required: true, message: "Please select sub categories!" }, <Select placeholder="Select Sub Category" allowClear>
]} <Option value="ACTIVE">AKTIF</Option>
> <Option value="INACTIVE">INAKTIF</Option>
<Select placeholder="Select Sub Category" allowClear> </Select>
{store.category.dataSubCategories.map((item) => ( </Form.Item>
<Option value={item.id} key={item.id}> <Form.Item
{item.name} name="subCategoriesId"
</Option> label="Sub categories"
))} rules={[
</Select> { required: true, message: "Please select sub categories!" },
</Form.Item> ]}
</Form> >
</Modal> <Select placeholder="Select Sub Category" allowClear>
<Modal {store.category.dataSubCategories.map((item) => (
visible={store.product.visibleModalFilterProduct} <Option value={item.id} key={item.id}>
title={"Filter"} {item.name}
footer={footerLayoutFilter} </Option>
onCancel={async () => { ))}
// setFilterSupplier([]); </Select>
// setFilterSubCategories([]); </Form.Item>
store.product.filterSupplier = null; </Form>
store.product.filterSubCategory = null; </Modal>
store.product.visibleModalFilterProduct = false; <Modal
await store.product.getData(); visible={store.product.visibleModalFilterProduct}
}} title={"Filter"}
> footer={footerLayoutFilter}
<Row> onCancel={async () => {
{store.authentication.userData.role === "Admin" && ( // setFilterSupplier([]);
// setFilterSubCategories([]);
store.product.filterSupplier = null;
store.product.filterSubCategory = null;
store.product.visibleModalFilterProduct = false;
await store.product.getData();
}}
>
<Row>
{store.authentication.userData.role === "Admin" && (
<Col span={24}>
<Title level={5} type={"secondary"} strong>
Filter Supplier
</Title>
<Select
mode={"multiple"}
placeholder="Choose Supplier"
onChange={(val) => {
setFilterSupplier(val);
}}
style={{ marginBottom: "20px", width: "100%" }}
value={filterSupplier}
>
{store.supplier.data.map((item) => (
<Option value={item.id} key={item.id}>
{item.name}
</Option>
))}
</Select>
</Col>
)}
<Col span={24}> <Col span={24}>
<Title level={5} type={"secondary"} strong> <Title level={5} type={"secondary"} strong>
Filter Supplier Filter Sub-Categories
</Title> </Title>
<Select <Select
mode={"multiple"} mode={"multiple"}
placeholder="Choose Supplier" placeholder="Choose Sub-Category"
onChange={(val) => { onChange={(val) => {
setFilterSupplier(val); setFilterSubCategories(val);
}} }}
style={{ marginBottom: "20px", width: "100%" }} style={{ marginBottom: "20px", width: "100%" }}
value={filterSupplier} value={filterSubCategories}
> >
{store.supplier.data.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>
))} ))}
</Select> </Select>
</Col> </Col>
)} </Row>
<Col span={24}> </Modal>
<Title level={5} type={"secondary"} strong> </div>
Filter Sub-Categories
</Title>
<Select
mode={"multiple"}
placeholder="Choose Sub-Category"
onChange={(val) => {
setFilterSubCategories(val);
}}
style={{ marginBottom: "20px", width: "100%" }}
value={filterSubCategories}
>
{store.product.dataSubCategories.map((item) => (
<Option value={item.id} key={item.id}>
{item.name}
</Option>
))}
</Select>
</Col>
</Row>
</Modal>
</div>
); );
}); });

View File

@ -57,20 +57,30 @@ export const ProductDetail = observer(() => {
dataIndex: "mark_up_price", dataIndex: "mark_up_price",
key: "mark_up_price", key: "mark_up_price",
render: (text) => render: (text) =>
new Intl.NumberFormat("id-ID", { new Intl.NumberFormat("id-ID", {
style: "currency", style: "currency",
currency: "IDR", currency: "IDR",
}).format(text), }).format(text),
}, },
{ {
title: "Price", title: "Price",
dataIndex: "price", dataIndex: "price",
key: "price", key: "price",
render: (text) => render: (text) =>
new Intl.NumberFormat("id-ID", { new Intl.NumberFormat("id-ID", {
style: "currency", style: "currency",
currency: "IDR", currency: "IDR",
}).format(text), }).format(text),
},
{
title: "Biaya Admin",
dataIndex: "admin_price",
key: "admin_price",
render: (text) =>
new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(text),
}, },
{ {
title: "Tanggal Berlaku", title: "Tanggal Berlaku",
@ -78,7 +88,7 @@ export const ProductDetail = observer(() => {
key: "startDate", key: "startDate",
render: (text) => { render: (text) => {
return ( return (
<Text>{text ? format(parseISO(text), "dd MMMM yyyy") : "-"}</Text> <Text>{text ? format(parseISO(text), "dd MMMM yyyy") : "-"}</Text>
); );
}, },
}, },
@ -88,174 +98,174 @@ export const ProductDetail = observer(() => {
key: "endDate", key: "endDate",
render: (text) => { render: (text) => {
return ( return (
<Text> <Text>
{text ? format(parseISO(text), "dd MMMM yyyy") : "Sampai Sekarang"} {text ? format(parseISO(text), "dd MMMM yyyy") : "Sampai Sekarang"}
</Text> </Text>
); );
}, },
}, },
]; ];
const styleSaldoTitle = store.ui.mediaQuery.isDesktop const styleSaldoTitle = store.ui.mediaQuery.isDesktop
? { ? {
display: "flex", display: "flex",
justifyContent: "center", justifyContent: "center",
} }
: { fontSize: "0.75rem" }; : { fontSize: "0.75rem" };
const styleSaldoContent = store.ui.mediaQuery.isDesktop const styleSaldoContent = store.ui.mediaQuery.isDesktop
? { ? {
fontSize: "1.25rem", fontSize: "1.25rem",
display: "flex", display: "flex",
justifyContent: "center", justifyContent: "center",
} }
: null; : null;
return ( return (
<div className={["ppob-container"].join(" ")}> <div className={["ppob-container"].join(" ")}>
<BreadcumbComponent data={routeData} /> <BreadcumbComponent data={routeData} />
<Card> <Card>
<Title strong>Product Detail</Title> <Title strong>Product Detail</Title>
<Row style={{ marginBottom: 20 }}> <Row style={{ marginBottom: 20 }}>
<Col lg={12} xs={24}> <Col lg={12} xs={24}>
<Row> <Row>
<Col span={12}> <Col span={12}>
<Text strong>Kode</Text> <Text strong>Kode</Text>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Text>{store.product?.dataDetailProduct?.code}</Text> <Text>{store.product?.dataDetailProduct?.code}</Text>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Text strong>Nama Produk</Text> <Text strong>Nama Produk</Text>
</Col> </Col>
<Col span={10}> <Col span={10}>
<Text>{store.product?.dataDetailProduct?.name}</Text> <Text>{store.product?.dataDetailProduct?.name}</Text>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Text strong>Supplier</Text> <Text strong>Supplier</Text>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Text>{store.product?.dataDetailProduct?.supplier?.name}</Text> <Text>{store.product?.dataDetailProduct?.supplier?.name}</Text>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Text strong>Status</Text> <Text strong>Status</Text>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Text>{store.product?.dataDetailProduct?.status}</Text> <Text>{store.product?.dataDetailProduct?.status}</Text>
</Col> </Col>
</Row> </Row>
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col span={24}> <Col span={24}>
<div> <div>
<Title strong level={3}> <Title strong level={3}>
Product Price History Product Price History
</Title> </Title>
{store.ui.mediaQuery.isDesktop && ( {store.ui.mediaQuery.isDesktop && (
<Table <Table
columns={columns} columns={columns}
dataSource={store.product.dataPriceHistory} dataSource={store.product.dataPriceHistory}
bordered bordered
pagination={{ pagination={{
pageSize: store.product.pageSizePriceHistory, pageSize: store.product.pageSizePriceHistory,
total: store.product.totalDataPriceHistory, total: store.product.totalDataPriceHistory,
current: store.product.pagePriceHistory + 1, current: store.product.pagePriceHistory + 1,
showSizeChanger: true, showSizeChanger: true,
simple: false, simple: false,
}} }}
onChange={async (page) => { onChange={async (page) => {
let pageNumber = page.current; let pageNumber = page.current;
store.product.pageSizePriceHistory = page.pageSize; store.product.pageSizePriceHistory = page.pageSize;
store.product.pagePriceHistory = pageNumber - 1; store.product.pagePriceHistory = pageNumber - 1;
modalLoader.setLoading(true); modalLoader.setLoading(true);
await store.product.getPriceHistoryByProduct(id); await store.product.getPriceHistoryByProduct(id);
modalLoader.setLoading(false); modalLoader.setLoading(false);
}} }}
/> />
)} )}
{store.ui.mediaQuery.isMobile && ( {store.ui.mediaQuery.isMobile && (
<List <List
itemLayout="horizontal" itemLayout="horizontal"
position={"top"} position={"top"}
pagination={{ pagination={{
onChange: async (page, pageSize) => { onChange: async (page, pageSize) => {
store.product.pageSizePriceHistory = pageSize; store.product.pageSizePriceHistory = pageSize;
store.product.pagePriceHistory = page - 1; store.product.pagePriceHistory = page - 1;
modalLoader.setLoading(true); modalLoader.setLoading(true);
await store.product.getPriceHistoryByProduct(id); await store.product.getPriceHistoryByProduct(id);
modalLoader.setLoading(false); modalLoader.setLoading(false);
}, },
pageSize: store.product.pageSizePriceHistory, pageSize: store.product.pageSizePriceHistory,
total: store.product.totalDataPriceHistory, total: store.product.totalDataPriceHistory,
current: store.product.pagePriceHistory + 1, current: store.product.pagePriceHistory + 1,
style: { marginBottom: "1rem", marginRight: "1rem" }, style: { marginBottom: "1rem", marginRight: "1rem" },
}} }}
dataSource={store.product.dataPriceHistory} dataSource={store.product.dataPriceHistory}
style={{ padding: 0 }} style={{ padding: 0 }}
renderItem={(item) => { renderItem={(item) => {
return ( return (
<div> <div>
<List.Item <List.Item
key={item.id} key={item.id}
style={{ style={{
backgroundColor: "#ffffff", backgroundColor: "#ffffff",
paddingTop: 0, paddingTop: 0,
paddingBottom: 0, paddingBottom: 0,
display: "flex", display: "flex",
flexDirection: "row", flexDirection: "row",
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
}} }}
> >
<List.Item.Meta <List.Item.Meta
className={[""].join(" ")} className={[""].join(" ")}
//title={item.mark_up_price} //title={item.mark_up_price}
description={ description={
<div style={{}}> <div style={{}}>
<p> <p>
<small> <small>
Markup Price :{" "} Markup Price :{" "}
{new Intl.NumberFormat("id-ID", { {new Intl.NumberFormat("id-ID", {
style: "currency", style: "currency",
currency: "IDR", currency: "IDR",
}).format(item.mark_up_price)} }).format(item.mark_up_price)}
</small>{" "} </small>{" "}
<br /> <br />
<small> <small>
Price:{" "} Price:{" "}
{new Intl.NumberFormat("id-ID", { {new Intl.NumberFormat("id-ID", {
style: "currency", style: "currency",
currency: "IDR", currency: "IDR",
}).format(item.price)} }).format(item.price)}
</small>{" "} </small>{" "}
<br /> <br />
<small> <small>
{" "} {" "}
Tanggal Berlaku : Tanggal Berlaku :
{item.startDate {item.startDate
? format( ? format(
parseISO(item.startDate), parseISO(item.startDate),
"dd MMMM yyyy" "dd MMMM yyyy"
) )
: "-"} : "-"}
</small>{" "} </small>{" "}
<br /> <br />
<small> <small>
Tanggal Berakhir :{" "} Tanggal Berakhir :{" "}
{item.endDate {item.endDate
? format( ? format(
parseISO(item.endDate), parseISO(item.endDate),
"dd MMMM yyyy" "dd MMMM yyyy"
) )
: "Sampai Sekarang"} : "Sampai Sekarang"}
</small>{" "} </small>{" "}
<br /> <br />
</p> </p>
<p></p> <p></p>
</div> </div>
} }
/> />
{/* <div style={{ marginRight: 16 }}> {/* <div style={{ marginRight: 16 }}>
<p <p
style={{ style={{
fontSize: 9, fontSize: 9,
@ -276,18 +286,18 @@ export const ProductDetail = observer(() => {
</Tag> </Tag>
</p> </p>
</div> */} </div> */}
</List.Item> </List.Item>
<Divider plain style={{ margin: 0 }} /> <Divider plain style={{ margin: 0 }} />
</div> </div>
); );
}} }}
/> />
)} )}
</div> </div>
</Col> </Col>
</Row> </Row>
<div /> <div />
</Card> </Card>
</div> </div>
); );
}); });