From 57d010a28b404e4abacb81ad720742268ca2ca70 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sat, 12 Apr 2025 13:56:14 +0330 Subject: [PATCH] loan history refahi --- public/locales/fa/app.json | 3 + .../{ => navgan}/Buttons/printExcel.jsx | 0 .../Form/HistoryForm/HistoryContent.jsx | 2 +- .../Form/HistoryForm/PrintHistory.jsx | 0 .../Form/HistoryForm/TableContent.jsx | 2 +- .../{ => navgan}/Form/HistoryForm/index.jsx | 2 +- .../{ => navgan}/TableRowActions.jsx | 2 +- .../{ => navgan}/TableToolbar.jsx | 2 +- .../loan-history/{ => navgan}/index.jsx | 34 +- .../refahi/Buttons/printExcel.jsx | 69 ++++ .../Form/HistoryForm/HistoryContent.jsx | 30 ++ .../refahi/Form/HistoryForm/PrintHistory.jsx | 25 ++ .../refahi/Form/HistoryForm/TableContent.jsx | 145 +++++++ .../refahi/Form/HistoryForm/index.jsx | 39 ++ .../loan-history/refahi/TableRowActions.jsx | 12 + .../loan-history/refahi/TableToolbar.jsx | 12 + .../dashboard/loan-history/refahi/index.jsx | 360 ++++++++++++++++++ src/core/data/sidebarMenu.jsx | 20 +- .../loan-history/{ => navgan}/index.jsx | 2 +- .../dashboard/loan-history/refahi/index.jsx | 22 ++ 20 files changed, 755 insertions(+), 28 deletions(-) rename src/components/dashboard/loan-history/{ => navgan}/Buttons/printExcel.jsx (100%) rename src/components/dashboard/loan-history/{ => navgan}/Form/HistoryForm/HistoryContent.jsx (90%) rename src/components/dashboard/loan-history/{ => navgan}/Form/HistoryForm/PrintHistory.jsx (100%) rename src/components/dashboard/loan-history/{ => navgan}/Form/HistoryForm/TableContent.jsx (98%) rename src/components/dashboard/loan-history/{ => navgan}/Form/HistoryForm/index.jsx (93%) rename src/components/dashboard/loan-history/{ => navgan}/TableRowActions.jsx (80%) rename src/components/dashboard/loan-history/{ => navgan}/TableToolbar.jsx (74%) rename src/components/dashboard/loan-history/{ => navgan}/index.jsx (95%) create mode 100644 src/components/dashboard/loan-history/refahi/Buttons/printExcel.jsx create mode 100644 src/components/dashboard/loan-history/refahi/Form/HistoryForm/HistoryContent.jsx create mode 100644 src/components/dashboard/loan-history/refahi/Form/HistoryForm/PrintHistory.jsx create mode 100644 src/components/dashboard/loan-history/refahi/Form/HistoryForm/TableContent.jsx create mode 100644 src/components/dashboard/loan-history/refahi/Form/HistoryForm/index.jsx create mode 100644 src/components/dashboard/loan-history/refahi/TableRowActions.jsx create mode 100644 src/components/dashboard/loan-history/refahi/TableToolbar.jsx create mode 100644 src/components/dashboard/loan-history/refahi/index.jsx rename src/pages/dashboard/loan-history/{ => navgan}/index.jsx (96%) create mode 100644 src/pages/dashboard/loan-history/refahi/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 5283808..6c9d65b 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -72,6 +72,7 @@ "role-management": "مدیریت نقش ها", "edit-profile": "ویرایش پروفایل", "loan-history": "کارتابل نظارت", + "loan-history-refahi": "کارتابل نظارت", "loan-followup": "پیگیری وام", "refahi-loan-followup": "پیگیری وام", "loan-history-province": "کارتابل نظارت استانی", @@ -80,7 +81,9 @@ "secondary": { "passenger-boss": "کارگروه", "loan-followup": "ناوگان", + "loan-history": "ناوگان", "refahi-loan-management": "رفاهی", + "loan-history-refahi": "رفاهی", "refahi-province-manager": "رفاهی", "refahi-transportation": "رفاهی", "refahi-province-working-group": "رفاهی", diff --git a/src/components/dashboard/loan-history/Buttons/printExcel.jsx b/src/components/dashboard/loan-history/navgan/Buttons/printExcel.jsx similarity index 100% rename from src/components/dashboard/loan-history/Buttons/printExcel.jsx rename to src/components/dashboard/loan-history/navgan/Buttons/printExcel.jsx diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx b/src/components/dashboard/loan-history/navgan/Form/HistoryForm/HistoryContent.jsx similarity index 90% rename from src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx rename to src/components/dashboard/loan-history/navgan/Form/HistoryForm/HistoryContent.jsx index eda6f7c..5cb7caa 100644 --- a/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx +++ b/src/components/dashboard/loan-history/navgan/Form/HistoryForm/HistoryContent.jsx @@ -1,7 +1,7 @@ import { Button, DialogActions, DialogContent } from "@mui/material"; import { useTranslations } from "next-intl"; import { useFormik } from "formik"; -import TableContent from "@/components/dashboard/loan-history/Form/HistoryForm/TableContent"; +import TableContent from "./TableContent"; const HistoryContent = ({ mutate, setOpenConfirmDialog, rowId }) => { const t = useTranslations(); diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/PrintHistory.jsx b/src/components/dashboard/loan-history/navgan/Form/HistoryForm/PrintHistory.jsx similarity index 100% rename from src/components/dashboard/loan-history/Form/HistoryForm/PrintHistory.jsx rename to src/components/dashboard/loan-history/navgan/Form/HistoryForm/PrintHistory.jsx diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx b/src/components/dashboard/loan-history/navgan/Form/HistoryForm/TableContent.jsx similarity index 98% rename from src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx rename to src/components/dashboard/loan-history/navgan/Form/HistoryForm/TableContent.jsx index 3509453..831c842 100644 --- a/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx +++ b/src/components/dashboard/loan-history/navgan/Form/HistoryForm/TableContent.jsx @@ -13,7 +13,7 @@ import { import { useTranslations } from "next-intl"; import { GET_HISTORY_DETAIL } from "@/core/data/apiRoutes"; import moment from "jalali-moment"; -import PrintHistory from "@/components/dashboard/loan-history/Form/HistoryForm/PrintHistory"; +import PrintHistory from "./PrintHistory"; import useRequest from "@/lib/app/hooks/useRequest"; import { useEffect, useState } from "react"; diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/index.jsx b/src/components/dashboard/loan-history/navgan/Form/HistoryForm/index.jsx similarity index 93% rename from src/components/dashboard/loan-history/Form/HistoryForm/index.jsx rename to src/components/dashboard/loan-history/navgan/Form/HistoryForm/index.jsx index 872128a..5f7963d 100644 --- a/src/components/dashboard/loan-history/Form/HistoryForm/index.jsx +++ b/src/components/dashboard/loan-history/navgan/Form/HistoryForm/index.jsx @@ -2,7 +2,7 @@ import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; import { useTranslations } from "next-intl"; import { useState } from "react"; import HistoryIcon from "@mui/icons-material/History"; -import HistoryContent from "@/components/dashboard/loan-history/Form/HistoryForm/HistoryContent"; +import HistoryContent from "./HistoryContent"; const History = ({ rowId, mutate }) => { const t = useTranslations(); diff --git a/src/components/dashboard/loan-history/TableRowActions.jsx b/src/components/dashboard/loan-history/navgan/TableRowActions.jsx similarity index 80% rename from src/components/dashboard/loan-history/TableRowActions.jsx rename to src/components/dashboard/loan-history/navgan/TableRowActions.jsx index ab4f3a8..e72b5a2 100644 --- a/src/components/dashboard/loan-history/TableRowActions.jsx +++ b/src/components/dashboard/loan-history/navgan/TableRowActions.jsx @@ -1,5 +1,5 @@ import { Box } from "@mui/material"; -import History from "@/components/dashboard/loan-history/Form/HistoryForm"; +import History from "./Form/HistoryForm"; const TableRow = ({ row, mutate }) => { return ( diff --git a/src/components/dashboard/loan-history/TableToolbar.jsx b/src/components/dashboard/loan-history/navgan/TableToolbar.jsx similarity index 74% rename from src/components/dashboard/loan-history/TableToolbar.jsx rename to src/components/dashboard/loan-history/navgan/TableToolbar.jsx index 76d7002..22483e2 100644 --- a/src/components/dashboard/loan-history/TableToolbar.jsx +++ b/src/components/dashboard/loan-history/navgan/TableToolbar.jsx @@ -1,5 +1,5 @@ import { Stack } from "@mui/material"; -import PrintExcel from "@/components/dashboard/loan-history/Buttons/printExcel"; +import PrintExcel from "./Buttons/printExcel"; const TableToolbar = ({ table }) => { return ( diff --git a/src/components/dashboard/loan-history/index.jsx b/src/components/dashboard/loan-history/navgan/index.jsx similarity index 95% rename from src/components/dashboard/loan-history/index.jsx rename to src/components/dashboard/loan-history/navgan/index.jsx index 3b9e0c1..118009d 100644 --- a/src/components/dashboard/loan-history/index.jsx +++ b/src/components/dashboard/loan-history/navgan/index.jsx @@ -6,7 +6,7 @@ import TableRowActions from "./TableRowActions"; import moment from "jalali-moment"; import DataTable from "@/core/components/DataTable"; import MuiDatePicker from "@/core/components/MuiDatePicker"; -import TableToolbar from "@/components/dashboard/loan-history/TableToolbar"; +import TableToolbar from "./TableToolbar"; function DashboardLoanHistoryComponent() { const t = useTranslations(); @@ -106,22 +106,22 @@ function DashboardLoanHistoryComponent() { columnFilterModeOptions: ["equals", "notEquals", "contains"], Cell: ({ renderedCellValue }) => {renderedCellValue}, }, - { - 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 {renderedCellValue}; - }, - Header: ({ column }) => <>{column.columnDef.header}, - Filter: ({ column }) => { - return ; - }, - }, + // { + // 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 {renderedCellValue}; + // }, + // Header: ({ column }) => <>{column.columnDef.header}, + // Filter: ({ column }) => { + // return ; + // }, + // }, { accessorFn: (row) => row.phone_number, id: "phone_number", diff --git a/src/components/dashboard/loan-history/refahi/Buttons/printExcel.jsx b/src/components/dashboard/loan-history/refahi/Buttons/printExcel.jsx new file mode 100644 index 0000000..9afd5e8 --- /dev/null +++ b/src/components/dashboard/loan-history/refahi/Buttons/printExcel.jsx @@ -0,0 +1,69 @@ +import { Button, CircularProgress } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useMemo, useState } from "react"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { EXPORT_LOAN_HISTORY } from "@/core/data/apiRoutes"; +import moment from "jalali-moment"; +import FileSaver from "file-saver"; +import DescriptionIcon from "@mui/icons-material/Description"; + +const PrintExcel = ({ table }) => { + const t = useTranslations(); + const [loading, setLoading] = useState(false); + const requestServer = useRequest({ auth: true, pending: false, success: { notification: { show: false } } }); + const { columnFilters, columnFilterFns, sorting } = table.getState(); + const columns = table.getAllColumns(); + + const filterParams = useMemo(() => { + const params = new URLSearchParams(); + const filters = columnFilters.map((filter) => { + let datatype; + for (const i in columns) { + if (columns[i].id == filter.id) { + datatype = columns[i].columnDef.datatype; + } + } + return { + ...filter, + fn: columnFilterFns[filter.id], + datatype: datatype, + }; + }); + params.set("start", "0"); + params.set("filters", JSON.stringify(filters ?? [])); + params.set("sorting", JSON.stringify(sorting ?? [])); + return params; + }, [columnFilters, columnFilterFns, sorting, columns]); + + const clickHandler = () => { + setLoading(true); + requestServer(`${EXPORT_LOAN_HISTORY}?${filterParams}`, "get", { + auth: true, + requestOptions: { responseType: "blob" }, + }) + .then((response) => { + const filename = `خروجی کارتابل نظارت تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`; + FileSaver.saveAs(response.data, filename); + }) + .catch(() => {}) + .finally(() => { + setLoading(false); + }); + }; + + return ( + + ); +}; + +export default PrintExcel; diff --git a/src/components/dashboard/loan-history/refahi/Form/HistoryForm/HistoryContent.jsx b/src/components/dashboard/loan-history/refahi/Form/HistoryForm/HistoryContent.jsx new file mode 100644 index 0000000..5cb7caa --- /dev/null +++ b/src/components/dashboard/loan-history/refahi/Form/HistoryForm/HistoryContent.jsx @@ -0,0 +1,30 @@ +import { Button, DialogActions, DialogContent } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useFormik } from "formik"; +import TableContent from "./TableContent"; + +const HistoryContent = ({ mutate, setOpenConfirmDialog, rowId }) => { + const t = useTranslations(); + + const formik = useFormik({}); + + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/loan-history/refahi/Form/HistoryForm/PrintHistory.jsx b/src/components/dashboard/loan-history/refahi/Form/HistoryForm/PrintHistory.jsx new file mode 100644 index 0000000..dfcce4a --- /dev/null +++ b/src/components/dashboard/loan-history/refahi/Form/HistoryForm/PrintHistory.jsx @@ -0,0 +1,25 @@ +import { Button, CircularProgress } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import useRequest from "@/lib/app/hooks/useRequest"; +import DescriptionIcon from "@mui/icons-material/Description"; +import Link from "next/link"; + +const PrintHistory = ({ attachment }) => { + const t = useTranslations(); + return ( + + ); +}; + +export default PrintHistory; diff --git a/src/components/dashboard/loan-history/refahi/Form/HistoryForm/TableContent.jsx b/src/components/dashboard/loan-history/refahi/Form/HistoryForm/TableContent.jsx new file mode 100644 index 0000000..831c842 --- /dev/null +++ b/src/components/dashboard/loan-history/refahi/Form/HistoryForm/TableContent.jsx @@ -0,0 +1,145 @@ +import { + Box, + LinearProgress, + Paper, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Typography, +} from "@mui/material"; +import { useTranslations } from "next-intl"; +import { GET_HISTORY_DETAIL } from "@/core/data/apiRoutes"; +import moment from "jalali-moment"; +import PrintHistory from "./PrintHistory"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { useEffect, useState } from "react"; + +const action_name = { + confirm: "تایید", + reject: "عدم تایید", + refer: "ارجاع", + reserve: "رزرو", +}; + +const TableContent = ({ rowId }) => { + const t = useTranslations(); + const requestServer = useRequest({ auth: true, notification: false }); + const [historyDetails, setHistoryDetails] = useState([]); + const [isLoading, setIsLoading] = useState(true); + const [error, setError] = useState(false); + + useEffect(() => { + requestServer(`${GET_HISTORY_DETAIL}/${rowId}`, "get") + .then((response) => { + setIsLoading(false); + setHistoryDetails(response.data.data); + }) + .catch(() => { + setError(true); + }); + }, []); + + return ( + + {error ? ( + + {t("LoanHistory.Table_history_error")} + + ) : isLoading ? ( + + ) : historyDetails.latest_histories.length === 0 ? ( + + {t("LoanHistory.empty_history_detail")} + + ) : ( + + + + + + {t("LoanHistory.Table_head_name")} + {t("LoanHistory.Table_head_date")} + {t("LoanHistory.Table_head_position")} + {t("LoanHistory.Table_head_state")} + {t("LoanHistory.Table_head_action")} + {t("LoanHistory.Table_head_expert_description")} + {t("LoanHistory.Table_head_file")} + + + + {historyDetails.latest_histories.map((latest_history, index) => { + return ( + + + {" "} + {latest_history?.expert?.name ? latest_history.expert.name : null} + + + {moment(latest_history.created_at) + .locale("fa") + .format("HH:mm | yyyy/MM/DD")} + + + {latest_history?.expert?.position + ? latest_history.expert.position + : null} + + + {latest_history?.previous_state_name + ? latest_history.previous_state_name + : null} + + {action_name[latest_history?.action]} + {latest_history?.expert_description} + + {latest_history.attachments.map((attachment, index) => ( + + ))} + + + ); + })} + +
+
+
+ )} +
+ ); +}; +export default TableContent; diff --git a/src/components/dashboard/loan-history/refahi/Form/HistoryForm/index.jsx b/src/components/dashboard/loan-history/refahi/Form/HistoryForm/index.jsx new file mode 100644 index 0000000..5f7963d --- /dev/null +++ b/src/components/dashboard/loan-history/refahi/Form/HistoryForm/index.jsx @@ -0,0 +1,39 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import HistoryIcon from "@mui/icons-material/History"; +import HistoryContent from "./HistoryContent"; + +const History = ({ rowId, mutate }) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return ( + <> + + { + setOpenConfirmDialog(true); + }} + > + + + + + {t("LoanHistory.history")} + + + + ); +}; +export default History; diff --git a/src/components/dashboard/loan-history/refahi/TableRowActions.jsx b/src/components/dashboard/loan-history/refahi/TableRowActions.jsx new file mode 100644 index 0000000..e72b5a2 --- /dev/null +++ b/src/components/dashboard/loan-history/refahi/TableRowActions.jsx @@ -0,0 +1,12 @@ +import { Box } from "@mui/material"; +import History from "./Form/HistoryForm"; + +const TableRow = ({ row, mutate }) => { + return ( + + + + ); +}; + +export default TableRow; diff --git a/src/components/dashboard/loan-history/refahi/TableToolbar.jsx b/src/components/dashboard/loan-history/refahi/TableToolbar.jsx new file mode 100644 index 0000000..22483e2 --- /dev/null +++ b/src/components/dashboard/loan-history/refahi/TableToolbar.jsx @@ -0,0 +1,12 @@ +import { Stack } from "@mui/material"; +import PrintExcel from "./Buttons/printExcel"; + +const TableToolbar = ({ table }) => { + return ( + + + + ); +}; + +export default TableToolbar; diff --git a/src/components/dashboard/loan-history/refahi/index.jsx b/src/components/dashboard/loan-history/refahi/index.jsx new file mode 100644 index 0000000..118009d --- /dev/null +++ b/src/components/dashboard/loan-history/refahi/index.jsx @@ -0,0 +1,360 @@ +import { Box, Stack, 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"; +import TableToolbar from "./TableToolbar"; + +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 }) => {renderedCellValue}, + }, + { + 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 }) => ( + + {renderedCellValue === 1 ? `${t("LoanHistory.hoghoghi")}` : `${t("LoanHistory.haghighi")}`} + + ), + }, + { + 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 }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.name, + id: "name", + header: t("LoanHistory.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + 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 }) => {renderedCellValue}, + }, + { + 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 }) => {renderedCellValue}, + }, + { + 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 }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.city_name, + id: "city_name", + header: t("LoanHistory.city_name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.postal_code, + id: "postal_code", + header: t("LoanHistory.postal_code"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["equals", "notEquals", "contains"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + // { + // 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 {renderedCellValue}; + // }, + // Header: ({ column }) => <>{column.columnDef.header}, + // Filter: ({ column }) => { + // return ; + // }, + // }, + { + 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 }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.statement_count, + id: "statement_count", + header: t("LoanHistory.statement_count"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + 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 }) => {renderedCellValue}, + }, + { + 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 }) => {renderedCellValue}, + }, + { + 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 }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.plate_number, + id: "plate_number", + header: t("LoanHistory.plate_number"), + enableColumnFilter: false, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + + + {renderedCellValue.split("-")[3]} + + + + {renderedCellValue.split("-")[2]} + + + {renderedCellValue.split("-")[1]} + + + {renderedCellValue.split("-")[0]} + + + + ), + }, + { + 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 }) => {renderedCellValue / 1000000}, + }, + { + accessorFn: (row) => row.facility_bank, + id: "facility_bank", + header: t("LoanHistory.facility_bank"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, + }, + { + accessorFn: (row) => row.facility_gov, + id: "facility_gov", + header: t("LoanHistory.facility_gov"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, + }, + { + accessorFn: (row) => row.facility_person, + id: "facility_person", + header: t("LoanHistory.facility_person"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, + }, + { + accessorFn: (row) => row.physical_progress, + id: "physical_progress", + header: t("LoanHistory.physical_progress"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.repayment_period, + id: "repayment_period", + header: t("LoanHistory.repayment_period"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.sakht_period, + id: "sakht_period", + header: t("LoanHistory.sakht_period"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.tanafos_period, + id: "tanafos_period", + header: t("LoanHistory.tanafos_period"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.committed_employment, + id: "committed_employment", + header: t("LoanHistory.committed_employment"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.existing_employment, + id: "existing_employment", + header: t("LoanHistory.existing_employment"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.state_name, + id: "state_name", + header: t("LoanHistory.state_name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + ], + [] + ); + return ( + + + + ); +} + +export default DashboardLoanHistoryComponent; diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index e23e256..8744dc7 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -4,9 +4,7 @@ import AssignmentIndIcon from "@mui/icons-material/AssignmentInd"; import DesktopWindowsIcon from "@mui/icons-material/DesktopWindows"; import GavelIcon from "@mui/icons-material/Gavel"; import BusinessCenterIcon from "@mui/icons-material/BusinessCenter"; -import GradingIcon from "@mui/icons-material/Grading"; -import SupervisedUserCircleIcon from "@mui/icons-material/SupervisedUserCircle"; -import Diversity3Icon from "@mui/icons-material/Diversity3"; +import PollIcon from '@mui/icons-material/Poll'; import PaidIcon from "@mui/icons-material/Paid"; import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; import PersonIcon from "@mui/icons-material/Person"; @@ -17,6 +15,7 @@ import SettingsIcon from "@mui/icons-material/Settings"; import RepartitionIcon from "@mui/icons-material/Repartition"; import AccountBalanceIcon from "@mui/icons-material/AccountBalance"; import RepeatIcon from "@mui/icons-material/Repeat"; +import DisplaySettingsIcon from '@mui/icons-material/DisplaySettings'; const sidebarMenu = [ [ @@ -39,13 +38,24 @@ const sidebarMenu = [ }, { key: "sidebar.loan-history", + secondary: "secondary.loan-history", name: "loan-history", type: "page", - route: "/dashboard/loan-history", + route: "/dashboard/loan-history/navgan", icon: , selected: false, permissions: ["view_navgan_loans", "view_navgan_loans_province"], }, + { + key: "sidebar.loan-history-refahi", + secondary: "secondary.loan-history-refahi", + name: "loan-history-refahi", + type: "page", + route: "/dashboard/loan-history/refahi", + icon: , + selected: false, + permissions: ["view_navgan_loans", "view_navgan_loans_province"], + }, ], [ { @@ -166,7 +176,7 @@ const sidebarMenu = [ name: "refahi_province_manager_navgan", type: "page", route: "/dashboard/refahi/refahi-province-manager", - icon: , + icon: , selected: false, permissions: ["manage_province_affairs_refahi"], }, diff --git a/src/pages/dashboard/loan-history/index.jsx b/src/pages/dashboard/loan-history/navgan/index.jsx similarity index 96% rename from src/pages/dashboard/loan-history/index.jsx rename to src/pages/dashboard/loan-history/navgan/index.jsx index 4e61957..c6695de 100644 --- a/src/pages/dashboard/loan-history/index.jsx +++ b/src/pages/dashboard/loan-history/navgan/index.jsx @@ -1,5 +1,5 @@ import { parse } from "next-useragent"; -import DashboardLoanHistoryComponent from "@/components/dashboard/loan-history"; +import DashboardLoanHistoryComponent from "@/components/dashboard/loan-history/navgan"; export default function LoanHistory() { return ; diff --git a/src/pages/dashboard/loan-history/refahi/index.jsx b/src/pages/dashboard/loan-history/refahi/index.jsx new file mode 100644 index 0000000..cd0bfe8 --- /dev/null +++ b/src/pages/dashboard/loan-history/refahi/index.jsx @@ -0,0 +1,22 @@ +import { parse } from "next-useragent"; +import DashboardLoanHistoryComponent from "@/components/dashboard/loan-history/refahi"; + +export default function LoanHistory() { + return ; +} + +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.loan_history", + isBot, + locale, + layout: { + name: "DashboardLayout", + props: { permissions: ["view_navgan_loans", "view_navgan_loans_province"] }, + }, + }, + }; +}