fix: revert buy product using modal
This commit is contained in:
parent
f427dc4990
commit
9490fd23b2
|
@ -1,11 +1,11 @@
|
||||||
import React, { useState } from "react";
|
import React, {useState} from "react";
|
||||||
import { Button, Form, Input, message, Modal, Space, Table, Tag } from "antd";
|
import {Button, Form, Input, message, Modal, Space, Table, Tag} from "antd";
|
||||||
import { observer } from "mobx-react-lite";
|
import {observer} from "mobx-react-lite";
|
||||||
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
import {ExclamationCircleOutlined} from "@ant-design/icons";
|
||||||
import { useHistory } from "react-router-dom";
|
import {useHistory} from "react-router-dom";
|
||||||
import { useStore } from "../utils/useStore";
|
import {useStore} from "../utils/useStore";
|
||||||
import { LINKS } from "../routes/app";
|
import {LINKS} from "../routes/app";
|
||||||
import { TopupsaldoModal } from "./TopupsaldoModal";
|
import {TopupsaldoModal} from "./TopupsaldoModal";
|
||||||
|
|
||||||
export const SupplierComponent = observer((props) => {
|
export const SupplierComponent = observer((props) => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
@ -66,12 +66,10 @@ export const SupplierComponent = observer((props) => {
|
||||||
key: ["coa", "amount"],
|
key: ["coa", "amount"],
|
||||||
width: "20%",
|
width: "20%",
|
||||||
render: (text, record) =>
|
render: (text, record) =>
|
||||||
text
|
new Intl.NumberFormat("id-ID", {
|
||||||
? new Intl.NumberFormat("id-ID", {
|
|
||||||
style: "currency",
|
style: "currency",
|
||||||
currency: "IDR",
|
currency: "IDR",
|
||||||
}).format(text)
|
}).format(text),
|
||||||
: "-",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Status",
|
title: "Status",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import { useStore } from "../../utils/useStore";
|
import {useStore} from "../../utils/useStore";
|
||||||
import { Button, Card, Col, Input, Row, Select, message } from "antd";
|
import {Button, Card, Col, Input, Row, Select} from "antd";
|
||||||
import { observer } from "mobx-react-lite";
|
import {observer} from "mobx-react-lite";
|
||||||
import { BuyProductModal } from "../../component/BuyProductModal";
|
import {BuyProductModal} from "../../component/BuyProductModal";
|
||||||
|
|
||||||
const { Search } = Input;
|
const {Search} = Input;
|
||||||
const { Option } = Select;
|
const {Option} = Select;
|
||||||
|
|
||||||
export const Product = observer(() => {
|
export const Product = observer(() => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
@ -13,8 +13,6 @@ export const Product = observer(() => {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [productData, setProductData] = useState([]);
|
const [productData, setProductData] = useState([]);
|
||||||
const [data, setData] = useState({});
|
const [data, setData] = useState({});
|
||||||
const [kode, setKode] = useState({});
|
|
||||||
const [cardIndex, setCardIndex] = useState({});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
|
@ -51,20 +49,15 @@ export const Product = observer(() => {
|
||||||
await store.transaction.getData();
|
await store.transaction.getData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBuyProduct = async (kode) => {
|
const handleBuyProduct = (data) => {
|
||||||
console.log(kode);
|
setData(data);
|
||||||
try {
|
store.transaction.visibleModalTransaction = true;
|
||||||
await store.product.buyProduct({ productCode: kode });
|
|
||||||
message.success("Success Buy Product");
|
|
||||||
} catch (e) {
|
|
||||||
message.error("Failed Buy Product");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Row>
|
<Row>
|
||||||
<span style={{ fontWeight: "bold", marginBottom: "10px" }}>
|
<span style={{fontWeight: "bold", marginBottom: "10px"}}>
|
||||||
Sub Category
|
Sub Category
|
||||||
</span>
|
</span>
|
||||||
</Row>
|
</Row>
|
||||||
|
@ -107,20 +100,12 @@ export const Product = observer(() => {
|
||||||
{productData.map((item, index) => (
|
{productData.map((item, index) => (
|
||||||
<Col key={index} xs={24} md={16} lg={8}>
|
<Col key={index} xs={24} md={16} lg={8}>
|
||||||
<Card
|
<Card
|
||||||
onClick={() => {
|
onClick={() => handleBuyProduct(item)}
|
||||||
setKode(item.code);
|
style={{cursor: "pointer"}}
|
||||||
setCardIndex(index);
|
|
||||||
}}
|
|
||||||
hoverable
|
|
||||||
style={{
|
|
||||||
cursor: "pointer",
|
|
||||||
borderColor: cardIndex === index ? "#2D9CDB" : "",
|
|
||||||
marginLeft: "10px",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<span style={{ color: "black" }}>{item.name}</span>
|
<span style={{color: "black"}}>{item.name}</span>
|
||||||
<br />
|
<br/>
|
||||||
<span style={{ color: "grey", fontSize: 10 }}>
|
<span style={{color: "grey", fontSize: 10}}>
|
||||||
{new Intl.NumberFormat("id-ID", {
|
{new Intl.NumberFormat("id-ID", {
|
||||||
style: "currency",
|
style: "currency",
|
||||||
currency: "IDR",
|
currency: "IDR",
|
||||||
|
@ -133,10 +118,7 @@ export const Product = observer(() => {
|
||||||
)}
|
)}
|
||||||
{productData.length !== 0 && (
|
{productData.length !== 0 && (
|
||||||
<Col style={{ textAlign: "right" }}>
|
<Col style={{ textAlign: "right" }}>
|
||||||
<Button
|
<Button style={{backgroundColor: "#2D9CDB", color: "white"}}>
|
||||||
style={{ backgroundColor: "#2D9CDB", color: "white" }}
|
|
||||||
onClick={() => handleBuyProduct(kode)}
|
|
||||||
>
|
|
||||||
Beli Sekarang
|
Beli Sekarang
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user