bank management cartable

This commit is contained in:
2024-02-06 14:28:04 +03:30
parent 4cd577a2dc
commit 6dec676f9b
7 changed files with 345 additions and 1 deletions

View File

@@ -0,0 +1,68 @@
import {useTranslations} from "next-intl";
import {useState} from "react";
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
IconButton,
Tooltip,
Typography
} from "@mui/material";
import RefreshIcon from '@mui/icons-material/Refresh';
import useRequest from "@/lib/app/hooks/useRequest";
import useNotification from "@/lib/app/hooks/useNotification";
import {RESEND_BANK_STATEMENT} from "@/core/data/apiRoutes";
const UpdateForm = ({rowId, mutate}) => {
const t = useTranslations();
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false)
const requestServer = useRequest({auth: true})
const {update_notification} = useNotification()
const handleSubmit = () => {
setIsSubmitting(true)
requestServer(`${RESEND_BANK_STATEMENT}/${rowId}`, 'post').then((response) => {
setOpenConfirmDialog(false)
mutate()
update_notification()
}).catch(() => {
}).finally(() => {
setIsSubmitting(false)
});
}
return (
<>
<Tooltip title={t("UpdateDialog.resend")}>
<IconButton
color="primary"
onClick={() => {
setOpenConfirmDialog(true)
}}
>
<RefreshIcon/>
</IconButton>
</Tooltip>
<Dialog maxWidth="sm" open={openConfirmDialog}
PaperProps={{sx: {boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}}>
<DialogTitle>{t("UpdateDialog.resend")}</DialogTitle>
<DialogContent>
<Typography>{t("UpdateDialog.typography")}</Typography>
</DialogContent>
<DialogActions>
<Button onClick={() => setOpenConfirmDialog(false)} variant="outlined" color="secondary"
disabled={isSubmitting} autoFocus>
{t("UpdateDialog.button-cancel")}
</Button>
<Button onClick={handleSubmit} variant="contained" color="primary"
disabled={isSubmitting}>
{t("UpdateDialog.button-resend")}
</Button>
</DialogActions>
</Dialog>
</>
);
};
export default UpdateForm;

View File

@@ -0,0 +1,15 @@
import {Box} from "@mui/material";
import UpdateForm from "@/components/dashboard/bank-management/Form/Update";
const TableRow = ({row, mutate}) => {
return (
<Box sx={{display: "flex", flexWrap: "nowrap", gap: "8px"}}>
<UpdateForm
rowId={row.getValue("id")}
mutate={mutate}
/>
</Box>
);
};
export default TableRow;

View File

