diff --git a/src/component/ProductComponent.js b/src/component/ProductComponent.js index 37c4d00..c4d28b5 100644 --- a/src/component/ProductComponent.js +++ b/src/component/ProductComponent.js @@ -64,30 +64,40 @@ export const ProductComponent = observer((props) => { dataIndex: "current_price_price", key: "current_price_price", render: (text) => - new Intl.NumberFormat("id-ID", { - style: "currency", - currency: "IDR", - }).format(text), + new Intl.NumberFormat("id-ID", { + style: "currency", + currency: "IDR", + }).format(text), }, { title: "Harga Jual", dataIndex: "mark_up_price", key: "mark_up_price", render: (text) => - new Intl.NumberFormat("id-ID", { - style: "currency", - currency: "IDR", - }).format(text), + new Intl.NumberFormat("id-ID", { + style: "currency", + currency: "IDR", + }).format(text), }, { title: "Harga", dataIndex: "price", key: "price", render: (text) => - new Intl.NumberFormat("id-ID", { - style: "currency", - currency: "IDR", - }).format(text), + new Intl.NumberFormat("id-ID", { + style: "currency", + currency: "IDR", + }).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", @@ -104,27 +114,27 @@ export const ProductComponent = observer((props) => { dataIndex: "tersedia", key: "tersedia", render: (text, record) => ( - - {record?.product_status === "ACTIVE" ? " Tersedia" : "Tidak"} - + + {record?.product_status === "ACTIVE" ? " Tersedia" : "Tidak"} + ), }, { title: "Tindakan", key: "action", render: (text, record) => ( - { - history.push( - LINKS.PRODUCT_DETAIL.replace(":id", record.product_id) - ); - }} - > - Detail - + { + history.push( + LINKS.PRODUCT_DETAIL.replace(":id", record.product_id) + ); + }} + > + Detail + ), }, ]; @@ -180,10 +190,10 @@ export const ProductComponent = observer((props) => { try { const response = await store.product.update(idData, data); response?.body?.statusCode === 201 || response?.body?.statusCode === 200 - ? message.success( - response?.body?.message || "Berhasil Ubah Data Produk" - ) - : message.error(response?.body?.message || "Gagal Ubah Data Produk"); + ? message.success( + response?.body?.message || "Berhasil Ubah Data Produk" + ) + : message.error(response?.body?.message || "Gagal Ubah Data Produk"); } catch (e) { message.error(e.response?.body?.message || "Gagal Ubah Data Produk"); } @@ -196,8 +206,8 @@ export const ProductComponent = observer((props) => { try { const response = await store.product.create(data); response?.body?.statusCode === 201 || response?.body?.statusCode === 200 - ? message.success(response?.body?.message || "Berhasil Tambah Produk") - : message.error(response?.body?.message || "Gagal Tambah Produk"); + ? message.success(response?.body?.message || "Berhasil Tambah Produk") + : message.error(response?.body?.message || "Gagal Tambah Produk"); } catch (e) { console.log(e, "apa errornya"); message.error(e.response?.body?.message || "Gagal Tambah Produk"); @@ -217,8 +227,8 @@ export const ProductComponent = observer((props) => { setFilterSupplier([]); setFilterSubCategories([]); store.authentication.userData.role === "Admin Partner" - ? await store.product.getProductPartner() - : await store.product.getData(); + ? await store.product.getProductPartner() + : await store.product.getData(); //await store.product.getData(); modalLoader.setLoading(false); }; @@ -235,8 +245,8 @@ export const ProductComponent = observer((props) => { store.product.filterSubCategory = filterSubCategories; modalLoader.setLoading(true); store.authentication.userData.role === "Admin Partner" - ? await store.product.getProductPartner(filterSubCategories) - : await store.product.getData(); + ? await store.product.getProductPartner(filterSubCategories) + : await store.product.getData(); //await store.product.getData(); modalLoader.setLoading(false); //store.product.page=1 @@ -244,12 +254,12 @@ export const ProductComponent = observer((props) => { const footerLayoutFilter = [ Hapus Filter , @@ -257,12 +267,12 @@ export const ProductComponent = observer((props) => { Batal , Terapkan , @@ -274,292 +284,293 @@ export const ProductComponent = observer((props) => { }, }); return ( -
- {item.product_name} - {/* Harga Beli : {item.current_price_price} - */} - Harga Jual : {item.mark_up_price} - - { - history.push( - LINKS.PRODUCT_DETAIL.replace( - ":id", - item.product_id - ) - ); + + {store.ui.mediaQuery.isDesktop && ( + { + 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.page = pageNumber - 1 : store.product.pageProductPartner = pageNumber - 1 + store.product.filterSubCategory = filterSubCategories + modalLoader.setLoading(true); + store.authentication.userData.role === "Admin Partner" + ? await store.product.getProductPartner( + // store.authentication.profileData.id + ) + : await store.product.getData(); + modalLoader.setLoading(false); + }} + /> + )} + {store.ui.mediaQuery.isMobile && ( + { + store.authentication.userData.role === "Admin" ? store.product.pageSize = pageSize : store.product.pageSizeProductPartner = pageSize; + store.authentication.userData.role === "Admin" ? store.product.page = page - 1 : store.product.pageProductPartner = page - 1 + modalLoader.setLoading(true); + store.authentication.userData.role === "Admin Partner" + ? await store.product.getProductPartner( + // store.authentication.profileData.id + ) + : await store.product.getData(); + //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" + ? store.product.total_data_partner + : store.product.total_data, + 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" + ? store.product.dataProductPartner + : store.product.data + } + style={{ padding: 0 }} + renderItem={(item) => { + return ( + + - Detail - - - + > + + + {item.product_name} + {/* Harga Beli : {item.current_price_price} + */} + Harga Jual : {item.mark_up_price} + + { + history.push( + LINKS.PRODUCT_DETAIL.replace( + ":id", + item.product_id + ) + ); + }} + > + Detail + + + + + } + /> + + + + {item?.product_status === "ACTIVE" + ? " Tersedia" + : "Tidak"} + + + + + - } - /> - - - - {item?.product_status === "ACTIVE" - ? " Tersedia" - : "Tidak"} - - - - - - - ); - }} - /> - )} - { - form.resetFields(); - handleCancel(); - }} - onOk={() => { - form - .validateFields() - .then((values) => { - console.log(values, "isi form"); - handleSubmit(values); + ); + }} + /> + )} + { form.resetFields(); - }) - .catch((info) => { - console.error("Validate Failed:", info); - }); - }} - > - - - - - - - `Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",") - } - parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")} - /> - - - - `Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",") - } - parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")} - /> - - - - - - - AKTIF - INAKTIF - - - - - {store.category.dataSubCategories.map((item) => ( - - {item.name} - - ))} - - - - - { - // setFilterSupplier([]); - // setFilterSubCategories([]); - store.product.filterSupplier = null; - store.product.filterSubCategory = null; - store.product.visibleModalFilterProduct = false; - await store.product.getData(); - }} - > - - {store.authentication.userData.role === "Admin" && ( + handleCancel(); + }} + onOk={() => { + form + .validateFields() + .then((values) => { + console.log(values, "isi form"); + handleSubmit(values); + form.resetFields(); + }) + .catch((info) => { + console.error("Validate Failed:", info); + }); + }} + > + + + + + + + `Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + } + parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")} + /> + + + + `Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + } + parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")} + /> + + + + + + + AKTIF + INAKTIF + + + + + {store.category.dataSubCategories.map((item) => ( + + {item.name} + + ))} + + + + + { + // setFilterSupplier([]); + // setFilterSubCategories([]); + store.product.filterSupplier = null; + store.product.filterSubCategory = null; + store.product.visibleModalFilterProduct = false; + await store.product.getData(); + }} + > + + {store.authentication.userData.role === "Admin" && ( + + + Filter Supplier + + { + setFilterSupplier(val); + }} + style={{ marginBottom: "20px", width: "100%" }} + value={filterSupplier} + > + {store.supplier.data.map((item) => ( + + {item.name} + + ))} + + + )} - Filter Supplier + Filter Sub-Categories { - setFilterSupplier(val); - }} - style={{ marginBottom: "20px", width: "100%" }} - value={filterSupplier} + mode={"multiple"} + placeholder="Choose Sub-Category" + onChange={(val) => { + setFilterSubCategories(val); + }} + style={{ marginBottom: "20px", width: "100%" }} + value={filterSubCategories} > - {store.supplier.data.map((item) => ( - - {item.name} - + {store.product.dataSubCategories.map((item) => ( + + {item.name} + ))} - )} - - - Filter Sub-Categories - - { - setFilterSubCategories(val); - }} - style={{ marginBottom: "20px", width: "100%" }} - value={filterSubCategories} - > - {store.product.dataSubCategories.map((item) => ( - - {item.name} - - ))} - - - - - + + + ); }); diff --git a/src/pages/Product/ProductDetail.js b/src/pages/Product/ProductDetail.js index 6364f74..caa71a8 100644 --- a/src/pages/Product/ProductDetail.js +++ b/src/pages/Product/ProductDetail.js @@ -57,20 +57,30 @@ export const ProductDetail = observer(() => { dataIndex: "mark_up_price", key: "mark_up_price", render: (text) => - new Intl.NumberFormat("id-ID", { - style: "currency", - currency: "IDR", - }).format(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), + new Intl.NumberFormat("id-ID", { + style: "currency", + currency: "IDR", + }).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", @@ -78,7 +88,7 @@ export const ProductDetail = observer(() => { key: "startDate", render: (text) => { return ( - {text ? format(parseISO(text), "dd MMMM yyyy") : "-"} + {text ? format(parseISO(text), "dd MMMM yyyy") : "-"} ); }, }, @@ -88,174 +98,174 @@ export const ProductDetail = observer(() => { key: "endDate", render: (text) => { return ( - - {text ? format(parseISO(text), "dd MMMM yyyy") : "Sampai Sekarang"} - + + {text ? format(parseISO(text), "dd MMMM yyyy") : "Sampai Sekarang"} + ); }, }, ]; const styleSaldoTitle = store.ui.mediaQuery.isDesktop - ? { + ? { display: "flex", justifyContent: "center", } - : { fontSize: "0.75rem" }; + : { fontSize: "0.75rem" }; const styleSaldoContent = store.ui.mediaQuery.isDesktop - ? { + ? { fontSize: "1.25rem", display: "flex", justifyContent: "center", } - : null; + : null; return ( - - - - Product Detail - - - - - Kode - - - {store.product?.dataDetailProduct?.code} - - - Nama Produk - - - {store.product?.dataDetailProduct?.name} - - - Supplier - - - {store.product?.dataDetailProduct?.supplier?.name} - - - Status - - - {store.product?.dataDetailProduct?.status} - - - - - - - - - Product Price History - - {store.ui.mediaQuery.isDesktop && ( - { - 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); - }} - /> - )} - {store.ui.mediaQuery.isMobile && ( - { - store.product.pageSizePriceHistory = pageSize; - store.product.pagePriceHistory = page - 1; - modalLoader.setLoading(true); - await store.product.getPriceHistoryByProduct(id); - modalLoader.setLoading(false); - }, - pageSize: store.product.pageSizePriceHistory, - total: store.product.totalDataPriceHistory, - current: store.product.pagePriceHistory + 1, - style: { marginBottom: "1rem", marginRight: "1rem" }, - }} - dataSource={store.product.dataPriceHistory} - style={{ padding: 0 }} - renderItem={(item) => { - return ( - - - - - - Markup Price :{" "} - {new Intl.NumberFormat("id-ID", { - style: "currency", - currency: "IDR", - }).format(item.mark_up_price)} - {" "} - - - Price:{" "} - {new Intl.NumberFormat("id-ID", { - style: "currency", - currency: "IDR", - }).format(item.price)} - {" "} - - - {" "} - Tanggal Berlaku : - {item.startDate - ? format( - parseISO(item.startDate), - "dd MMMM yyyy" - ) - : "-"} - {" "} - - - Tanggal Berakhir :{" "} - {item.endDate - ? format( - parseISO(item.endDate), - "dd MMMM yyyy" - ) - : "Sampai Sekarang"} - {" "} - - - - - } - /> - {/* + + + + Product Detail + + + + + Kode + + + {store.product?.dataDetailProduct?.code} + + + Nama Produk + + + {store.product?.dataDetailProduct?.name} + + + Supplier + + + {store.product?.dataDetailProduct?.supplier?.name} + + + Status + + + {store.product?.dataDetailProduct?.status} + + + + + + + + + Product Price History + + {store.ui.mediaQuery.isDesktop && ( + { + 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); + }} + /> + )} + {store.ui.mediaQuery.isMobile && ( + { + store.product.pageSizePriceHistory = pageSize; + store.product.pagePriceHistory = page - 1; + modalLoader.setLoading(true); + await store.product.getPriceHistoryByProduct(id); + modalLoader.setLoading(false); + }, + pageSize: store.product.pageSizePriceHistory, + total: store.product.totalDataPriceHistory, + current: store.product.pagePriceHistory + 1, + style: { marginBottom: "1rem", marginRight: "1rem" }, + }} + dataSource={store.product.dataPriceHistory} + style={{ padding: 0 }} + renderItem={(item) => { + return ( + + + + + + Markup Price :{" "} + {new Intl.NumberFormat("id-ID", { + style: "currency", + currency: "IDR", + }).format(item.mark_up_price)} + {" "} + + + Price:{" "} + {new Intl.NumberFormat("id-ID", { + style: "currency", + currency: "IDR", + }).format(item.price)} + {" "} + + + {" "} + Tanggal Berlaku : + {item.startDate + ? format( + parseISO(item.startDate), + "dd MMMM yyyy" + ) + : "-"} + {" "} + + + Tanggal Berakhir :{" "} + {item.endDate + ? format( + parseISO(item.endDate), + "dd MMMM yyyy" + ) + : "Sampai Sekarang"} + {" "} + + + + + } + /> + {/* { */} - - - - ); - }} - /> - )} - - - - - - + + + + ); + }} + /> + )} + + + + + + ); });
+ {item.product_name} + {/* Harga Beli : {item.current_price_price} + */} + Harga Jual : {item.mark_up_price} + + { + history.push( + LINKS.PRODUCT_DETAIL.replace( + ":id", + item.product_id + ) + ); + }} + > + Detail + +
+ + {item?.product_status === "ACTIVE" + ? " Tersedia" + : "Tidak"} + +
- - {item?.product_status === "ACTIVE" - ? " Tersedia" - : "Tidak"} - -
- - Markup Price :{" "} - {new Intl.NumberFormat("id-ID", { - style: "currency", - currency: "IDR", - }).format(item.mark_up_price)} - {" "} - - - Price:{" "} - {new Intl.NumberFormat("id-ID", { - style: "currency", - currency: "IDR", - }).format(item.price)} - {" "} - - - {" "} - Tanggal Berlaku : - {item.startDate - ? format( - parseISO(item.startDate), - "dd MMMM yyyy" - ) - : "-"} - {" "} - - - Tanggal Berakhir :{" "} - {item.endDate - ? format( - parseISO(item.endDate), - "dd MMMM yyyy" - ) - : "Sampai Sekarang"} - {" "} - -
+ + Markup Price :{" "} + {new Intl.NumberFormat("id-ID", { + style: "currency", + currency: "IDR", + }).format(item.mark_up_price)} + {" "} + + + Price:{" "} + {new Intl.NumberFormat("id-ID", { + style: "currency", + currency: "IDR", + }).format(item.price)} + {" "} + + + {" "} + Tanggal Berlaku : + {item.startDate + ? format( + parseISO(item.startDate), + "dd MMMM yyyy" + ) + : "-"} + {" "} + + + Tanggal Berakhir :{" "} + {item.endDate + ? format( + parseISO(item.endDate), + "dd MMMM yyyy" + ) + : "Sampai Sekarang"} + {" "} + +
{