96 lines
3.7 KiB
JavaScript
96 lines
3.7 KiB
JavaScript
import {
|
|
Box,
|
|
DialogContent,
|
|
LinearProgress,
|
|
Paper,
|
|
Table,
|
|
TableBody,
|
|
TableCell,
|
|
TableContainer,
|
|
TableHead,
|
|
TableRow,
|
|
Typography,
|
|
} from "@mui/material";
|
|
import { useTranslations } from "next-intl";
|
|
import { useEffect, useState } from "react";
|
|
import useRequest from "@/lib/app/hooks/useRequest";
|
|
import { GET_COMEBACK_LOAN_DETAIL } from "@/core/data/apiRoutes";
|
|
import moment from "jalali-moment";
|
|
|
|
const ComebackLoanDetailContent = ({ rowId }) => {
|
|
const t = useTranslations();
|
|
const requestServer = useRequest({ auth: true, notification: false });
|
|
const [ComebackLoanDetail, setComebackLoanDetail] = useState([]);
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
const [error, setError] = useState(false);
|
|
useEffect(() => {
|
|
requestServer(`${GET_COMEBACK_LOAN_DETAIL}/${rowId}`, "get")
|
|
.then((res) => {
|
|
setComebackLoanDetail(res.data.data);
|
|
setIsLoading(false);
|
|
})
|
|
.catch((error) => {
|
|
setError(true);
|
|
});
|
|
}, []);
|
|
|
|
return (
|
|
<Box>
|
|
{error ? (
|
|
<Typography
|
|
sx={{
|
|
padding: 2,
|
|
display: "flex",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
}}
|
|
>
|
|
{t("LoanHistory.Table_history_error")}
|
|
</Typography>
|
|
) : isLoading ? (
|
|
<LinearProgress sx={{ width: "100%" }} />
|
|
) : (
|
|
<Paper
|
|
elevation={0}
|
|
sx={{
|
|
width: "100%",
|
|
overflow: "hidden",
|
|
"*::-webkit-scrollbar": {
|
|
width: "0.5em",
|
|
},
|
|
"*::-webkit-scrollbar-thumb": {
|
|
backgroundColor: "primary.main",
|
|
},
|
|
}}
|
|
>
|
|
<TableContainer sx={{ maxHeight: 600 }}>
|
|
<Table stickyHeader sx={{ minWidth: 800 }}>
|
|
<TableHead>
|
|
<TableRow>
|
|
<TableCell>{t("ComebackLoanDetailDialog.Table_head_comeback_name")}</TableCell>
|
|
<TableCell>{t("ComebackLoanDetailDialog.Table_head_comeback_comment")}</TableCell>
|
|
<TableCell>{t("ComebackLoanDetailDialog.Table_head_comeback_date")}</TableCell>
|
|
</TableRow>
|
|
</TableHead>
|
|
<TableBody>
|
|
<TableRow sx={{ "&:last-child td, &:last-child th": { border: 0 } }}>
|
|
<TableCell>{ComebackLoanDetail.comeback_name}</TableCell>
|
|
<TableCell> {ComebackLoanDetail.comeback_comment}</TableCell>
|
|
<TableCell>
|
|
{ComebackLoanDetail.comeback_date
|
|
? moment(ComebackLoanDetail.comeback_date)
|
|
.locale("fa")
|
|
.format("HH:mm | yyyy/MM/DD")
|
|
: null}
|
|
</TableCell>
|
|
</TableRow>
|
|
</TableBody>
|
|
</Table>
|
|
</TableContainer>
|
|
</Paper>
|
|
)}
|
|
</Box>
|
|
);
|
|
};
|
|
export default ComebackLoanDetailContent;
|