@@ -0,0 +1,207 @@
import {Box, Typography} from "@mui/material";
import {useMemo} from "react";
import {useTranslations} from "next-intl";
import moment from "jalali-moment";
import DataTable from "@/core/components/DataTable";
import TableRowActions from "@/components/dashboard/bank-management/TableRowActions";
import {GET_BANK_STATEMENT} from "@/core/data/apiRoutes";
function DashboardBankManagementComponent() {
const t = useTranslations();
const columns = useMemo(
() => [
{
accessorFn: (row) => row.id,
id: "id",
header: t("BankManagement.id"),
enableColumnFilter: true,
datatype: "numeric",
filterFn: "equals",
columnFilterModeOptions: [
"equals",
"notEquals",
"contains",
"lessThan",
"greaterThan",
"between",
],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
},
{
accessorFn: (row) => row.navgan_id,
id: "navgan_id",
header: t("BankManagement.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("BankManagement.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("BankManagement.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.national_serial_number,
id: "national_serial_number",
header: t("BankManagement.national_serial_number"),
enableColumnFilter: true,
datatype: "numeric",
filterFn: "equals",
columnFilterModeOptions: [
"equals",
"notEquals",
"contains",
"lessThan",
"greaterThan",
"between",
],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
},
{
accessorFn: (row) => row.birthday,
id: "birthday",
header: t("BankManagement.birthday"),
enableColumnFilter: true,
datatype: "text",
filterFn: "contains",
columnFilterModeOptions: ["contains", "equals", "notEquals"],
Cell: ({renderedCellValue}) => (
<Typography
variant="body2">{moment(renderedCellValue).locale("fa").format("yyyy/MM/DD")}</Typography>
),
},
{
accessorFn: (row) => row.proposed_amount,
id: "proposed_amount",
header: t("BankManagement.proposed_amount"),
enableColumnFilter: true,
datatype: "text",
filterFn: "equals",
columnFilterModeOptions: [
"equals",
"notEquals",
"contains",
],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
},
{
accessorFn: (row) => row.bank_loan_amount,
id: "bank_loan_amount",
header: t("BankManagement.bank_loan_amount"),
enableColumnFilter: true,
datatype: "numeric",
filterFn: "equals",
columnFilterModeOptions: [
"equals",
"notEquals",
"contains",
"lessThan",
"greaterThan",
"between",
],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
},
{
accessorFn: (row) => row.branch_name,
id: "branch_name",
header: t("BankManagement.branch_name"),
enableColumnFilter: true,
datatype: "text",
filterFn: "contains",
columnFilterModeOptions: ["contains", "equals", "notEquals"],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
},
{
accessorFn: (row) => row.bank_state,
id: "bank_state",
header: t("BankManagement.bank_state"),
enableColumnFilter: true,
datatype: "text",
filterFn: "equals",
columnFilterModeOptions: [
"equals",
"notEquals",
"contains"
],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
}
],
[]
);
return (
<Box sx={{px: 3}}>
<DataTable
tableUrl={GET_BANK_STATEMENT}
columns={columns}
selectableRow={false}
// enableCustomToolbar={true}
// CustomToolbar={TableToolbar}
enableLastUpdate={true}
sorting={[{
id: 'score', 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 should change renderRowActions props ** see https://www.material-react-table.com/docs/guides/row-actions
enableRowActions={true}
TableRowAction={TableRowActions}
/>
</Box>
);
}
export default DashboardBankManagementComponent;

View File

@@ -243,6 +243,10 @@ export const ADD_ADMIN_SETTING = BASE_URL + "/dashboard/settings/store"
export const UPDATE_ADMIN_SETTING = BASE_URL + "/dashboard/settings/update"
export const DELETE_ADMIN_SETTING = BASE_URL + "/dashboard/settings/delete"
//bank statement
export const GET_BANK_STATEMENT = BASE_URL + "/dashboard/bank_referred_loans"
export const RESEND_BANK_STATEMENT = BASE_URL + "/dashboard/bank_referred_loans/resend"
// loan statistics
export const GET_LOAN_STATISTICS = BASE_URL + "/dashboard/reports/navgan/statistics"

View File

@@ -16,6 +16,7 @@ import AccessibilityIcon from '@mui/icons-material/Accessibility';
import AssessmentIcon from '@mui/icons-material/Assessment';
import SecurityIcon from '@mui/icons-material/Security';
import SettingsIcon from '@mui/icons-material/Settings';
import AccountBalanceIcon from '@mui/icons-material/AccountBalance';
const sidebarMenu = [
[
@@ -97,6 +98,16 @@ const sidebarMenu = [
selected: false,
permissions: ["manage_province_affairs_navgan"],
},
{
key: "sidebar.bank-management",
secondary: "secondary.navgan-province-manager",
name: "management",
type: "page",
route: "/dashboard/bank-management",
icon: <AccountBalanceIcon sx={{width: 'inherit', height: 'inherit'}}/>,
selected: false,
permissions: ["manage_bank_referred_loans"],
},
{
key: "sidebar.navgan-loan-management",
secondary: "secondary.navgan-loan-management",

View File

@@ -0,0 +1,21 @@
import {parse} from "next-useragent";
import DashboardBankManagementComponent from "@/components/dashboard/bank-management";
export default function BankManagement() {
return (
<DashboardBankManagementComponent/>
);
}
export async function getServerSideProps({req, locale}) {
const {isBot} = parse(req.headers["user-agent"]);
return {
props: {
messages: (await import(`&/locales/${locale}/app.json`)).default,
title: "Dashboard.bank_management_page",
isBot,
locale,
layout: {name: 'DashboardLayout', props: {permissions: ["manage_bank_referred_loans"]}}
},
};
}