Handling Error
This commit is contained in:
parent
7928df9fc6
commit
a115d8488b
|
@ -1,5 +1,5 @@
|
||||||
import React, { useContext } from "react";
|
import React, { useContext } from "react";
|
||||||
import {Form, Input, message, Modal} from "antd";
|
import { Form, Input, message, Modal, InputNumber } from "antd";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { useStore } from "../utils/useStore";
|
import { useStore } from "../utils/useStore";
|
||||||
import { ModalLoaderContext } from "../utils/modal";
|
import { ModalLoaderContext } from "../utils/modal";
|
||||||
|
@ -69,7 +69,13 @@ export const TopupsaldoModal = observer((props) => {
|
||||||
label="Amount"
|
label="Amount"
|
||||||
rules={[{ required: true, message: "Please input amount!" }]}
|
rules={[{ required: true, message: "Please input amount!" }]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<InputNumber
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
formatter={(value) =>
|
||||||
|
`Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
|
||||||
|
}
|
||||||
|
parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
|
@ -7,12 +7,14 @@ import {observer} from "mobx-react-lite";
|
||||||
import {FilterOutlined} from "@ant-design/icons";
|
import {FilterOutlined} from "@ant-design/icons";
|
||||||
import {format, parseISO} from "date-fns";
|
import {format, parseISO} from "date-fns";
|
||||||
import {ModalLoaderContext} from "../../utils/modal";
|
import {ModalLoaderContext} from "../../utils/modal";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
const {Title, Text} = Typography;
|
const {Title, Text} = Typography;
|
||||||
|
|
||||||
export const DetailUser = observer(() => {
|
export const DetailUser = observer(() => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const modalLoader = useContext(ModalLoaderContext);
|
const modalLoader = useContext(ModalLoaderContext);
|
||||||
|
const { id } = useParams();
|
||||||
|
|
||||||
const routeData = [
|
const routeData = [
|
||||||
{
|
{
|
||||||
|
@ -24,12 +26,13 @@ export const DetailUser = observer(() => {
|
||||||
name: <span style={{fontWeight: 'bold'}}>Detail User</span>,
|
name: <span style={{fontWeight: 'bold'}}>Detail User</span>,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
console.log(id)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
modalLoader.setLoading(true);
|
modalLoader.setLoading(true);
|
||||||
await Promise.allSettled([
|
await Promise.allSettled([
|
||||||
store.authentication.getProfile(),
|
store.authentication.getProfile(),
|
||||||
|
store.transaction.getDataHistoryTopUp(id),
|
||||||
store.transaction.getDataHistoryTransaction(),
|
store.transaction.getDataHistoryTransaction(),
|
||||||
]);
|
]);
|
||||||
modalLoader.setLoading(false);
|
modalLoader.setLoading(false);
|
||||||
|
@ -83,7 +86,7 @@ export const DetailUser = observer(() => {
|
||||||
<Text strong>Name</Text>
|
<Text strong>Name</Text>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Text>{store.authentication.profileData?.userDetail?.name}</Text>
|
<Text>{store.transaction.data.name}</Text>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Text strong>Role</Text>
|
<Text strong>Role</Text>
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
Space,
|
Space,
|
||||||
Table,
|
Table,
|
||||||
Tag,
|
Tag,
|
||||||
InputNumber
|
InputNumber,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import { useStore } from "../../utils/useStore";
|
import { useStore } from "../../utils/useStore";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
|
@ -101,10 +101,16 @@ export const Membership = observer(() => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let response = null;
|
||||||
|
|
||||||
(await store.authentication.userData.role) === "Admin"
|
(await store.authentication.userData.role) === "Admin"
|
||||||
? store.transaction.distributeAdmin(data)
|
? (response = await store.transaction.distributeAdmin(data))
|
||||||
: store.transaction.distribute(data);
|
: (response = await store.transaction.distribute(data));
|
||||||
message.success("Success Top Up");
|
|
||||||
|
response?.body?.statusCode === 200
|
||||||
|
? message.success("Success Top Up")
|
||||||
|
: message.error("Failed Top Up");
|
||||||
|
|
||||||
modalLoader.setLoading(false);
|
modalLoader.setLoading(false);
|
||||||
//await store.supplier.getData()
|
//await store.supplier.getData()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -217,8 +223,9 @@ export const Membership = observer(() => {
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
await store.transaction.getDataHistoryTopUp(record.id)
|
||||||
history.push(LINKS.DETAILUSER.replace(":id", record.id));
|
history.push(LINKS.DETAILUSER.replace(":id", record.id));
|
||||||
//console.log(record.id)
|
console.log(record.id);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Detail
|
Detail
|
||||||
|
@ -465,7 +472,7 @@ export const Membership = observer(() => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Form form={form} layout="vertical">
|
<Form form={form} layout="vertical">
|
||||||
<Form.Item
|
{/* <Form.Item
|
||||||
name="supplier"
|
name="supplier"
|
||||||
label="Supplier"
|
label="Supplier"
|
||||||
rules={[{ required: true, message: "Please input supplier!" }]}
|
rules={[{ required: true, message: "Please input supplier!" }]}
|
||||||
|
@ -477,7 +484,7 @@ export const Membership = observer(() => {
|
||||||
</Option>
|
</Option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item> */}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="amount"
|
name="amount"
|
||||||
label="Amount"
|
label="Amount"
|
||||||
|
|
|
@ -22,10 +22,14 @@ export class Transaction {
|
||||||
filterSubCategory = null;
|
filterSubCategory = null;
|
||||||
|
|
||||||
pageHistoryTransaction = 0;
|
pageHistoryTransaction = 0;
|
||||||
|
pageHistoryTopUp = 0;
|
||||||
// pageSizeHistoryTransaction = 10
|
// pageSizeHistoryTransaction = 10
|
||||||
dataHistoryTransaction = [];
|
dataHistoryTransaction = [];
|
||||||
total_dataHistoryTransaction = 0;
|
total_dataHistoryTransaction = 0;
|
||||||
|
|
||||||
|
dataHistoryTopUp=[];
|
||||||
|
total_dataHistoryTopUp = 0;
|
||||||
|
|
||||||
constructor(ctx) {
|
constructor(ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
|
@ -76,6 +80,18 @@ export class Transaction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getDataHistoryTopUp(id) {
|
||||||
|
try {
|
||||||
|
console.log("Top up")
|
||||||
|
const response = await http.get(`/transaction/history-deposit?page=${this.pageHistoryTopUp}&user-destination=${id}`);
|
||||||
|
|
||||||
|
this.dataHistoryTopUp = response.body.data ?? []
|
||||||
|
this.total_dataHistoryTopUp = response?.body?.count ?? 0
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async create(data) {
|
async create(data) {
|
||||||
try {
|
try {
|
||||||
const response = await http.post('/product').send(data);
|
const response = await http.post('/product').send(data);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user