Merge branch 'feature/loan_followup' into 'develop'

Feature/loan followup

See merge request witel-front-end/loan-facilities/expert-v2!13
This commit is contained in:
AmirHossein Mahmoodi
2024-11-02 06:48:57 +00:00
12 changed files with 616 additions and 1 deletions

View File

@@ -62,6 +62,7 @@
"role-management": "مدیریت نقش ها",
"edit-profile": "ویرایش پروفایل",
"loan-history": "کارتابل نظارت",
"loan-followup": "پیگیری وام",
"loan-history-province": "کارتابل نظارت استانی",
"reserve-loan": "وام های رزرو"
},
@@ -124,6 +125,7 @@
"user_management_page": "مدیریت کاربر",
"admin_setting": "تنظیمات",
"loan_history": "کارتابل نظارت",
"loan_followup": "کارتابل پیگیری وام",
"total_number_loan_offers": "تعداد کل وام های پیشنهادی",
"total_amount_proposed_loan": "مبلغ کل وام های پیشنهادی",
"total_number_requests": "تعداد کل درخواست ها",
@@ -269,6 +271,56 @@
"first_form": "فرم الف را بارگذاری کنید",
"second_form": "فرم ب را بارگذاری کنید"
},
"LoanFollowUp": {
"name": "نام",
"birthday": "تاریخ تولد",
"approved_amount": "مبلغ مصوب",
"branch_name": "نام شعبه",
"bank_state": "وضعیت پیگیری بانک",
"button-reserve-confirm": "رزرو",
"reserve-loan-title": "رزرو وام",
"description-reserve-loan-first": "آیا از رزرو وام به کد یکتا",
"description-reserve-loan-second": "اطمینان دارید؟",
"button-reserve-cancel": "بستن",
"national_serial_number": "سریال پشت کارت ملی",
"national_tracking_code": "کد رهگیری کارت ملی",
"city_name": "شهرستان",
"plate_number": "پلاک",
"refer_reason": "علت ارجاع",
"statement_count": "تعداد صورت وضعیت",
"id": "کد یکتا",
"score": "اولویت",
"navgan_capacity": "ظرفیت",
"manufacture_date": "سال ساخت",
"shenase_meli": "شناسه ملی",
"is_legal_person": "نوع شخص",
"haghighi": "حقیقی",
"hoghoghi": "حقوقی",
"province_name": "استان",
"sakht_period": "دوره ساخت",
"tanafos_period": "دوره تنفس",
"national_id": "کد ملی",
"phone_number": "موبایل",
"proposed_amount": "مبلغ پیشنهادی",
"created_at": "تاریخ درخواست",
"updated_at": "تاریخ بروزرسانی",
"navgan_id": "کد ناوگان",
"vehicle_type": "نوع ماشین",
"state_name": "وضعیت درخواست",
"confirm": "تایید و ارجاع به معاون حمل و نقل",
"upload_file": "فایل خود را بارگذاری کنید(اختیاری)",
"upload_expert_img": "فایل گزارش کارشناسی را بارگذاری کنید",
"upload_file_required": "وارد کردن گزارش کارشناسی الزامیست",
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
"upload_expert_file_required": "وارد کردن گزارش کارشناسی الزامیست",
"upload_expert_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
"upload_expert_file_format": "فرمت قابل قبول : png,jpg,pdf",
"max_amount": "حداکثر مبلغ تصویب شده {value} میلیون ریال می باشد",
"excel_report": "گزارش اکسل",
"first_form": "فرم الف را بارگذاری کنید",
"second_form": "فرم ب را بارگذاری کنید"
},
"RefahiProvinceManager": {
"name": "نام",
"id": "کد یکتا",
@@ -727,6 +779,16 @@
"typography": "آیا از حدف این مورد اطمینان دارید ؟",
"button-delete": "حذف کردن"
},
"ReferDialog": {
"refer-passenger-boss": "ارجاع به کارگروه",
"refer-user": "ارجاع به کاربر",
"refer-confirmation": "آیا از ارجاع این مورد اطمینان دارید ؟",
"button-cancel": "انصراف",
"typography": "آیا از ارجاع این مورد اطمینان دارید ؟",
"button-refer": "ارجاع",
"description_error" : "وارد کردن توضیحات الزامیست!!!",
"description": "توضیحات"
},
"AddDialog": {
"add": "افزودن",
"setting_name": "نام انگلیسی",

View File

@@ -0,0 +1,80 @@
import useNotification from "@/lib/app/hooks/useNotification";
import useRequest from "@/lib/app/hooks/useRequest";
import {Button, DialogActions, DialogContent, Stack, TextField} from "@mui/material"
import {useFormik} from "formik";
import {useTranslations} from "next-intl";
import * as Yup from "yup";
import {REFER_LOAN_FOLLOWUP_PASSENGERBOSS} from "@/core/data/apiRoutes";
const ReferPassengerBossContent = ({rowId, mutate, setOpenReferDialog}) => {
const t = useTranslations();
const requestServer = useRequest({auth: true})
const {update_notification} = useNotification()
const validationSchema = Yup.object().shape({
description: Yup.string().required(t("ReferDialog.description_error")),
});
const formik = useFormik({
initialValues: {
description: "",
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("expert_description", values.description);
requestServer(`${REFER_LOAN_FOLLOWUP_PASSENGERBOSS}/${rowId}`, 'post', {
data: formData,
}).then((response) => {
setOpenReferDialog(false)
mutate()
update_notification()
}).catch(() => {
}).finally(() => {
setSubmitting(false);
});
},
});
const handleDescriptionChange = (event) => {
formik.setFieldValue("description", event.target.value);
formik.handleChange(event);
};
return (
<>
<DialogContent>
<Stack spacing={2}>
<Stack>
<TextField
name="description"
multiline
rows={8}
label={t("ReferDialog.description")}
value={formik.values.description}
onChange={handleDescriptionChange}
onBlur={formik.handleBlur("description")}
error={
formik.touched.description && Boolean(formik.errors.description)
}
helperText={formik.touched.description && formik.errors.description}
fullWidth
variant="outlined"
sx={{mt: 1}}
/>
</Stack>
</Stack>
</DialogContent>
<DialogActions>
<Button onClick={() => setOpenReferDialog(false)} variant="outlined" color="secondary"
disabled={formik.isSubmitting} autoFocus>
{t("ReferDialog.button-cancel")}
</Button>
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
{t("ReferDialog.button-refer")}
</Button>
</DialogActions>
</>
)
}
export default ReferPassengerBossContent

View File

@@ -0,0 +1,25 @@
import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"
import {useTranslations} from "next-intl";
import {useState} from "react";
import UTurnRightIcon from '@mui/icons-material/UTurnRight';
import ReferPassengerBossContent from "./ReferPassengerBossContent";
const ReferPassengerBoss = ({rowId, mutate}) => {
const t = useTranslations();
const [openReferDialog, setOpenReferDialog] = useState(false);
return (
<>
<Tooltip title={t("ReferDialog.refer-passenger-boss")}>
<IconButton color="primary" onClick={() => setOpenReferDialog(true)}>
<UTurnRightIcon/>
</IconButton>
</Tooltip>
<Dialog fullWidth open={openReferDialog}
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("ReferDialog.refer-passenger-boss")}</DialogTitle>
<ReferPassengerBossContent mutate={mutate} rowId={rowId} setOpenReferDialog={setOpenReferDialog}/>
</Dialog>
</>
)
}
export default ReferPassengerBoss

