fix: add API payback confirmation
This commit is contained in:
parent
1e92eee5b5
commit
7b07d1a1d8
|
@ -1,12 +1,13 @@
|
||||||
import React, {useContext, useEffect} from "react";
|
import React, {useContext, useEffect} from "react";
|
||||||
import {Button, Card, Col, Divider, Image, Input, List, message, Row, Space, Table,} from "antd";
|
import {Button, Card, Col, Divider, Image, Input, List, message, Modal, Row, Space, Table,} from "antd";
|
||||||
import {useStore} from "../../utils/useStore";
|
import {useStore} from "../../utils/useStore";
|
||||||
import {observer} from "mobx-react-lite";
|
import {observer} from "mobx-react-lite";
|
||||||
import {CheckCircleOutlined, CloseOutlined, FilterOutlined,} from "@ant-design/icons";
|
import {CheckCircleOutlined, CheckOutlined, CloseOutlined, FilterOutlined, StopOutlined,} from "@ant-design/icons";
|
||||||
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
||||||
import {LINKS} from "../../routes/app";
|
import {LINKS} from "../../routes/app";
|
||||||
import {ModalLoaderContext} from "../../utils/modal";
|
import {ModalLoaderContext} from "../../utils/modal";
|
||||||
import {appConfig} from "../../config/app";
|
import {appConfig} from "../../config/app";
|
||||||
|
import {capitalize} from "lodash";
|
||||||
|
|
||||||
const {Search} = Input;
|
const {Search} = Input;
|
||||||
|
|
||||||
|
@ -66,7 +67,19 @@ export const Payback = observer(() => {
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
<Button
|
<Button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await handleAction(record, "accept");
|
Modal.confirm({
|
||||||
|
title: `Are you sure Accept this submission?`,
|
||||||
|
icon: <CheckOutlined/>,
|
||||||
|
okText: "Accept",
|
||||||
|
cancelText: "Cancel",
|
||||||
|
okType: "primary",
|
||||||
|
onOk() {
|
||||||
|
handleAction(record.id, "accept");
|
||||||
|
},
|
||||||
|
onCancel() {
|
||||||
|
console.log("Cancel");
|
||||||
|
},
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
icon={<CheckCircleOutlined/>}
|
icon={<CheckCircleOutlined/>}
|
||||||
style={{
|
style={{
|
||||||
|
@ -79,7 +92,20 @@ export const Payback = observer(() => {
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await handleAction(record, "reject");
|
Modal.confirm({
|
||||||
|
title: `Are you sure Reject this submission?`,
|
||||||
|
icon: <StopOutlined/>,
|
||||||
|
okText: "Reject",
|
||||||
|
cancelText: "Cancel",
|
||||||
|
okType: "primary",
|
||||||
|
onOk() {
|
||||||
|
handleAction(record.id, "reject");
|
||||||
|
},
|
||||||
|
onCancel() {
|
||||||
|
console.log("Cancel");
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
}}
|
}}
|
||||||
icon={<CloseOutlined/>}
|
icon={<CloseOutlined/>}
|
||||||
style={{
|
style={{
|
||||||
|
@ -104,26 +130,25 @@ export const Payback = observer(() => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
route: LINKS.PAYBACK,
|
route: LINKS.PAYBACK,
|
||||||
name: <span style={{fontWeight: "bold"}}>Payback</span>,
|
name: <span style={{fontWeight: "bold"}}>Payback Confirmation</span>,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const onSubmit = async (data) => {
|
const handleAction = async (id, type) => {
|
||||||
modalLoader.setLoading(true);
|
modalLoader.setLoading(true);
|
||||||
try {
|
try {
|
||||||
// await store.payback.create(data);
|
const response = await store.payback.confirmPayback(id, {status: capitalize(type)});
|
||||||
// message.success("Success Add New Member");
|
if (response.body.status !== 201) {
|
||||||
// await store.payback.getData();
|
message.error(`Failed ${capitalize(type)} Payback`);
|
||||||
|
}
|
||||||
|
message.success(`Success ${capitalize(type)} Payback`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e, "apa errornya");
|
console.error(e, "apa errornya");
|
||||||
message.error("Failed Add Member");
|
message.error("Failed Handler Action Payback");
|
||||||
}
|
}
|
||||||
modalLoader.setLoading(false);
|
modalLoader.setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAction = async (record, type) => {
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={["ppob-container"].join(" ")}>
|
<div className={["ppob-container"].join(" ")}>
|
||||||
<BreadcumbComponent data={routeData}/>
|
<BreadcumbComponent data={routeData}/>
|
||||||
|
@ -145,16 +170,6 @@ export const Payback = observer(() => {
|
||||||
marginBottom: store.ui.mediaQuery.isMobile ? 10 : 0,
|
marginBottom: store.ui.mediaQuery.isMobile ? 10 : 0,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/* {store.authentication.userData.role !== "Admin" && (
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
setInitialData({});
|
|
||||||
setVisibleModal(true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PlusSquareOutlined /> New
|
|
||||||
</Button>
|
|
||||||
)} */}
|
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{store.ui.mediaQuery.isDesktop && (
|
{store.ui.mediaQuery.isDesktop && (
|
||||||
|
|
|
@ -70,7 +70,7 @@ export const PaybackCreated = observer(() => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
route: LINKS.PAYBACK_CREATED,
|
route: LINKS.PAYBACK_CREATED,
|
||||||
name: <span style={{fontWeight: "bold"}}>Payback User</span>,
|
name: <span style={{fontWeight: "bold"}}>Payback Created</span>,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -80,4 +80,17 @@ export class Payback {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async confirmPayback(id, data) {
|
||||||
|
try {
|
||||||
|
const response = await http.put(`/transaction/deposit-return/confirmation/${id}`).send(data);
|
||||||
|
await Promise.all([
|
||||||
|
this.getDataConfirmation(),
|
||||||
|
this.getDataCreated()
|
||||||
|
])
|
||||||
|
return response;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user