340 lines
13 KiB
JavaScript
340 lines
13 KiB
JavaScript
import {Box, Typography} from "@mui/material";
|
|
import {useMemo} from "react";
|
|
import {GET_LOAN_HISTORY} from "@/core/data/apiRoutes";
|
|
import {useTranslations} from "next-intl";
|
|
import TableRowActions from "./TableRowActions";
|
|
import moment from "jalali-moment";
|
|
import DataTable from "@/core/components/DataTable";
|
|
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
|
|
|
function DashboardLoanHistoryComponent() {
|
|
const t = useTranslations();
|
|
const columns = useMemo(
|
|
() => [
|
|
{
|
|
accessorFn: (row) => row.id,
|
|
id: "id",
|
|
header: t("LoanHistory.id"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.is_legal_person,
|
|
id: "is_legal_person",
|
|
header: t("LoanHistory.is_legal_person"),
|
|
enableColumnFilter: false,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: ["equals"],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography
|
|
variant="body2">{renderedCellValue === 1 ? `${t("LoanHistory.hoghoghi")}` : `${t("LoanHistory.haghighi")}`}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.navgan_id,
|
|
id: "navgan_id",
|
|
header: t("LoanHistory.navgan_id"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.name,
|
|
id: "name",
|
|
header: t("LoanHistory.name"),
|
|
enableColumnFilter: true,
|
|
datatype: "text",
|
|
filterFn: "contains",
|
|
columnFilterModeOptions: ["contains", "equals", "notEquals"],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.national_id,
|
|
id: "national_id",
|
|
header: t("LoanHistory.national_id"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.shenase_meli,
|
|
id: "shenase_meli",
|
|
header: t("LoanHistory.shenase_meli"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.province_name,
|
|
id: "province_name",
|
|
header: t("LoanHistory.province_name"),
|
|
enableColumnFilter: true,
|
|
datatype: "text",
|
|
filterFn: "contains",
|
|
columnFilterModeOptions: ["contains", "equals", "notEquals"],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) =>
|
|
moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"),
|
|
id: "created_at",
|
|
header: t("LoanHistory.created_at"),
|
|
enableColumnFilter: true,
|
|
datatype: "date",
|
|
filterFn: "lessThan",
|
|
columnFilterModeOptions: ["lessThan", "greaterThan"],
|
|
Cell: ({renderedCellValue}) => {
|
|
return <Typography variant="body2">{renderedCellValue}</Typography>;
|
|
},
|
|
Header: ({column}) => <>{column.columnDef.header}</>,
|
|
Filter: ({column}) => {
|
|
return (
|
|
<MuiDatePicker column={column}/>
|
|
);
|
|
},
|
|
},
|
|
{
|
|
accessorFn: (row) => row.phone_number,
|
|
id: "phone_number",
|
|
header: t("LoanHistory.phone_number"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.score,
|
|
id: "score",
|
|
header: t("LoanHistory.score"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.navgan_capacity,
|
|
id: "navgan_capacity",
|
|
header: t("LoanHistory.navgan_capacity"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.manufacture_date,
|
|
id: "manufacture_date",
|
|
header: t("LoanHistory.manufacture_date"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.vehicle_type,
|
|
id: "vehicle_type",
|
|
header: t("LoanHistory.vehicle_type"),
|
|
enableColumnFilter: true,
|
|
datatype: "text",
|
|
filterFn: "contains",
|
|
columnFilterModeOptions: ["contains", "equals", "notEquals"],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.proposed_amount,
|
|
id: "proposed_amount",
|
|
header: t("LoanHistory.proposed_amount"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue / 1000000}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.approved_amount,
|
|
id: "approved_amount",
|
|
header: t("LoanHistory.approved_amount"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals",
|
|
"notEquals",
|
|
"contains",
|
|
"lessThan",
|
|
"greaterThan",
|
|
"between",
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue / 1000000}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.sakht_period,
|
|
id: "sakht_period",
|
|
header: t("LoanHistory.sakht_period"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals"
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.tanafos_period,
|
|
id: "tanafos_period",
|
|
header: t("LoanHistory.tanafos_period"),
|
|
enableColumnFilter: true,
|
|
datatype: "numeric",
|
|
filterFn: "equals",
|
|
columnFilterModeOptions: [
|
|
"equals"
|
|
],
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
{
|
|
accessorFn: (row) => row.state_name,
|
|
id: "state_id",
|
|
header: t("LoanHistory.state_name"),
|
|
enableColumnFilter: false,
|
|
datatype: "numeric",
|
|
Cell: ({renderedCellValue}) => (
|
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
|
),
|
|
},
|
|
],
|
|
[]
|
|
);
|
|
return (
|
|
<Box sx={{px: 3}}>
|
|
<DataTable
|
|
tableUrl={GET_LOAN_HISTORY}
|
|
columns={columns}
|
|
selectableRow={false}
|
|
enableCustomToolbar={false}
|
|
enableLastUpdate={true}
|
|
sorting={[{
|
|
id: 'id', desc: false
|
|
}]}
|
|
enablePinning={true}
|
|
enableDensityToggle={false}
|
|
initialState={{density: 'compact'}} //compact (small) //comfortable (medium) //spacious (large)
|
|
enableColumnFilters={true}
|
|
enableHiding={true}
|
|
enableFullScreenToggle={false}
|
|
enableGlobalFilter={false}
|
|
enableColumnResizing={false} // if you want true this you shold change renderRowActions props ** see https://www.material-react-table.com/docs/guides/row-actions
|
|
enableRowActions={true}
|
|
TableRowAction={TableRowActions}
|
|
/>
|
|
</Box>
|
|
);
|
|
}
|
|
|
|
export default DashboardLoanHistoryComponent;
|