import React, {useContext, useEffect} from "react";
import {Button, Card, Col, Divider, Image, Input, List, message, Modal, Row, Space, Table,} from "antd";
import {useStore} from "../../utils/useStore";
import {observer} from "mobx-react-lite";
import {CheckCircleOutlined, CheckOutlined, CloseOutlined, FilterOutlined, StopOutlined,} from "@ant-design/icons";
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
import {LINKS} from "../../routes/app";
import {ModalLoaderContext} from "../../utils/modal";
import {appConfig} from "../../config/app";
import {capitalize} from "lodash";
const {Search} = Input;
export const Payback = observer(() => {
const store = useStore();
const modalLoader = useContext(ModalLoaderContext);
useEffect(() => {
const init = async () => {
try {
modalLoader.setLoading(true);
await store.payback.getDataConfirmation();
modalLoader.setLoading(false);
} catch (e) {
modalLoader.setLoading(false);
if (e.response?.body?.message) {
message.error(e.response.body.message);
return;
}
message.error(e.message);
}
};
init();
}, []);
const columns = [
{
title: "Picture",
dataIndex: "image_prove",
key: "image_prove",
render: (text, record) => (
),
},
{
title: "Amount",
dataIndex: "amount",
key: "amount",
width: '20%',
render: (text) =>
new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(text),
},
{
title: "Action",
dataIndex: "amount",
key: "action",
width: '10%',
render: (text, record) => (
),
},
];
if (store.authentication.userData.role === "Retail") columns.pop();
const routeData = [
{
route: LINKS.HOME,
name: "Home",
},
{
route: LINKS.PAYBACK,
name: Payback Confirmation,
},
];
const handleAction = async (id, type) => {
modalLoader.setLoading(true);
try {
const response = await store.payback.confirmPayback(id, type);
if (response.body.status !== 201) {
message.error(`Failed ${capitalize(type)} Payback`);
}
message.success(`Success ${capitalize(type)} Payback`);
} catch (e) {
console.error(e, "apa errornya");
message.error("Failed Handler Action Payback");
}
modalLoader.setLoading(false);
};
return (
{store.ui.mediaQuery.isDesktop && (
{
let pageNumber = page.current;
store.payback.pageSizeConfirmation = page.pageSize;
store.payback.pageConfirmation = pageNumber - 1;
modalLoader.setLoading(true);
await store.payback.getDataConfirmation();
modalLoader.setLoading(false);
}}
/>
)}
{store.ui.mediaQuery.isMobile && (
{
store.payback.pageSizeConfirmation = page.pageSize;
store.payback.pageConfirmation = page.current - 1;
modalLoader.setLoading(true);
await store.payback.getDataConfirmation();
modalLoader.setLoading(false);
},
pageSize: store.payback.pageSizeConfirmation,
total: store.payback.totalDataConfirmation,
current: store.payback.pageConfirmation + 1,
style: {marginBottom: "1rem", marginRight: "1rem"},
}}
dataSource={store.payback.dataConfirmation}
style={{padding: 0}}
renderItem={(item) => {
return (
}
/>
);
}}
/>
)}
);
});