From 30753bb22729b381006968363ab391d3a68be452 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Wed, 7 Feb 2024 17:13:34 +0330 Subject: [PATCH] add reserve_loan --- public/locales/fa/app.json | 18 +- .../Form/ReserveForm/index.jsx | 75 ++++ .../machinary-office/TableRowActions.jsx | 5 + .../reserve-loan/Form/CanselReserve/index.jsx | 73 ++++ .../reserve-loan/TableRowActions.jsx | 15 + .../dashboard/reserve-loan/TableToolbar.jsx | 12 + .../dashboard/reserve-loan/index.jsx | 331 ++++++++++++++++++ src/core/data/apiRoutes.js | 9 + src/core/data/sidebarMenu.jsx | 11 + src/pages/dashboard/reserve-loan/index.jsx | 21 ++ 10 files changed, 568 insertions(+), 2 deletions(-) create mode 100644 src/components/dashboard/machinary-office/Form/ReserveForm/index.jsx create mode 100644 src/components/dashboard/reserve-loan/Form/CanselReserve/index.jsx create mode 100644 src/components/dashboard/reserve-loan/TableRowActions.jsx create mode 100644 src/components/dashboard/reserve-loan/TableToolbar.jsx create mode 100644 src/components/dashboard/reserve-loan/index.jsx create mode 100644 src/pages/dashboard/reserve-loan/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 53699b0..1b9c3c5 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -62,7 +62,8 @@ "role-management": "مدیریت نقش ها", "edit-profile": "ویرایش پروفایل", "loan-history": "کارتابل نظارت", - "loan-history-province": "کارتابل نظارت استانی" + "loan-history-province": "کارتابل نظارت استانی", + "reserve-loan" : "وام های رزرو" }, "secondary": { "passenger-office": "توزیع درخواست", @@ -115,6 +116,7 @@ "passenger_office_page": "اداره مسافر", "loan_management_page": "مدیریت وام", "machinary_office_page": "کارتابل کارشناسی", + "reserve_loans": "وام های رزرو", "development_assistant_page": "معاون توسعه", "inspector_expert_page": "بازدید کارشناس", "commercial_chief_page": "رئیس اداره بازرگانی", @@ -411,7 +413,19 @@ "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", "print_report": "چاپ گزارش کارشناسی", "max_amount": "حداکثر مبلغ پیشنهادی {value} میلیون ریال می باشد", - "excel_report": "گزارش اکسل" + "excel_report": "گزارش اکسل", + "reserve-loan-title" : "رزرو وام", + "description-reserve-loan-first": "آیا از رزرو وام به کد یکتا", + "description-reserve-loan-second": "اطمینان دارید؟", + "button-reserve-cancel": "بستن", + "button-reserve-confirm": "رزرو" + }, + "ReserveLoan": { + "title": "لغو رزرو", + "description-loan-first": "آیا از لغو رزرو وام به کد یکتا", + "description-loan-second": "اطمینان دارید؟", + "button-cancel": "بستن", + "button-confirm": "لغو رزرو" }, "UserManagement": { "name": "نام", diff --git a/src/components/dashboard/machinary-office/Form/ReserveForm/index.jsx b/src/components/dashboard/machinary-office/Form/ReserveForm/index.jsx new file mode 100644 index 0000000..8056abc --- /dev/null +++ b/src/components/dashboard/machinary-office/Form/ReserveForm/index.jsx @@ -0,0 +1,75 @@ +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + IconButton, + Tooltip, Typography +} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; +import RepartitionIcon from '@mui/icons-material/Repartition'; +import useRequest from "@/lib/app/hooks/useRequest"; +import useNotification from "@/lib/app/hooks/useNotification"; +import {RESERVE_MACHINARY_LOAN} from "@/core/data/apiRoutes"; + +const ReserveForm = ({rowId, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + const requestServer = useRequest({auth: true, notification: false}); + const [isSubmitting, setIsSubmitting] = useState(false); + const {update_notification} = useNotification() + + const handleSubmit = () => { + setIsSubmitting(true) + requestServer(`${RESERVE_MACHINARY_LOAN}/${rowId}`, 'post').then((response) => { + setOpenConfirmDialog(false) + mutate() + update_notification() + }).catch(() => { + }).finally(() => { + setIsSubmitting(false) + }); + } + + return ( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + + {t("MachinaryOffice.reserve-loan-title")} + + + {t("MachinaryOffice.description-reserve-loan-first")} {rowId} {t("MachinaryOffice.description-reserve-loan-second")} + + + + + + + + ) + +} +export default ReserveForm; \ No newline at end of file diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx index f50938e..0e111cb 100644 --- a/src/components/dashboard/machinary-office/TableRowActions.jsx +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -1,6 +1,7 @@ import {Box} from "@mui/material"; import Confirm from "./Form/ConfirmForm"; import Reject from "./Form/RejectForm"; +import ReserveForm from "@/components/dashboard/machinary-office/Form/ReserveForm"; const TableRow = ({row, mutate}) => { return ( @@ -10,6 +11,10 @@ const TableRow = ({row, mutate}) => { vehicle_type={row.original.vehicle_type} mutate={mutate} /> + { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + const requestServer = useRequest({auth: true, notification: false}); + const [isSubmitting, setIsSubmitting] = useState(false) + + const handleSubmit = () => { + setIsSubmitting(true) + requestServer(`${CANSEL_RESERVE_MACHINARY_LOAN}/${rowId}`, 'get').then((response) => { + setOpenConfirmDialog(false) + mutate() + update_notification() + }).catch(() => { + }).finally(() => { + setIsSubmitting(false) + }); + } + + return ( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + + {t("ReserveLoan.title")} + + + {t("ReserveLoan.description-loan-first")} {rowId} {t("ReserveLoan.description-loan-second")} + + + + + + + + ) + +} +export default CanselReserve; \ No newline at end of file diff --git a/src/components/dashboard/reserve-loan/TableRowActions.jsx b/src/components/dashboard/reserve-loan/TableRowActions.jsx new file mode 100644 index 0000000..147ff26 --- /dev/null +++ b/src/components/dashboard/reserve-loan/TableRowActions.jsx @@ -0,0 +1,15 @@ +import {Box} from "@mui/material"; +import CanselReserve from "./Form/CanselReserve"; + +const TableRow = ({row, mutate}) => { + return ( + + {/**/} + + ); +}; + +export default TableRow; diff --git a/src/components/dashboard/reserve-loan/TableToolbar.jsx b/src/components/dashboard/reserve-loan/TableToolbar.jsx new file mode 100644 index 0000000..bd5e9e8 --- /dev/null +++ b/src/components/dashboard/reserve-loan/TableToolbar.jsx @@ -0,0 +1,12 @@ +import {Stack} from "@mui/material"; + + +const TableToolbar = ({table}) => { + return ( + + + + ) +} + +export default TableToolbar \ No newline at end of file diff --git a/src/components/dashboard/reserve-loan/index.jsx b/src/components/dashboard/reserve-loan/index.jsx new file mode 100644 index 0000000..06095b5 --- /dev/null +++ b/src/components/dashboard/reserve-loan/index.jsx @@ -0,0 +1,331 @@ +import {Box, Stack, Typography} from "@mui/material"; +import {useMemo} from "react"; +import {GET_RESERVE_MACHINARY_LOAN} 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 "@/components/dashboard/reserve-loan/TableToolbar"; + +function DashboardReserveLoan() { + const t = useTranslations(); + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("MachinaryOffice.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.score, + id: "score", + header: t("MachinaryOffice.score"), + 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("MachinaryOffice.is_legal_person"), + enableColumnFilter: false, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals"], + Cell: ({renderedCellValue}) => ( + {renderedCellValue === 1 ? `${t("MachinaryOffice.hoghoghi")}` : `${t("MachinaryOffice.haghighi")}`} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("MachinaryOffice.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("MachinaryOffice.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("MachinaryOffice.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("MachinaryOffice.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("MachinaryOffice.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("MachinaryOffice.city_name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => + moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "created_at", + header: t("MachinaryOffice.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("MachinaryOffice.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("MachinaryOffice.statement_count"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_capacity, + id: "navgan_capacity", + header: t("MachinaryOffice.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("MachinaryOffice.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("MachinaryOffice.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("MachinaryOffice.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.state_name, + id: "state_id", + header: t("MachinaryOffice.state_name"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + ], + [] + ); + return ( + + + + ); +} + +export default DashboardReserveLoan; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 94c0982..beb73fd 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -73,6 +73,15 @@ export const REJECT_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/reject"; export const EXPORT_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/export"; + + +export const GET_RESERVE_MACHINARY_LOAN = + BASE_URL + "/dashboard/machinery_expert/reserved/show"; +export const RESERVE_MACHINARY_LOAN = + BASE_URL + "/dashboard/machinery_expert/reserve"; + +export const CANSEL_RESERVE_MACHINARY_LOAN = + BASE_URL + "/dashboard/machinery_expert/unreserved"; //machinary office //commercial chief diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index cc32838..28b5a6d 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -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 RepartitionIcon from '@mui/icons-material/Repartition'; const sidebarMenu = [ [ @@ -66,6 +67,16 @@ const sidebarMenu = [ selected: false, permissions: ["manage_machinery_navgan"], }, + { + key: "sidebar.reserve-loan", + secondary: "secondary.navgan-province-manager", + name: "reserve_loan", + type: "page", + route: "/dashboard/reserve-loan", + icon: , + selected: false, + permissions: ["manage_machinery_navgan"], + }, { key: "sidebar.passenger-boss", secondary: "secondary.navgan-province-manager", diff --git a/src/pages/dashboard/reserve-loan/index.jsx b/src/pages/dashboard/reserve-loan/index.jsx new file mode 100644 index 0000000..9ab7f23 --- /dev/null +++ b/src/pages/dashboard/reserve-loan/index.jsx @@ -0,0 +1,21 @@ +import {parse} from "next-useragent"; +import DashboardReserveLoan from "@/components/dashboard/reserve-loan"; + +export default function PassengerOffice() { + 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.reserve_loans", + isBot, + locale, + layout: {name: 'DashboardLayout', props: {permissions: ["manage_machinery_navgan"]}} + }, + }; +}