View File

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

View File

@@ -0,0 +1,10 @@
import {Stack} from "@mui/material";
const TableToolbar = ({table}) => {
return (
<Stack direction={"row"} spacing={2}>
</Stack>
)
}
export default TableToolbar

View File

@@ -0,0 +1,277 @@
import {useTranslations} from "next-intl";
import {useMemo} from "react";
import {Box, Typography} from "@mui/material";
import moment from "jalali-moment";
import MuiDatePicker from "@/core/components/MuiDatePicker";
import DataTable from "@/core/components/DataTable";
import {GET_LOAN_FOLLOWUP} from "@/core/data/apiRoutes";
import TableToolbar from "./TableToolbar";
import TableRowActions from "./TableRowActions";
function DashboardLoanFollowUpComponent () {
const t = useTranslations();
const columns = useMemo(
() => [
{
accessorFn: (row) => row.id,
id: "id",
header: t("LoanFollowUp.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("LoanFollowUp.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("LoanFollowUp.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("LoanFollowUp.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("LoanFollowUp.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.national_serial_number,
id: "national_serial_number",
header: t("LoanFollowUp.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.national_tracking_code,
id: "national_tracking_code",
header: t("LoanFollowUp.national_tracking_code"),
enableColumnFilter: true,
datatype: "text",
filterFn: "equals",
columnFilterModeOptions: [
"equals",
"notEquals",
"contains",
],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
},
{
accessorFn: (row) => row.birthday,
id: "birthday",
header: t("LoanFollowUp.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.approved_amount,
id: "approved_amount",
header: t("LoanFollowUp.approved_amount"),
enableColumnFilter: true,
datatype: "text",
filterFn: "equals",
columnFilterModeOptions: [
"equals",
"notEquals",
"contains",
],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{Number(renderedCellValue).toLocaleString()}</Typography>
),
},
{
accessorFn: (row) => row.branch_name,
id: "branch_name",
header: t("LoanFollowUp.branch_name"),
enableColumnFilter: true,
datatype: "text",
filterFn: "contains",
columnFilterModeOptions: ["contains", "equals", "notEquals"],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
},
{
accessorFn: (row) => row.province_name,
id: "province_name",
header: t("LoanFollowUp.province_name"),
enableColumnFilter: true,
datatype: "text",
filterFn: "contains",
columnFilterModeOptions: ["contains", "equals", "notEquals"],
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
},
{
accessorFn: (row) => row.city_name,
id: "city_name",
header: t("LoanFollowUp.city_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("LoanFollowUp.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("LoanFollowUp.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.state_name,
id: "state_id",
header: t("LoanFollowUp.state_name"),
enableColumnFilter: false,
datatype: "numeric",
Cell: ({renderedCellValue}) => (
<Typography variant="body2">{renderedCellValue}</Typography>
),
},
],
[]
);
return (
<Box sx={{px: 3}}>
<DataTable
tableUrl={GET_LOAN_FOLLOWUP}
columns={columns}
selectableRow={false}
enableCustomToolbar={true}
CustomToolbar={TableToolbar}
enableLastUpdate={true}
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 DashboardLoanFollowUpComponent

View File

@@ -0,0 +1,80 @@
import useNotification from "@/lib/app/hooks/useNotification";
import useRequest from "@/lib/app/hooks/useRequest";
import {Button, DialogActions, DialogContent, Stack, TextField} from "@mui/material"
import {useFormik} from "formik";
import {useTranslations} from "next-intl";
import * as Yup from "yup";
import {REFER_LOAN_FOLLOWUP_USER} from "@/core/data/apiRoutes";
const ReferUserContent = ({rowId, mutate, setOpenReferDialog}) => {
const t = useTranslations();
const requestServer = useRequest({auth: true})
const {update_notification} = useNotification()
const validationSchema = Yup.object().shape({
description: Yup.string().required(t("ReferDialog.description_error")),
});
const formik = useFormik({
initialValues: {
description: "",
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("expert_description", values.description);
requestServer(`${REFER_LOAN_FOLLOWUP_USER}/${rowId}`, 'post', {
data: formData,
}).then((response) => {
setOpenReferDialog(false)
mutate()
update_notification()
}).catch(() => {
}).finally(() => {
setSubmitting(false);
});
},
});
// const handleDescriptionChange = (event) => {
// formik.setFieldValue("description", event.target.value);
// formik.handleChange(event);
// };
return (
<>
<DialogContent>
<Stack spacing={2}>
<Stack>
<TextField
name="description"
multiline
rows={8}
label={t("ReferDialog.description")}
value={formik.values.description}
onChange={formik.handleChange}
onBlur={formik.handleBlur("description")}
error={
formik.touched.description && Boolean(formik.errors.description)
}
helperText={formik.touched.description && formik.errors.description}
fullWidth
variant="outlined"
sx={{mt: 1}}
/>
</Stack>
</Stack>
</DialogContent>
<DialogActions>
<Button onClick={() => setOpenReferDialog(false)} variant="outlined" color="secondary"
disabled={formik.isSubmitting} autoFocus>
{t("ReferDialog.button-cancel")}
</Button>
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
{t("ReferDialog.button-refer")}
</Button>
</DialogActions>
</>
)
}
export default ReferUserContent

View File

@@ -0,0 +1,24 @@
import {Dialog,DialogTitle, IconButton, Tooltip} from "@mui/material"
import {useTranslations} from "next-intl";
import {useState} from "react";
import ContactMailIcon from '@mui/icons-material/ContactMail';
import ReferUserContent from "@/components/dashboard/passenger-boss/Form/ReferUser/ReferUserContent";
const ReferUser = ({rowId, mutate}) => {
const t = useTranslations();
const [openReferDialog, setOpenReferDialog] = useState(false);
return (
<>
<Tooltip title={t("ReferDialog.refer-user")}>
<IconButton color="primary" onClick={() => setOpenReferDialog(true)}>
<ContactMailIcon/>
</IconButton>
</Tooltip>
<Dialog fullWidth open={openReferDialog}
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("ReferDialog.refer-user")}</DialogTitle>
<ReferUserContent mutate={mutate} rowId={rowId} setOpenReferDialog={setOpenReferDialog} />
</Dialog>
</>
)
}
export default ReferUser

View File

@@ -3,11 +3,16 @@ import Reject from "./Form/RejectForm"
import Confirm from "./Form/ConfirmForm";
import ReserveForm from "@/components/dashboard/passenger-boss/Form/ReserveForm";
import ReferReason from "@/components/dashboard/passenger-boss/Form/ReferReason";
import ReferUser from "@/components/dashboard/passenger-boss/Form/ReferUser";
const TableRow = ({row, mutate}) => {
return (
<Box sx={{display: "flex", flexWrap: "nowrap", gap: "8px"}}>
{row.original.latest_history?.action === "refer" ? <ReferReason row={row}/> : null}
<ReferUser
rowId={row.getValue("id")}
mutate={mutate}
/>
<Confirm
rowId={row.getValue("id")}
vehicle_type={row.original.vehicle_type}

View File

@@ -31,7 +31,8 @@ export const EXPORT_PASSENGER_OFFICE =
//passenger boss
export const GET_PASSENGER_BOSS =
BASE_URL + "/dashboard/province_working_group/show";
export const REFER_LOAN_FOLLOWUP_USER =
BASE_URL + "/dashboard/province_working_group/refer_to_user";
export const CONFIRM_PASSENGER_BOSS =
BASE_URL + "/dashboard/province_working_group/confirm";
@@ -45,6 +46,12 @@ export const EXPORT_PASSENGER_BOSS_DETAILS =
BASE_URL + "/dashboard/province_working_group";
//passenger boss
//loan follow up
export const GET_LOAN_FOLLOWUP =
BASE_URL + "/dashboard/vezarat_loan_tracking/";
export const REFER_LOAN_FOLLOWUP_PASSENGERBOSS =
BASE_URL + "/dashboard/vezarat_loan_tracking/refer";
//transportation assistance
export const GET_TRANSPORTATION_ASSISTANCE =
BASE_URL + "/dashboard/transportation_assistant/show";

View File

@@ -16,6 +16,7 @@ import SecurityIcon from '@mui/icons-material/Security';
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';
const sidebarMenu = [
[
@@ -45,6 +46,15 @@ const sidebarMenu = [
selected: false,
permissions: ["view_navgan_loans", "view_navgan_loans_province"],
},
{
key: "sidebar.loan-followup",
name: "loan-followup",
type: "page",
route: "/dashboard/loan-followup",
icon: <RepeatIcon sx={{width: 'inherit', height: 'inherit'}}/>,
selected: false,
permissions: ["manage_vezarat_eghtesad_loans"], //permission should change
},
], [
{
key: "sidebar.reserve-loan",

View File

@@ -0,0 +1,21 @@
import {parse} from "next-useragent";
import DashboardLoanFollowUpComponent from "@/components/dashboard/loan-followup";
export default function LoanFollowUp() {
return (
<DashboardLoanFollowUpComponent/>
);
}
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_followup",
isBot,
locale,
layout: {name: 'DashboardLayout', props: {permissions: ["manage_vezarat_eghtesad_loans"]}} //permission should change
},
};
}