{
const store = useStore();
@@ -18,8 +18,8 @@ export const Product = observer(() => {
modalLoader.setLoading(true);
await Promise.allSettled([
store.transaction.getDataSubCategories(),
- store.transaction.getDataCategories()
- ])
+ store.transaction.getDataCategories(),
+ ]);
modalLoader.setLoading(false);
} catch (e) {
modalLoader.setLoading(false);
@@ -44,7 +44,9 @@ export const Product = observer(() => {
const handleBuyProduct = async (data) => {
modalLoader.setLoading(true);
try {
- const response = await store.transaction.buyProduct({productCode: data});
+ const response = await store.transaction.buyProduct({
+ productCode: data,
+ });
if (response.status === 201) {
message.success("Success Buy Product");
} else {
@@ -64,16 +66,18 @@ export const Product = observer(() => {
return (
- Sub Category
+
+ Sub Category
+
-
+
Produk & Nominal
-
+
{store.transaction.data.length != 0 && (
-
- {store.transaction.data.map((item, index) => (
-
- {
- Modal.confirm({
- title: `Are you sure buy ${item.product_name}?`,
- icon: ,
- okText: "Confirm",
- cancelText: "Cancel",
- okType: "primary",
- onOk() {
- handleBuyProduct(item.product_code)
- },
- onCancel() {
- console.log("Cancel");
- },
- });
- }}
- style={{cursor: "pointer",marginLeft:10}}
- >
- {item.product_name}
-
-
+
+ {store.transaction.data.map((item, index) => (
+
+ {
+ Modal.confirm({
+ title: `Are you sure buy ${item.product_name}?`,
+ icon: ,
+ okText: "Confirm",
+ cancelText: "Cancel",
+ okType: "primary",
+ onOk() {
+ handleBuyProduct(item.product_code);
+ },
+ onCancel() {
+ console.log("Cancel");
+ },
+ });
+ }}
+ hoverable
+ style={{
+ cursor: "pointer",
+ marginLeft: 10,
+ borderColor: "salmon",
+ height: 100,
+ marginBottom: 10,
+ }}
+ >
+ {item.product_name}
+
+
{new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(item?.price)}
-
-
- ))}
-
+
+
+ ))}
+
)}
{/* {store.transaction.data.length !== 0 && (
diff --git a/src/routes/app.js b/src/routes/app.js
index 9bc009f..8df28d0 100644
--- a/src/routes/app.js
+++ b/src/routes/app.js
@@ -30,7 +30,7 @@ export const LINKS = {
PAYBACK_CREATED: "/app/payback-created",
SUBCATEGORY: "/app/subcategory",
USER_DETAIL: "/app/user-detail/:id",
- PRODUCT_DETAIL: "/app/product-detail",
+ PRODUCT_DETAIL: "/app/product-detail/:id",
};
export const AppRoute = () => {
diff --git a/src/store/product.js b/src/store/product.js
index 5881c38..24fd675 100644
--- a/src/store/product.js
+++ b/src/store/product.js
@@ -22,6 +22,11 @@ export class Product {
dataSubCategories = [];
total_dataSubCategories = 0;
filterCategory = null;
+ dataDetail=[]
+ dataDetailProduct=[]
+
+ pageGetDetail=0
+ supplier=null
constructor(ctx) {
this.ctx = ctx;
@@ -31,7 +36,7 @@ export class Product {
async getData() {
try {
const response = await http.get(`/product/all?supplier=${this.filterSupplier}&sub-category=${this.filterSubCategory}&page=${this.page}&pageSize=${this.pageSize}`);
- //console.log(response)
+ console.log(response)
this.data = response.body.data.map((item, idx) => {
item.key = idx;
return item
@@ -67,6 +72,26 @@ export class Product {
console.error(e);
}
}
+ async getDetail(id) {
+ try {
+ const response = await http.get(`/product/price-history/${id}?page=${this.pageGetDetail}&supplier=${this.supplier}`);
+ //console.log(response,' Detail')
+ this.dataDetail = response.body.data
+ this.total_data = response?.body?.count ?? 0
+ } catch (e) {
+ console.error(e);
+ }
+ }
+ async getDetailProduct(id) {
+ try {
+ const response = await http.get(`/product/${id}`);
+ //console.log(response,' Detail Product')
+ this.dataDetailProduct = response.body.data
+ this.total_data = response?.body?.count ?? 0
+ } catch (e) {
+ console.error(e);
+ }
+ }
async create(data) {
try {