diff --git a/.env.local.example b/.env.local.example index 338efc7..bc09fef 100644 --- a/.env.local.example +++ b/.env.local.example @@ -8,6 +8,8 @@ NEXT_PUBLIC_SECONDARY_MAIN = "#FF4E00" NEXT_PUBLIC_FACILITY_BANK = 33 NEXT_PUBLIC_FACILITY_PERSON = 10 +NEXT_PUBLIC_BUS_AMOUNT=10000 +NEXT_PUBLIC_MINIBUS_AMOUNT=4000 NEXT_PUBLIC_BASE_URL = "https://loan-v2.witel.ir" NEXT_PUBLIC_POWERED_BY_URL = "https://witel.ir" diff --git a/.eslintrc.json b/.eslintrc.json index bffb357..35823c0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,3 @@ { - "extends": "next/core-web-vitals" + "extends" : ["next/core-web-vitals","prettier"] } diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..434e674 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "printWidth": 120, + "tabWidth": 4, + "useTabs": false, + "semi": true, + "singleQuote": false, + "trailingComma": "es5", + "bracketSpacing": true, + "jsxBracketSameLine": false, + "arrowParens": "always", + "endOfLine": "crlf" +} diff --git a/package.json b/package.json index b06961c..1b1b455 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "start": "next start", "publish-3002": "next start -p 3002", "lint": "next lint", + "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,html,css,scss}\"", "test": "jest", "test:watch": "jest --watchAll", "cypress:open": "cypress open", @@ -41,6 +42,7 @@ "next-intl": "^2.13.1", "next-useragent": "^2.8.0", "nextjs-progressbar": "^0.0.16", + "prettier": "^3.3.3", "prop-types": "^15.8.1", "react": "^18.2.0", "react-apexcharts": "^1.4.1", @@ -67,4 +69,4 @@ "next-router-mock": "^0.9.10", "run-script-os": "^1.1.6" } -} \ No newline at end of file +} diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 30668f6..0ab64cf 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -267,7 +267,7 @@ "upload_expert_file_required": "وارد کردن گزارش کارشناسی الزامیست", "upload_expert_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد", "upload_expert_file_format": "فرمت قابل قبول : png,jpg,pdf", - "max_amount": "حداکثر مبلغ تصویب شده {value} میلیون ریال می باشد", + "max_amount": "حداکثر مبلغ تصویب شده {value} {amount} ریال می باشد", "excel_report": "گزارش اکسل", "first_form": "فرم الف را بارگذاری کنید", "second_form": "فرم ب را بارگذاری کنید" @@ -599,6 +599,7 @@ "participation_period_number": "دوره مشارکت باید عدد باشد", "tanafos_period_number": "دوره تنفس باید عدد باشد", "toman": "میلیون تومان", + "milyard_toman": "میلیارد تومان", "facility_bank_max_amount": "جمع مبلغ سهم دولت و سهم بانک نباید از مبلغ تصویب شده بیشتر باشد .", "facility_gov_max_amount": "جمع مبلغ سهم دولت و سهم بانک نباید از مبلغ تصویب شده بیشتر باشد .", "tanafos_period_month": "ماه", @@ -662,7 +663,7 @@ "unit": " (میلیون ریال)", "button-revise": "ارسال", "approved_amount_positive": "مبلغ مصوب باید مثبت باشد", - "max_amount": "حداکثر مبلغ مصوب {value} میلیون ریال می باشد", + "max_amount": "حداکثر مبلغ مصوب {value} {amount} ریال می باشد", "approved_amount_number": "مبلغ مصوب باید عدد باشد", "description": "توضیحات خود را وارد نمائید" }, @@ -780,6 +781,60 @@ "typography": "آیا از حدف این مورد اطمینان دارید ؟", "button-delete": "حذف کردن" }, + "UserInfoDialog": { + "user_info": "اطلاعات درخواست کاربر", + "user_info_tooltip" : "اطلاعات کاربر", + "applicant_payment" : "آورده متقاضی", + "id" : "کد یکتا", + "toman" : "{value} میلیون ریال", + "milyard" : "{value} میلیارد ریال", + "user_committed_employment" :"تعداد اشتغال متعهد متقاضی", + "user_existing_employment" : "تعداد اشتغال موجود متقاضی", + "phone_number": "شماره تلفن", + "requested_facilities" : "تسهیلات مورد تقاضا", + "physical_progress" : "درصد پیشرفت فیزیکی", + "investment" : "سرمایه گذاری انجام شده", + "no_info" : "اطلاعاتی موجود نیست !!!", + "is_legal_person": "نوع شخص", + "legal_person" : "شخص حقوقی", + "real_person" : "شخص حقیقی", + "activity_type": "نوع فعالیت", + "navgan_plan_id": "عنوان پروژه", + "shenasname_serial": "سریال پشت کارت ملی", + "national_tracking_code": "کد رهگیری کارت ملی", + "national_id": "کد ملی", + "boss_national_id": "کد ملی مدیر عامل", + "register_number": "شماره ثبت شرکت", + "postal_code": "کد پستی", + "national_serial_number": "سریال پشت کارت ملی", + "address": "آدرس", + "committed_employment": "اشتغال ایجاد شده", + "existing_employment": "اشتغال موجود", + "plate" : "پلاک", + "male" : "مرد", + "female" : "زن", + "IRAN" : "ایران", + "company_name": "نام شرکت", + "company_register_date": "تاریخ ثبت شرکت", + "father_name": "نام پدر", + "birthday": "تاریخ تولد", + "navgan_id": "کد ناوگان", + "province_id": "استان", + "city_id": "شهر", + "boss_father_name": "نام پدر مدیر عامل", + "education_id": "تحصیلات", + "occupation_id": "شغل", + "navgan_type": "نوع ناوگان", + "shenase_meli": "شناسه ملی شرکت", + "first_name": "نام", + "boss_first_name": "نام مدیر عامل", + "boss_last_name": "نام خانوادگی مدیر عامل", + "gender": "جنسیت", + "last_name": "نام خانوادگی", + "vehicle_type": "نوع وسیله", + "tel_number": "شماره ثابت (با پیش شماره استان)", + "button-cancel": "بستن" + }, "ReferDialog": { "refer-passenger-boss": "ارجاع به کارگروه", "refer-user": "ارجاع به کاربر", @@ -916,5 +971,61 @@ "Table_head_refer_reason": "علت ارجاع", "Table_head_expert_description": "توضیحات", "empty_history_detail": "سابقه ای برای این وام وجود ندارد" + }, + "CouncilHistory": { + "id": "کد یکتا", + "name": "نام", + "close": "بستن", + "more": "بیشتر", + "council_opinion": "نظر شورا برنامه ریزی :", + "council_history": "نتیجه شورای برنامه ریزی", + "council_history_detail": "نتیجه شورای برنامه ریزی", + "score": "اولویت", + "existing_employment": "اشتغال موجود", + "bank_facility": "سهم بانک", + "facility_bank": "سهم بانک", + "government_facility": "سهم دولت", + "facility_gov": "سهم دولت", + "user_facility": "سهم متقاضی", + "facility_person": "سهم متقاضی", + "physical_progress": "درصد پیشرفت فیزیکی", + "committed_employment": "اشتغال ایجاد شده", + "available_jobs": "اشتغال موجود", + "navgan_capacity": "ظرفیت", + "manufacture_date": "سال ساخت", + "shenase_meli": "شناسه ملی", + "is_legal_person": "نوع شخص", + "haghighi": "حقیقی", + "hoghoghi": "حقوقی", + "tanafos_period": "دوره تنفس", + "repayment_period": "دوره بازپرداخت", + "sakht_period": "دوره ساخت", + "national_id": "کد ملی", + "postal_code": "کد پستی", + "phone_number": "موبایل", + "proposed_amount": "مبلغ پیشنهادی", + "approved_amount": "مبلغ مصوب", + "created_at": "تاریخ درخواست", + "updated_at": "تاریخ بروزرسانی", + "navgan_id": "کد ناوگان", + "button-cancel": "بستن", + "vehicle_type": "نوع ماشین", + "state_name": "وضعیت درخواست", + "history": "تاریخچه", + "province_name": "استان", + "Table_history_error": "خطا در دریافت اطلاعات", + "history_report": "فایل ضمیمه", + "Table_head_name": "نام", + "Table_head_id": "کد یکتا", + "Table_head_date": "تاریخ", + "Table_head_planning_council_loan": "تاریخ", + "Table_head_position": "سمت", + "Table_head_council_comment": "توضیحات", + "Table_head_council_reason_name": "عملیات", + "Table_head_file": "فایل پیوست", + "Table_head_state": "وضعیت", + "Table_head_council_confirm": "وضعیت", + "Table_head_refer_reason": "علت ارجاع", + "Table_head_expert_description": "توضیحات" } } \ No newline at end of file diff --git a/src/components/dashboard/admin-setting/Form/CreateForm/CreateContent.jsx b/src/components/dashboard/admin-setting/Form/CreateForm/CreateContent.jsx index f10a97b..8b4b8b8 100644 --- a/src/components/dashboard/admin-setting/Form/CreateForm/CreateContent.jsx +++ b/src/components/dashboard/admin-setting/Form/CreateForm/CreateContent.jsx @@ -1,20 +1,17 @@ -import {Button, DialogActions, DialogContent, Stack, TextField} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { useTranslations } from "next-intl"; import useRequest from "@/lib/app/hooks/useRequest"; import * as Yup from "yup"; -import {useFormik} from "formik"; -import {ADD_ADMIN_SETTING} from "@/core/data/apiRoutes"; +import { useFormik } from "formik"; +import { ADD_ADMIN_SETTING } from "@/core/data/apiRoutes"; -const CreateContent = ({mutate, setOpenConfirmDialog}) => { +const CreateContent = ({ mutate, setOpenConfirmDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) + const requestServer = useRequest({ auth: true }); const validationSchema = Yup.object().shape({ - name: Yup.string("AddDialog.name_string") - .required(t("AddDialog.setting_name_error")), - name_fa: Yup.string("AddDialog.name_fa_string") - .required(t("AddDialog.setting_name_fa_error")), - value: Yup.string("AddDialog.value_string") - .required(t("AddDialog.value_error")), + name: Yup.string("AddDialog.name_string").required(t("AddDialog.setting_name_error")), + name_fa: Yup.string("AddDialog.name_fa_string").required(t("AddDialog.setting_name_fa_error")), + value: Yup.string("AddDialog.value_string").required(t("AddDialog.value_error")), }); const formik = useFormik({ @@ -22,22 +19,26 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { name: "", name_fa: "", value: "", - }, validationSchema, onSubmit: (values, {setSubmitting}) => { + }, + validationSchema, + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("name", values.name); formData.append("name_fa", values.name_fa); formData.append("value", values.value); - requestServer(ADD_ADMIN_SETTING, 'post', { + requestServer(ADD_ADMIN_SETTING, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -57,7 +58,7 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { onBlur={formik.handleBlur("name_fa")} error={formik.touched.name_fa && Boolean(formik.errors.name_fa)} helperText={formik.touched.name_fa && formik.errors.name_fa} - sx={{mt: 1}} + sx={{ mt: 1 }} /> @@ -72,7 +73,7 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { onBlur={formik.handleBlur("name")} error={formik.touched.name && Boolean(formik.errors.name)} helperText={formik.touched.name && formik.errors.name} - sx={{mt: 1}} + sx={{ mt: 1 }} /> @@ -86,22 +87,31 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { onBlur={formik.handleBlur("value")} error={formik.touched.value && Boolean(formik.errors.value)} helperText={formik.touched.value && formik.errors.value} - sx={{mt: 1}} + sx={{ mt: 1 }} /> - - - ) -} -export default CreateContent \ No newline at end of file + ); +}; +export default CreateContent; diff --git a/src/components/dashboard/admin-setting/Form/CreateForm/index.jsx b/src/components/dashboard/admin-setting/Form/CreateForm/index.jsx index 9d531d2..e40f86a 100644 --- a/src/components/dashboard/admin-setting/Form/CreateForm/index.jsx +++ b/src/components/dashboard/admin-setting/Form/CreateForm/index.jsx @@ -1,10 +1,10 @@ -import {Button, Dialog, DialogTitle, Stack, Tooltip} from "@mui/material"; +import { Button, Dialog, DialogTitle, Stack, Tooltip } from "@mui/material"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import CreateContent from "@/components/dashboard/admin-setting/Form/CreateForm/CreateContent"; -const CreateForm = ({mutate}) => { +const CreateForm = ({ mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); @@ -15,21 +15,28 @@ const CreateForm = ({mutate}) => { color="primary" variant="contained" size="small" - sx={{textTransform: "unset", alignSelf: "center"}} - startIcon={} + sx={{ textTransform: "unset", alignSelf: "center" }} + startIcon={} onClick={() => { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > {t("AddDialog.add")} - + {t("AddDialog.add")} - + - ) -} -export default CreateForm \ No newline at end of file + ); +}; +export default CreateForm; diff --git a/src/components/dashboard/admin-setting/Form/DeleteForm.jsx b/src/components/dashboard/admin-setting/Form/DeleteForm.jsx index b2fdead..9fc1897 100644 --- a/src/components/dashboard/admin-setting/Form/DeleteForm.jsx +++ b/src/components/dashboard/admin-setting/Form/DeleteForm.jsx @@ -1,5 +1,5 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import { Button, Dialog, @@ -8,29 +8,31 @@ import { DialogTitle, IconButton, Tooltip, - Typography + Typography, } from "@mui/material"; -import DeleteIcon from '@mui/icons-material/Delete'; -import {DELETE_ADMIN_SETTING} from "@/core/data/apiRoutes"; +import DeleteIcon from "@mui/icons-material/Delete"; +import { DELETE_ADMIN_SETTING } from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; import useNotification from "@/lib/app/hooks/useNotification"; -const Delete = ({rowId, mutate}) => { +const Delete = ({ 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 [isSubmitting, setIsSubmitting] = useState(false); + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const handleSubmit = () => { - setIsSubmitting(true) - requestServer(`${DELETE_ADMIN_SETTING}/${rowId}`, 'delete').then((response) => { - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setIsSubmitting(false) - }); - } + setIsSubmitting(true); + requestServer(`${DELETE_ADMIN_SETTING}/${rowId}`, "delete") + .then((response) => { + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setIsSubmitting(false); + }); + }; return ( <> @@ -38,25 +40,36 @@ const Delete = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("DeleteDialog.delete")} {t("DeleteDialog.typography")} - - @@ -64,4 +77,4 @@ const Delete = ({rowId, mutate}) => { ); }; -export default Delete; \ No newline at end of file +export default Delete; diff --git a/src/components/dashboard/admin-setting/Form/UpdateForm/UpdateContent.jsx b/src/components/dashboard/admin-setting/Form/UpdateForm/UpdateContent.jsx index f521ced..5285a87 100644 --- a/src/components/dashboard/admin-setting/Form/UpdateForm/UpdateContent.jsx +++ b/src/components/dashboard/admin-setting/Form/UpdateForm/UpdateContent.jsx @@ -1,23 +1,20 @@ -import {UPDATE_ADMIN_SETTING} from "@/core/data/apiRoutes"; +import { UPDATE_ADMIN_SETTING } from "@/core/data/apiRoutes"; 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 { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { +const UpdateContent = ({ row, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ - name: Yup.string("UpdateDialog.name_string") - .required(t("UpdateDialog.setting_name_error")), - name_fa: Yup.string("UpdateDialog.name_fa_string") - .required(t("UpdateDialog.setting_name_fa_error")), - value: Yup.string("UpdateDialog.value_string") - .required(t("UpdateDialog.value_error")), + name: Yup.string("UpdateDialog.name_string").required(t("UpdateDialog.setting_name_error")), + name_fa: Yup.string("UpdateDialog.name_fa_string").required(t("UpdateDialog.setting_name_fa_error")), + value: Yup.string("UpdateDialog.value_string").required(t("UpdateDialog.value_error")), }); const formik = useFormik({ @@ -25,21 +22,25 @@ const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { name: row.getValue("name"), name_fa: row.getValue("name_fa"), value: row.getValue("value"), - }, validationSchema, onSubmit: (values, {setSubmitting}) => { + }, + validationSchema, + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("name", values.name); formData.append("name_fa", values.name_fa); formData.append("value", values.value); - requestServer(`${UPDATE_ADMIN_SETTING}/${row.getValue("id")}`, 'post', { + requestServer(`${UPDATE_ADMIN_SETTING}/${row.getValue("id")}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); return ( @@ -58,7 +59,7 @@ const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { onBlur={formik.handleBlur("name_fa")} error={formik.touched.name_fa && Boolean(formik.errors.name_fa)} helperText={formik.touched.name_fa && formik.errors.name_fa} - sx={{mt: 1}} + sx={{ mt: 1 }} /> @@ -73,7 +74,7 @@ const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { onBlur={formik.handleBlur("name")} error={formik.touched.name && Boolean(formik.errors.name)} helperText={formik.touched.name && formik.errors.name} - sx={{mt: 1}} + sx={{ mt: 1 }} /> @@ -88,22 +89,31 @@ const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { onBlur={formik.handleBlur("value")} error={formik.touched.value && Boolean(formik.errors.value)} helperText={formik.touched.value && formik.errors.value} - sx={{mt: 1}} + sx={{ mt: 1 }} /> - - - ) -} -export default UpdateContent \ No newline at end of file + ); +}; +export default UpdateContent; diff --git a/src/components/dashboard/admin-setting/Form/UpdateForm/index.jsx b/src/components/dashboard/admin-setting/Form/UpdateForm/index.jsx index a00cd74..d85b573 100644 --- a/src/components/dashboard/admin-setting/Form/UpdateForm/index.jsx +++ b/src/components/dashboard/admin-setting/Form/UpdateForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import EditIcon from '@mui/icons-material/Edit'; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import EditIcon from "@mui/icons-material/Edit"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import UpdateContent from "./UpdateContent"; -const Update = ({row, mutate}) => { +const Update = ({ row, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,18 +13,25 @@ const Update = ({row, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("UpdateDialog.update")} - + - ) -} -export default Update \ No newline at end of file + ); +}; +export default Update; diff --git a/src/components/dashboard/admin-setting/TableRowActions.jsx b/src/components/dashboard/admin-setting/TableRowActions.jsx index 6bdd0fe..e2416ad 100644 --- a/src/components/dashboard/admin-setting/TableRowActions.jsx +++ b/src/components/dashboard/admin-setting/TableRowActions.jsx @@ -1,18 +1,12 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import Update from "src/components/dashboard/admin-setting/Form/UpdateForm"; import Delete from "@/components/dashboard/admin-setting/Form/DeleteForm"; -const TableRow = ({row, mutate}) => { +const TableRow = ({ row, mutate }) => { return ( - - - + + + ); }; diff --git a/src/components/dashboard/admin-setting/TableToolbar.jsx b/src/components/dashboard/admin-setting/TableToolbar.jsx index 007eb2f..0c77a75 100644 --- a/src/components/dashboard/admin-setting/TableToolbar.jsx +++ b/src/components/dashboard/admin-setting/TableToolbar.jsx @@ -1,11 +1,10 @@ -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import CreateForm from "@/components/dashboard/admin-setting/Form/CreateForm"; -function TableToolbar({mutate}) { +function TableToolbar({ mutate }) { const t = useTranslations(); - return - + return ; } export default TableToolbar; diff --git a/src/components/dashboard/admin-setting/index.jsx b/src/components/dashboard/admin-setting/index.jsx index 685c47a..4eabe91 100644 --- a/src/components/dashboard/admin-setting/index.jsx +++ b/src/components/dashboard/admin-setting/index.jsx @@ -1,7 +1,7 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_ADMIN_SETTING} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_ADMIN_SETTING } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import DataTable from "@/core/components/DataTable"; import TableRowActions from "@/components/dashboard/admin-setting/TableRowActions"; import TableToolbar from "@/components/dashboard/admin-setting/TableToolbar"; @@ -18,9 +18,7 @@ function DashboardAdminSettingComponent() { datatype: "number", filterFn: "equals", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name_fa, @@ -30,9 +28,7 @@ function DashboardAdminSettingComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -42,9 +38,7 @@ function DashboardAdminSettingComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.value, @@ -53,19 +47,14 @@ function DashboardAdminSettingComponent() { enableColumnFilter: true, datatype: "text", filterFn: "contains", - columnFilterModeOptions: [ - "equals", - "contains", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "contains"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +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 [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(); @@ -24,31 +24,33 @@ const PrintExcel = ({table}) => { } } return { - ...filter, fn: columnFilterFns[filter.id], datatype: datatype, + ...filter, + fn: columnFilterFns[filter.id], + datatype: datatype, }; }); - params.set("start", '0'); + params.set("start", "0"); params.set("filters", JSON.stringify(filters ?? [])); params.set("sorting", JSON.stringify(sorting ?? [])); return params; - }, [columnFilters, columnFilterFns, sorting, columns,]); - + }, [columnFilters, columnFilterFns, sorting, columns]); const clickHandler = () => { - setLoading(true) - requestServer(`${EXPORT_BANK_MANAGEMENT}?${filterParams}`, 'get', { + setLoading(true); + requestServer(`${EXPORT_BANK_MANAGEMENT}?${filterParams}`, "get", { auth: true, notification: false, - requestOptions: {responseType: 'blob'} - }).then((response) => { - const filename = `گزارش کارتابل نظارت بانک تاریخ_${moment().format('jYYYY_jMM_jDD')}.xlsx`; - FileSaver.saveAs(response.data, filename); - }).catch(() => { - }).finally(() => { - setLoading(false) + 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 \ No newline at end of file +export default PrintExcel; diff --git a/src/components/dashboard/bank-management/Form/Edit/EditContent.jsx b/src/components/dashboard/bank-management/Form/Edit/EditContent.jsx index 79b1961..e3dcd32 100644 --- a/src/components/dashboard/bank-management/Form/Edit/EditContent.jsx +++ b/src/components/dashboard/bank-management/Form/Edit/EditContent.jsx @@ -1,58 +1,80 @@ import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, Stack,} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {EDIT_APPROVED_AMOUNT} from "@/core/data/apiRoutes"; +import { Button, DialogActions, DialogContent, Stack } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { EDIT_APPROVED_AMOUNT } from "@/core/data/apiRoutes"; import * as Yup from "yup"; import PriceField from "@/core/components/PriceField"; const vehicle_amount = { - "اتوبوس": 7000, - "مینی بوس": 2000, -} + "اتوبوس": parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT), + "مینی بوس": parseInt(process.env.NEXT_PUBLIC_MINIBUS_AMOUNT), +}; -const EditContent = ({rowId, row, mutate, setOpenEditDialog, vehicle_type}) => { +const EditContent = ({ rowId, row, mutate, setOpenEditDialog, vehicle_type }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true, notification: false}); - const {update_notification} = useNotification(); + const requestServer = useRequest({ auth: true, notification: false }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ - approved_amount: Yup.mixed().test( - "is-number", - `${t("EditDialog.approved_amount_number")}`, - (value) => !isNaN(value) - ).test("max-amount", `${t("EditDialog.max_amount", {value: parseInt(vehicle_amount[vehicle_type]).toLocaleString('en')})}`, - (value) => value <= vehicle_amount[vehicle_type]) + approved_amount: Yup.mixed() + .test("is-number", `${t("EditDialog.approved_amount_number")}`, (value) => !isNaN(value)) + .test("max-amount", function (value) { + const maxAmount = + vehicle_type === "اتوبوس" + ? value > parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT) + ? parseInt(vehicle_amount[vehicle_type]) / 1000 + : parseInt(vehicle_amount[vehicle_type]) + : parseInt(vehicle_amount[vehicle_type]); + // Check the condition to set the message dynamically + const message = + vehicle_type === "اتوبوس" + ? value > parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT) && + `${t("EditDialog.max_amount", { + value: maxAmount.toLocaleString("en"), + amount: "میلیارد", + })}` + : value > parseInt(process.env.NEXT_PUBLIC_MINIBUS_AMOUNT) && + `${t("EditDialog.max_amount", { + value: maxAmount.toLocaleString("en"), + amount: "میلیارد", + })}`; + // Return either `true` (pass the validation) or `this.createError` with the message + return value <= maxAmount || this.createError({ message }); + }) .test("positive", `${t("EditDialog.approved_amount_positive")}`, (value) => value >= 0) .required(t("EditDialog.edit_approved_amount_required")), - }) + }); const formik = useFormik({ initialValues: { - approved_amount: String(row.original.approved_amount / 1000000) - }, validationSchema, - onSubmit: (values, {setSubmitting}) => { - requestServer(`${EDIT_APPROVED_AMOUNT}/${rowId}`, 'post', { + approved_amount: String(row.original.approved_amount / 1000000), + }, + validationSchema, + onSubmit: (values, { setSubmitting }) => { + requestServer(`${EDIT_APPROVED_AMOUNT}/${rowId}`, "post", { data: { - approved_amount: values.approved_amount + approved_amount: values.approved_amount, }, - notification: true - }).then(() => { - setOpenEditDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + notification: true, + }) + .then(() => { + setOpenEditDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleAmountChange = (event) => { if (!isNaN(event.target.value)) { - formik.setFieldValue("approved_amount", event.target.value) + formik.setFieldValue("approved_amount", event.target.value); } else { - formik.setFieldValue("approved_amount", formik.values.approved_amount) + formik.setFieldValue("approved_amount", formik.values.approved_amount); } }; return ( @@ -62,8 +84,12 @@ const EditContent = ({rowId, row, mutate, setOpenEditDialog, vehicle_type}) => { - {t("EditDialog.edit_approved_amount")}{t("EditDialog.unit")}} + label={ + <> + {t("EditDialog.edit_approved_amount")} + {t("EditDialog.unit")} + + } type="text" inputProps={{ inputMode: "number", @@ -74,32 +100,34 @@ const EditContent = ({rowId, row, mutate, setOpenEditDialog, vehicle_type}) => { value={formik.values.approved_amount} onChange={handleAmountChange} onBlur={formik.handleBlur("approved_amount")} - error={ - formik.touched.approved_amount && - Boolean(formik.errors.approved_amount) - } - helperText={ - formik.touched.approved_amount && formik.errors.approved_amount - } - sx={{mt: 1}} + error={formik.touched.approved_amount && Boolean(formik.errors.approved_amount)} + helperText={formik.touched.approved_amount && formik.errors.approved_amount} + sx={{ mt: 1 }} fullWidth /> - - - ) - -} -export default EditContent \ No newline at end of file + ); +}; +export default EditContent; diff --git a/src/components/dashboard/bank-management/Form/Edit/index.jsx b/src/components/dashboard/bank-management/Form/Edit/index.jsx index bc7a168..f59c71c 100644 --- a/src/components/dashboard/bank-management/Form/Edit/index.jsx +++ b/src/components/dashboard/bank-management/Form/Edit/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import EditIcon from '@mui/icons-material/Edit'; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import EditIcon from "@mui/icons-material/Edit"; import EditContent from "@/components/dashboard/bank-management/Form/Edit/EditContent"; -const EditForm = ({rowId, row, mutate, vehicle_type}) => { +const EditForm = ({ rowId, row, mutate, vehicle_type }) => { const t = useTranslations(); const [openEditDialog, setOpenEditDialog] = useState(false); @@ -14,27 +14,33 @@ const EditForm = ({rowId, row, mutate, vehicle_type}) => { { - setOpenEditDialog(true) + setOpenEditDialog(true); }} > - + - + {t("EditDialog.edit_approved_amount")} - ) - -} -export default EditForm; \ No newline at end of file + ); +}; +export default EditForm; diff --git a/src/components/dashboard/bank-management/Form/Reject/RejectContent.jsx b/src/components/dashboard/bank-management/Form/Reject/RejectContent.jsx index 7720503..c4222e0 100644 --- a/src/components/dashboard/bank-management/Form/Reject/RejectContent.jsx +++ b/src/components/dashboard/bank-management/Form/Reject/RejectContent.jsx @@ -1,30 +1,31 @@ -import UploadSystem from "@/core/components/UploadSystem" +import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import * as Yup from "yup"; -import {REJECT_BANK_MANAGEMENT} from "@/core/data/apiRoutes"; +import { REJECT_BANK_MANAGEMENT } from "@/core/data/apiRoutes"; -const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { +const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), - reject_img: Yup.mixed().notRequired(t("RejectDialog.choose_file")) - .test('fileSize', `${t("MachinaryOffice.upload_file_unit")}`, (value) => { + reject_img: Yup.mixed() + .notRequired(t("RejectDialog.choose_file")) + .test("fileSize", `${t("MachinaryOffice.upload_file_unit")}`, (value) => { return !value || (value.size && value.size <= 5 * 1024 * 1024); }) - .test('fileType', `${t("MachinaryOffice.upload_file_format")}`, (value) => { - const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types + .test("fileType", `${t("MachinaryOffice.upload_file_format")}`, (value) => { + const allowedTypes = ["image/jpg", "image/jpeg", "image/png", "application/pdf"]; // Define your allowed file types return !value || (value.type && allowedTypes.includes(value.type)); }), }); @@ -32,34 +33,36 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const formik = useFormik({ initialValues: { description: "", - reject_img: null + reject_img: null, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("expert_description", values.description); if (values.reject_img != null) { const attachments = [ { title: "فایل ضمیمه کارتابل نظارت بانک", - file: values.reject_img - } + file: values.reject_img, + }, ]; attachments.forEach((attachment, index) => { formData.append(`attachment[${index}][title]`, attachment.title); formData.append(`attachment[${index}][file]`, attachment.file); }); } - requestServer(`${REJECT_BANK_MANAGEMENT}/${rowId}`, 'post', { + requestServer(`${REJECT_BANK_MANAGEMENT}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenRejectDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenRejectDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -73,7 +76,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { setfileName(fileName); formik.setFieldValue("reject_img", uploadedFile).then(() => { formik.setFieldTouched("reject_img", true); - }) + }); setShowAddIcon(false); } }; @@ -90,17 +93,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { value={formik.values.description} onChange={formik.handleChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { setShowAddIcon={setShowAddIcon} showAddIcon={showAddIcon} onBlur={() => formik.handleBlur("reject_img")} - error={ - formik.touched.reject_img && - Boolean(formik.errors.reject_img) - } + error={formik.touched.reject_img && Boolean(formik.errors.reject_img)} /> - + {formik.touched.reject_img && formik.errors.reject_img} - - - ) -} -export default RejectContent \ No newline at end of file + ); +}; +export default RejectContent; diff --git a/src/components/dashboard/bank-management/Form/Reject/index.jsx b/src/components/dashboard/bank-management/Form/Reject/index.jsx index c5ea413..54f8178 100644 --- a/src/components/dashboard/bank-management/Form/Reject/index.jsx +++ b/src/components/dashboard/bank-management/Form/Reject/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import RejectContent from "./RejectContent"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -const RejectForm = ({rowId, mutate}) => { +const RejectForm = ({ rowId, mutate }) => { const t = useTranslations(); const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> setOpenRejectDialog(true)}> - + - + {t("RejectDialog.bank_management_reject")} - + - ) -} -export default RejectForm \ No newline at end of file + ); +}; +export default RejectForm; diff --git a/src/components/dashboard/bank-management/Form/Update.jsx b/src/components/dashboard/bank-management/Form/Update.jsx index 659ba1b..7342fca 100644 --- a/src/components/dashboard/bank-management/Form/Update.jsx +++ b/src/components/dashboard/bank-management/Form/Update.jsx @@ -1,5 +1,5 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import { Button, Dialog, @@ -8,30 +8,32 @@ import { DialogTitle, IconButton, Tooltip, - Typography + Typography, } from "@mui/material"; -import RefreshIcon from '@mui/icons-material/Refresh'; +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"; +import { RESEND_BANK_STATEMENT } from "@/core/data/apiRoutes"; -const UpdateForm = ({rowId, mutate}) => { +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 [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) - }); - } + setIsSubmitting(true); + requestServer(`${RESEND_BANK_STATEMENT}/${rowId}`, "post") + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setIsSubmitting(false); + }); + }; return ( <> @@ -39,25 +41,36 @@ const UpdateForm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("UpdateDialog.resend")} {t("UpdateDialog.typography")} - - @@ -65,4 +78,4 @@ const UpdateForm = ({rowId, mutate}) => { ); }; -export default UpdateForm; \ No newline at end of file +export default UpdateForm; diff --git a/src/components/dashboard/bank-management/TableRowActions.jsx b/src/components/dashboard/bank-management/TableRowActions.jsx index d11d62e..14c32ed 100644 --- a/src/components/dashboard/bank-management/TableRowActions.jsx +++ b/src/components/dashboard/bank-management/TableRowActions.jsx @@ -1,35 +1,23 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import UpdateForm from "@/components/dashboard/bank-management/Form/Update"; import EditForm from "@/components/dashboard/bank-management/Form/Edit"; import RejectForm from "@/components/dashboard/bank-management/Form/Reject"; -const TableRow = ({row, mutate}) => { +const TableRow = ({ row, mutate }) => { return ( - + {(row.original.bank_status == 0 || (row.original.bank_status == 1 && row.original.bank_state == 8)) && ( - + )} + {row.original.bank_state == 8 && } + {row.original.bank_state == 8 && ( + )} - { - row.original.bank_state == 8 && ( - - ) - } - { - row.original.bank_state == 8 && ( - - ) - } ); }; diff --git a/src/components/dashboard/bank-management/TableToobar.jsx b/src/components/dashboard/bank-management/TableToobar.jsx index 8de0761..95a9ad4 100644 --- a/src/components/dashboard/bank-management/TableToobar.jsx +++ b/src/components/dashboard/bank-management/TableToobar.jsx @@ -1,13 +1,12 @@ -import {Stack} from "@mui/material"; +import { Stack } from "@mui/material"; import PrintExcel from "@/components/dashboard/bank-management/Buttons/printExcel"; -const TableToolbar = ({table}) => { - +const TableToolbar = ({ table }) => { return ( - + - ) -} + ); +}; -export default TableToolbar \ No newline at end of file +export default TableToolbar; diff --git a/src/components/dashboard/bank-management/index.jsx b/src/components/dashboard/bank-management/index.jsx index b91ffb8..7b75088 100644 --- a/src/components/dashboard/bank-management/index.jsx +++ b/src/components/dashboard/bank-management/index.jsx @@ -1,10 +1,10 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {useTranslations} from "next-intl"; +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"; +import { GET_BANK_STATEMENT } from "@/core/data/apiRoutes"; import TableToolbar from "@/components/dashboard/bank-management/TableToobar"; function DashboardBankManagementComponent() { @@ -18,17 +18,8 @@ function DashboardBankManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.navgan_id, @@ -37,17 +28,8 @@ function DashboardBankManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -57,9 +39,7 @@ function DashboardBankManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -68,17 +48,8 @@ function DashboardBankManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_serial_number, @@ -87,17 +58,8 @@ function DashboardBankManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_tracking_code, @@ -106,14 +68,8 @@ function DashboardBankManagementComponent() { enableColumnFilter: true, datatype: "text", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.birthday, @@ -123,9 +79,10 @@ function DashboardBankManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {moment(renderedCellValue).locale("fa").format("yyyy/MM/DD")} + Cell: ({ renderedCellValue }) => ( + + {moment(renderedCellValue).locale("fa").format("yyyy/MM/DD")} + ), }, { @@ -135,12 +92,8 @@ function DashboardBankManagementComponent() { enableColumnFilter: true, datatype: "text", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - ], - Cell: ({renderedCellValue}) => ( + columnFilterModeOptions: ["equals", "notEquals", "contains"], + Cell: ({ renderedCellValue }) => ( {Number(renderedCellValue).toLocaleString()} ), }, @@ -151,15 +104,8 @@ function DashboardBankManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => ( {Number(renderedCellValue).toLocaleString()} ), }, @@ -171,9 +117,7 @@ function DashboardBankManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.bank_state_name, @@ -182,14 +126,8 @@ function DashboardBankManagementComponent() { enableColumnFilter: true, datatype: "text", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.bank_reason_description, @@ -198,20 +136,14 @@ function DashboardBankManagementComponent() { enableColumnFilter: true, datatype: "text", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), - } + columnFilterModeOptions: ["equals", "notEquals", "contains"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, ], [] ); return ( - + { +const ChangePasswordForm = ({ onSubmit }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) + const requestServer = useRequest({ auth: true }); - const handleSubmit = (values, {setSubmitting, resetForm}) => { - requestServer(SET_USER_PASSWORD, 'post', { + const handleSubmit = (values, { setSubmitting, resetForm }) => { + requestServer(SET_USER_PASSWORD, "post", { data: { current_password: values.current_password, new_password: values.new_password, new_password_confirmation: values.new_password_confirmation, }, - }).then((response) => { - resetForm(); - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + resetForm(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }; const initialValues = { current_password: "", @@ -31,15 +33,10 @@ const ChangePasswordForm = ({onSubmit}) => { new_password_confirmation: "", }; const validationSchema = Yup.object().shape({ - current_password: Yup.string().required( - t("ChangePassword.error_message_current_password") - ), + current_password: Yup.string().required(t("ChangePassword.error_message_current_password")), new_password: Yup.string() .required(t("ExpertMangement.error_message_new_password")) - .matches( - /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/, - t("ExpertMangement.error_message_new_password_regex") - ), + .matches(/^(?=.*[a-zA-Z])(?=.*\d).{8,}$/, t("ExpertMangement.error_message_new_password_regex")), new_password_confirmation: Yup.string() .required(t("ChangePassword.error_message_confirm_password")) .test( @@ -52,11 +49,7 @@ const ChangePasswordForm = ({onSubmit}) => { }); return ( - + {(props) => ( { @@ -65,7 +58,7 @@ const ChangePasswordForm = ({onSubmit}) => { }} > - + {t("ChangePassword.typography_change_password")} @@ -74,30 +67,17 @@ const ChangePasswordForm = ({onSubmit}) => { name="current_password" label={t("ChangePassword.label_current_password")} error={ - props.touched.current_password && - props.errors.current_password - ? true - : false - } - helperText={ - props.touched.current_password - ? props.errors.current_password - : null + props.touched.current_password && props.errors.current_password ? true : false } + helperText={props.touched.current_password ? props.errors.current_password : null} /> @@ -137,4 +117,4 @@ const ChangePasswordForm = ({onSubmit}) => { ); }; -export default ChangePasswordForm; \ No newline at end of file +export default ChangePasswordForm; diff --git a/src/components/dashboard/change-password/index.jsx b/src/components/dashboard/change-password/index.jsx index c62d127..ce706e9 100644 --- a/src/components/dashboard/change-password/index.jsx +++ b/src/components/dashboard/change-password/index.jsx @@ -1,12 +1,12 @@ import CenterLayout from "@/layouts/CenterLayout"; -import {Container} from "@mui/material"; +import { Container } from "@mui/material"; import ChangePasswordForm from "@/components/dashboard/change-password/change-password-form"; const DashboardChangePasswordComponent = () => { return ( - + ); diff --git a/src/components/dashboard/commercial-chief/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/commercial-chief/Form/ConfirmForm/ConfirmContent.jsx index 05de17e..066d4d5 100644 --- a/src/components/dashboard/commercial-chief/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/commercial-chief/Form/ConfirmForm/ConfirmContent.jsx @@ -1,47 +1,49 @@ import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {CONFIRM_COMMERCIAL_CHIEF} from "@/core/data/apiRoutes"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { CONFIRM_COMMERCIAL_CHIEF } from "@/core/data/apiRoutes"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import {useState} from "react"; +import { useState } from "react"; -const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { +const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const formik = useFormik({ initialValues: { description: "", - confirm_img: null + confirm_img: null, }, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); if (values.description != "") formData.append("description", values.description); if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - requestServer(`${CONFIRM_COMMERCIAL_CHIEF}/${rowId}`, 'post', { + requestServer(`${CONFIRM_COMMERCIAL_CHIEF}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - update_notification() - mutate() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + update_notification(); + mutate(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) + formik.setFieldValue("description", event.target.value); }; const handleUploadChange = (event) => { @@ -73,17 +75,24 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { name="description" multiline rows={8} - label={<> - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} + label={ + <> + {t("ConfirmDialog.description")} + {t("ConfirmDialog.optional")} + + } value={formik.values.description} onChange={handleDescriptionChange} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) - -} -export default ConfirmContent \ No newline at end of file + ); +}; +export default ConfirmContent; diff --git a/src/components/dashboard/commercial-chief/Form/ConfirmForm/index.jsx b/src/components/dashboard/commercial-chief/Form/ConfirmForm/index.jsx index 95a6367..e849196 100644 --- a/src/components/dashboard/commercial-chief/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/commercial-chief/Form/ConfirmForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import {useState} from "react"; +import { useState } from "react"; import ConfirmContent from "./ConfirmContent"; -const Confirm = ({rowId, mutate}) => { +const Confirm = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,19 +13,25 @@ const Confirm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("ConfirmDialog.confirm")} - + - ) - -} -export default Confirm; \ No newline at end of file + ); +}; +export default Confirm; diff --git a/src/components/dashboard/commercial-chief/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/commercial-chief/Form/RejectForm/RejectContent.jsx index 7f065ee..ba4e6b6 100644 --- a/src/components/dashboard/commercial-chief/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/commercial-chief/Form/RejectForm/RejectContent.jsx @@ -1,21 +1,21 @@ -import UploadSystem from "@/core/components/UploadSystem" +import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import * as Yup from "yup"; -import {REJECT_COMMERCIAL_CHIEF} from "@/core/data/apiRoutes"; +import { REJECT_COMMERCIAL_CHIEF } from "@/core/data/apiRoutes"; -const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { +const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), @@ -24,24 +24,26 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const formik = useFormik({ initialValues: { description: "", - reject_img: null + reject_img: null, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("description", values.description); if (values.reject_img != null) formData.append("attachment", values.reject_img); - requestServer(`${REJECT_COMMERCIAL_CHIEF}/${rowId}`, 'post', { + requestServer(`${REJECT_COMMERCIAL_CHIEF}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenRejectDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenRejectDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -80,17 +82,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) -} -export default RejectContent \ No newline at end of file + ); +}; +export default RejectContent; diff --git a/src/components/dashboard/commercial-chief/Form/RejectForm/index.jsx b/src/components/dashboard/commercial-chief/Form/RejectForm/index.jsx index 06608f5..a04d0e1 100644 --- a/src/components/dashboard/commercial-chief/Form/RejectForm/index.jsx +++ b/src/components/dashboard/commercial-chief/Form/RejectForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import RejectContent from "./RejectContent"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -const Reject = ({rowId, mutate}) => { +const Reject = ({ rowId, mutate }) => { const t = useTranslations(); const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> setOpenRejectDialog(true)}> - + - + {t("RejectDialog.reject")} - + - ) -} -export default Reject \ No newline at end of file + ); +}; +export default Reject; diff --git a/src/components/dashboard/commercial-chief/TableRowActions.jsx b/src/components/dashboard/commercial-chief/TableRowActions.jsx index 36fb1e5..fa9e1ef 100644 --- a/src/components/dashboard/commercial-chief/TableRowActions.jsx +++ b/src/components/dashboard/commercial-chief/TableRowActions.jsx @@ -1,18 +1,12 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import Confirm from "./Form/ConfirmForm"; import Reject from "./Form/RejectForm"; -const TableRow = ({row, mutate}) => { +const TableRow = ({ row, mutate }) => { return ( - - - + + + ); }; diff --git a/src/components/dashboard/commercial-chief/index.jsx b/src/components/dashboard/commercial-chief/index.jsx index 9caaa36..3528fea 100644 --- a/src/components/dashboard/commercial-chief/index.jsx +++ b/src/components/dashboard/commercial-chief/index.jsx @@ -1,7 +1,7 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_COMMERCIAL_CHIEF} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_COMMERCIAL_CHIEF } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import moment from "jalali-moment"; import DataTable from "@/core/components/DataTable"; @@ -18,17 +18,8 @@ function DashboardCommercialChiefComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -38,9 +29,7 @@ function DashboardCommercialChiefComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -49,17 +38,8 @@ function DashboardCommercialChiefComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.phone_number, @@ -68,47 +48,32 @@ function DashboardCommercialChiefComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("CommercialChief.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "updated_at", header: t("CommercialChief.updated_at"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -116,28 +81,29 @@ function DashboardCommercialChiefComponent() { header: t("CommercialChief.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const formik = useFormik({ initialValues: { description: "", - confirm_img: null + confirm_img: null, }, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); if (values.description != "") formData.append("description", values.description); if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - requestServer(`${CONFIRM_DEVELOPMENT_ASSISTANT}/${rowId}`, 'post', { + requestServer(`${CONFIRM_DEVELOPMENT_ASSISTANT}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) + formik.setFieldValue("description", event.target.value); }; const handleUploadChange = (event) => { @@ -73,17 +75,24 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { name="description" multiline rows={8} - label={<> - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} + label={ + <> + {t("ConfirmDialog.description")} + {t("ConfirmDialog.optional")} + + } value={formik.values.description} onChange={handleDescriptionChange} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) - -} -export default ConfirmContent \ No newline at end of file + ); +}; +export default ConfirmContent; diff --git a/src/components/dashboard/development-assistant/Form/ConfirmForm/index.jsx b/src/components/dashboard/development-assistant/Form/ConfirmForm/index.jsx index 95a6367..e849196 100644 --- a/src/components/dashboard/development-assistant/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/development-assistant/Form/ConfirmForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import {useState} from "react"; +import { useState } from "react"; import ConfirmContent from "./ConfirmContent"; -const Confirm = ({rowId, mutate}) => { +const Confirm = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,19 +13,25 @@ const Confirm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("ConfirmDialog.confirm")} - + - ) - -} -export default Confirm; \ No newline at end of file + ); +}; +export default Confirm; diff --git a/src/components/dashboard/development-assistant/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/development-assistant/Form/RejectForm/RejectContent.jsx index b45da82..8878e72 100644 --- a/src/components/dashboard/development-assistant/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/development-assistant/Form/RejectForm/RejectContent.jsx @@ -1,21 +1,21 @@ -import UploadSystem from "@/core/components/UploadSystem" +import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import * as Yup from "yup"; -import {REJECT_DEVELOPMENT_ASSISTANT} from "@/core/data/apiRoutes"; +import { REJECT_DEVELOPMENT_ASSISTANT } from "@/core/data/apiRoutes"; -const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { +const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), @@ -24,24 +24,26 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const formik = useFormik({ initialValues: { description: "", - reject_img: null + reject_img: null, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("description", values.description); if (values.reject_img != null) formData.append("attachment", values.reject_img); - requestServer(`${REJECT_DEVELOPMENT_ASSISTANT}/${rowId}`, 'post', { + requestServer(`${REJECT_DEVELOPMENT_ASSISTANT}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenRejectDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenRejectDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -80,17 +82,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) -} -export default RejectContent \ No newline at end of file + ); +}; +export default RejectContent; diff --git a/src/components/dashboard/development-assistant/Form/RejectForm/index.jsx b/src/components/dashboard/development-assistant/Form/RejectForm/index.jsx index 06608f5..a04d0e1 100644 --- a/src/components/dashboard/development-assistant/Form/RejectForm/index.jsx +++ b/src/components/dashboard/development-assistant/Form/RejectForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import RejectContent from "./RejectContent"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -const Reject = ({rowId, mutate}) => { +const Reject = ({ rowId, mutate }) => { const t = useTranslations(); const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> setOpenRejectDialog(true)}> - + - + {t("RejectDialog.reject")} - + - ) -} -export default Reject \ No newline at end of file + ); +}; +export default Reject; diff --git a/src/components/dashboard/development-assistant/TableRowActions.jsx b/src/components/dashboard/development-assistant/TableRowActions.jsx index 69f9d6f..fa9e1ef 100644 --- a/src/components/dashboard/development-assistant/TableRowActions.jsx +++ b/src/components/dashboard/development-assistant/TableRowActions.jsx @@ -1,19 +1,12 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import Confirm from "./Form/ConfirmForm"; import Reject from "./Form/RejectForm"; -const TableRow = ({row, mutate}) => { - +const TableRow = ({ row, mutate }) => { return ( - - - + + + ); }; diff --git a/src/components/dashboard/development-assistant/index.jsx b/src/components/dashboard/development-assistant/index.jsx index 53c25bd..3b7877c 100644 --- a/src/components/dashboard/development-assistant/index.jsx +++ b/src/components/dashboard/development-assistant/index.jsx @@ -1,7 +1,7 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_DEVELOPMENT_ASSISTANT} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_DEVELOPMENT_ASSISTANT } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import moment from "jalali-moment"; import DataTable from "@/core/components/DataTable"; @@ -19,17 +19,8 @@ function DashboardDevelopmentAssistantComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -39,9 +30,7 @@ function DashboardDevelopmentAssistantComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -50,17 +39,8 @@ function DashboardDevelopmentAssistantComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.phone_number, @@ -69,47 +49,32 @@ function DashboardDevelopmentAssistantComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("DevelopmentAssistant.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "updated_at", header: t("DevelopmentAssistant.updated_at"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -117,16 +82,14 @@ function DashboardDevelopmentAssistantComponent() { header: t("DevelopmentAssistant.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { const t = useTranslations(); - const {user, token, getUser, changeUser} = useUser(); - const {directionApp} = useDirection() - const handleSubmit = (values, {setSubmitting}) => { - - }; + const { user, token, getUser, changeUser } = useUser(); + const { directionApp } = useDirection(); + const handleSubmit = (values, { setSubmitting }) => {}; const initialValues = { expert_avatar: null, username: user.username, @@ -27,11 +25,7 @@ const DashboardEditProfile = () => { return ( - + {(props) => ( { @@ -40,11 +34,11 @@ const DashboardEditProfile = () => { }} > - + {t("UpdateProfile.typography_edit_profile")} - + { margin="normal" size="small" disabled={true} - error={ - props.touched.username && props.errors.username - ? true - : false - } - helperText={ - props.touched.username - ? props.errors.username - : null - } + error={props.touched.username && props.errors.username ? true : false} + helperText={props.touched.username ? props.errors.username : null} sx={{ width: "100%", }} @@ -78,14 +64,8 @@ const DashboardEditProfile = () => { margin="normal" size="small" disabled={true} - error={ - props.touched.name && props.errors.name - ? true - : false - } - helperText={ - props.touched.name ? props.errors.name : null - } + error={props.touched.name && props.errors.name ? true : false} + helperText={props.touched.name ? props.errors.name : null} sx={{ width: "100%", }} @@ -100,14 +80,8 @@ const DashboardEditProfile = () => { margin="normal" size="small" disabled={true} - error={ - props.touched.email && props.errors.email - ? true - : false - } - helperText={ - props.touched.email ? props.errors.email : null - } + error={props.touched.email && props.errors.email ? true : false} + helperText={props.touched.email ? props.errors.email : null} sx={{ width: "100%", }} @@ -124,15 +98,12 @@ const DashboardEditProfile = () => { size="small" disabled={true} error={ - props.touched.province_name && - props.errors.province_name + props.touched.province_name && props.errors.province_name ? true : false } helperText={ - props.touched.province_name - ? props.errors.province_name - : null + props.touched.province_name ? props.errors.province_name : null } sx={{ width: "100%", @@ -148,16 +119,8 @@ const DashboardEditProfile = () => { margin="normal" size="small" disabled={true} - error={ - props.touched.position && props.errors.position - ? true - : false - } - helperText={ - props.touched.position - ? props.errors.position - : null - } + error={props.touched.position && props.errors.position ? true : false} + helperText={props.touched.position ? props.errors.position : null} sx={{ width: "100%", }} diff --git a/src/components/dashboard/expert-management/Form/ChangePassword/ChangePasswordContent.jsx b/src/components/dashboard/expert-management/Form/ChangePassword/ChangePasswordContent.jsx index 9a8cf1d..6b5c3a3 100644 --- a/src/components/dashboard/expert-management/Form/ChangePassword/ChangePasswordContent.jsx +++ b/src/components/dashboard/expert-management/Form/ChangePassword/ChangePasswordContent.jsx @@ -1,14 +1,13 @@ -import {useTranslations} from "next-intl"; -import {Button, DialogActions, DialogContent, IconButton, InputAdornment, TextField} from "@mui/material"; -import {CHANGE_PASSWORD_EXPERT_MANAGEMENT} from "@/core/data/apiRoutes"; -import {useFormik} from "formik"; +import { useTranslations } from "next-intl"; +import { Button, DialogActions, DialogContent, IconButton, InputAdornment, TextField } from "@mui/material"; +import { CHANGE_PASSWORD_EXPERT_MANAGEMENT } from "@/core/data/apiRoutes"; +import { useFormik } from "formik"; import * as Yup from "yup"; -import {Visibility, VisibilityOff} from "@mui/icons-material"; -import {useState} from "react"; +import { Visibility, VisibilityOff } from "@mui/icons-material"; +import { useState } from "react"; import useRequest from "@/lib/app/hooks/useRequest"; - -const ChnagePasswordContent = ({rowId, mutate, setOpenChangePasswordDialog}) => { +const ChnagePasswordContent = ({ rowId, mutate, setOpenChangePasswordDialog }) => { const t = useTranslations(); const requestServer = useRequest(); const [showPassword, setShowPassword] = useState(false); @@ -20,10 +19,7 @@ const ChnagePasswordContent = ({rowId, mutate, setOpenChangePasswordDialog}) => const validationSchema = Yup.object().shape({ new_password: Yup.string() .required(t("ExpertMangement.error_message_new_password")) - .matches( - /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/, - t("ExpertMangement.error_message_new_password_regex") - ), + .matches(/^(?=.*[a-zA-Z])(?=.*\d).{8,}$/, t("ExpertMangement.error_message_new_password_regex")), }); const formik = useFormik({ @@ -31,21 +27,22 @@ const ChnagePasswordContent = ({rowId, mutate, setOpenChangePasswordDialog}) => new_password: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("new_password", values.new_password); - requestServer(`${CHANGE_PASSWORD_EXPERT_MANAGEMENT}/${rowId}`, 'post', { + requestServer(`${CHANGE_PASSWORD_EXPERT_MANAGEMENT}/${rowId}`, "post", { auth: true, - data: formData + data: formData, }) .then((response) => { - setOpenChangePasswordDialog(false) - mutate() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + setOpenChangePasswordDialog(false); + mutate(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -62,31 +59,42 @@ const ChnagePasswordContent = ({rowId, mutate, setOpenChangePasswordDialog}) => onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.new_password && !!formik.errors.new_password} - helperText={formik.touched.new_password && formik.errors.new_password ? formik.errors.new_password : null} + helperText={ + formik.touched.new_password && formik.errors.new_password ? formik.errors.new_password : null + } type={showPassword ? "text" : "password"} InputProps={{ endAdornment: ( - {showPassword ? : } + {showPassword ? : } ), }} - sx={{width: "100%"}} + sx={{ width: "100%" }} /> - - ); }; -export default ChnagePasswordContent; \ No newline at end of file +export default ChnagePasswordContent; diff --git a/src/components/dashboard/expert-management/Form/ChangePassword/index.jsx b/src/components/dashboard/expert-management/Form/ChangePassword/index.jsx index 73b00fc..55f92c2 100644 --- a/src/components/dashboard/expert-management/Form/ChangePassword/index.jsx +++ b/src/components/dashboard/expert-management/Form/ChangePassword/index.jsx @@ -1,11 +1,10 @@ -import {useTranslations} from "next-intl"; -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import KeyIcon from '@mui/icons-material/Key'; -import {useState} from "react"; +import { useTranslations } from "next-intl"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import KeyIcon from "@mui/icons-material/Key"; +import { useState } from "react"; import ChangePasswordContent from "./ChangePasswordContent"; - -const ChangePassword = ({rowId, mutate}) => { +const ChangePassword = ({ rowId, mutate }) => { const t = useTranslations(); const [openChnagePasswordDialog, setOpenChangePasswordDialog] = useState(false); @@ -15,19 +14,30 @@ const ChangePassword = ({rowId, mutate}) => { { - setOpenChangePasswordDialog(true) + setOpenChangePasswordDialog(true); }} > - + - + {t("ExpertMangement.change_password")} - + ); }; -export default ChangePassword; \ No newline at end of file +export default ChangePassword; diff --git a/src/components/dashboard/expert-management/Form/CreateForm/CreateContent.jsx b/src/components/dashboard/expert-management/Form/CreateForm/CreateContent.jsx index c50fe30..dd93211 100644 --- a/src/components/dashboard/expert-management/Form/CreateForm/CreateContent.jsx +++ b/src/components/dashboard/expert-management/Form/CreateForm/CreateContent.jsx @@ -15,23 +15,23 @@ import { Select, TextField, } from "@mui/material"; -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -import {useState} from "react"; -import {CREATE_EXPERT_MANAGEMENT, GET_CITY_LIST} from "@/core/data/apiRoutes"; +import { useState } from "react"; +import { CREATE_EXPERT_MANAGEMENT, GET_CITY_LIST } from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; import useProvince from "@/lib/app/hooks/useProvince"; import useRole from "@/lib/app/hooks/useRole"; -import {Visibility, VisibilityOff} from "@mui/icons-material"; +import { Visibility, VisibilityOff } from "@mui/icons-material"; -const CreateContent = ({setOpenCreateDialog, mutate}) => { +const CreateContent = ({ setOpenCreateDialog, mutate }) => { const t = useTranslations(); - const requestServer = useRequest() + const requestServer = useRequest(); const [cityList, setCityList] = useState([]); const [cityTextField, setCityTextField] = useState(t("ExpertMangement.text_field_please_select_province")); - const {provinceList, isLoadingProvinceList, errorProvinceList} = useProvince(); - const {roleList, isLoadingRoleList, errorRoleList} = useRole(); + const { provinceList, isLoadingProvinceList, errorProvinceList } = useProvince(); + const { roleList, isLoadingRoleList, errorRoleList } = useRole(); const [showPassword, setShowPassword] = useState(false); const handleClickShowPassword = () => { @@ -40,10 +40,10 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { function getCities(province_id) { formik.setFieldTouched("city_id", false, false); - formik.setFieldValue("city_id", "") - setCityTextField(t("ExpertMangement.text_field_loading_cities_list")) - requestServer(`${GET_CITY_LIST}?province_id=${province_id}`, "get", {auth: true, notification: false}) - .then(({data}) => { + formik.setFieldValue("city_id", ""); + setCityTextField(t("ExpertMangement.text_field_loading_cities_list")); + requestServer(`${GET_CITY_LIST}?province_id=${province_id}`, "get", { auth: true, notification: false }) + .then(({ data }) => { const result = data.data; const formattedData = result.map((city, index) => ({ id: index, @@ -51,13 +51,13 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { value: city.id, })); setCityList(formattedData); - setCityTextField(t("ExpertMangement.text_field_city_id")) - }).catch(() => { - setCityTextField(t("ExpertMangement.text_field_error_fetching_cities")) - }); + setCityTextField(t("ExpertMangement.text_field_city_id")); + }) + .catch(() => { + setCityTextField(t("ExpertMangement.text_field_error_fetching_cities")); + }); } - const validationSchema = Yup.object().shape({ name: Yup.string().required(t("ExpertMangement.error_message_name")), username: Yup.string().required(t("ExpertMangement.error_message_username")), @@ -66,14 +66,11 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { national_id: Yup.string().required(t("ExpertMangement.error_message_national_id")), password: Yup.string() .required(t("ExpertMangement.error_message_password")) - .matches( - /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/, - t("ExpertMangement.error_message_password_regex") - ), + .matches(/^(?=.*[a-zA-Z])(?=.*\d).{8,}$/, t("ExpertMangement.error_message_password_regex")), position: Yup.string().required(t("ExpertMangement.error_message_position")), province_id: Yup.string().required(t("ExpertMangement.error_message_province_id")), city_id: Yup.string(), - role_id: Yup.string().required(t("ExpertMangement.error_message_role_id")) + role_id: Yup.string().required(t("ExpertMangement.error_message_role_id")), }); const formik = useFormik({ @@ -87,10 +84,10 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { position: "", province_id: "", city_id: "", - role_id: "" + role_id: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("name", values.name); formData.append("national_id", values.national_id); @@ -103,28 +100,27 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { formData.append("position", values.position); formData.append("role_id", values.role_id); - requestServer(`${CREATE_EXPERT_MANAGEMENT}`, 'post', {auth: true, data: formData}) + requestServer(`${CREATE_EXPERT_MANAGEMENT}`, "post", { auth: true, data: formData }) .then((response) => { - setOpenCreateDialog(false) - mutate() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + setOpenCreateDialog(false); + mutate(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); return ( <> - + - + - + { onBlur={formik.handleBlur} error={formik.touched.name && !!formik.errors.name} helperText={formik.touched.name && formik.errors.name ? formik.errors.name : null} - sx={{width: "100%"}} + sx={{ width: "100%" }} /> @@ -151,8 +147,12 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.national_id && !!formik.errors.national_id} - helperText={formik.touched.national_id && formik.errors.national_id ? formik.errors.national_id : null} - sx={{width: "100%"}} + helperText={ + formik.touched.national_id && formik.errors.national_id + ? formik.errors.national_id + : null + } + sx={{ width: "100%" }} /> @@ -166,8 +166,12 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.phone_number && !!formik.errors.phone_number} - helperText={formik.touched.phone_number && formik.errors.phone_number ? formik.errors.phone_number : null} - sx={{width: "100%"}} + helperText={ + formik.touched.phone_number && formik.errors.phone_number + ? formik.errors.phone_number + : null + } + sx={{ width: "100%" }} /> @@ -182,18 +186,16 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { onBlur={formik.handleBlur} error={formik.touched.email && !!formik.errors.email} helperText={formik.touched.email && formik.errors.email ? formik.errors.email : null} - sx={{width: "100%"}} + sx={{ width: "100%" }} /> - + - + - + { onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.username && !!formik.errors.username} - helperText={formik.touched.username && formik.errors.username ? formik.errors.username : null} - sx={{width: "100%"}} + helperText={ + formik.touched.username && formik.errors.username ? formik.errors.username : null + } + sx={{ width: "100%" }} /> @@ -220,33 +224,33 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.password && !!formik.errors.password} - helperText={formik.touched.password && formik.errors.password ? formik.errors.password : null} + helperText={ + formik.touched.password && formik.errors.password ? formik.errors.password : null + } type={showPassword ? "text" : "password"} InputProps={{ endAdornment: ( - {showPassword ? : } + {showPassword ? : } ), }} - sx={{width: "100%"}} + sx={{ width: "100%" }} /> - + - + - + {t("ExpertMangement.text_field_province_id")} @@ -257,20 +261,16 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { value={formik.values.province_id} onChange={(e) => { formik.setFieldValue("province_id", e.target.value); - getCities(e.target.value) + getCities(e.target.value); }} onBlur={formik.handleBlur} fullWidth variant="outlined" > {isLoadingProvinceList ? ( - - {t("ExpertMangement.text_field_loading_provinces_list")} - + {t("ExpertMangement.text_field_loading_provinces_list")} ) : errorProvinceList ? ( - - {t("ExpertMangement.text_field_error_fetching_provinces")} - + {t("ExpertMangement.text_field_error_fetching_provinces")} ) : ( provinceList.map((item) => ( @@ -280,7 +280,9 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { )} - {formik.touched.province_id && formik.errors.province_id ? formik.errors.province_id : ""} + {formik.touched.province_id && formik.errors.province_id + ? formik.errors.province_id + : ""} @@ -288,7 +290,7 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { {cityTextField} @@ -313,7 +315,7 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { - + { onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.position && !!formik.errors.position} - helperText={formik.touched.position && formik.errors.position ? formik.errors.position : null} - sx={{width: "100%"}} + helperText={ + formik.touched.position && formik.errors.position ? formik.errors.position : null + } + sx={{ width: "100%" }} /> {t("ExpertMangement.text_field_role_id")} @@ -346,13 +350,9 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { variant="outlined" > {isLoadingRoleList ? ( - - {t("ExpertMangement.text_field_loading_roles_list")} - + {t("ExpertMangement.text_field_loading_roles_list")} ) : errorRoleList ? ( - - {t("ExpertMangement.text_field_error_fetching_roles")} - + {t("ExpertMangement.text_field_error_fetching_roles")} ) : ( roleList.map((item) => ( @@ -369,12 +369,21 @@ const CreateContent = ({setOpenCreateDialog, mutate}) => { - - diff --git a/src/components/dashboard/expert-management/Form/CreateForm/index.jsx b/src/components/dashboard/expert-management/Form/CreateForm/index.jsx index b9a110b..10aed8f 100644 --- a/src/components/dashboard/expert-management/Form/CreateForm/index.jsx +++ b/src/components/dashboard/expert-management/Form/CreateForm/index.jsx @@ -1,10 +1,10 @@ -import {Button, Dialog, DialogTitle, Stack, Tooltip,} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Button, Dialog, DialogTitle, Stack, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import {useState} from "react"; +import { useState } from "react"; import CreateContent from "./CreateContent"; -const Create = ({mutate}) => { +const Create = ({ mutate }) => { const t = useTranslations(); const [openCreateDialog, setOpenCreateDialog] = useState(false); @@ -16,21 +16,29 @@ const Create = ({mutate}) => { color="primary" variant="contained" size="small" - sx={{textTransform: "unset", alignSelf: "center"}} - startIcon={} + sx={{ textTransform: "unset", alignSelf: "center" }} + startIcon={} onClick={() => { - setOpenCreateDialog(true) + setOpenCreateDialog(true); }} > {t("ExpertMangement.add")} - + {t("ExpertMangement.create")} - + ); diff --git a/src/components/dashboard/expert-management/Form/DeleteForm.jsx b/src/components/dashboard/expert-management/Form/DeleteForm.jsx index 3c8b5b7..4233e9c 100644 --- a/src/components/dashboard/expert-management/Form/DeleteForm.jsx +++ b/src/components/dashboard/expert-management/Form/DeleteForm.jsx @@ -6,30 +6,29 @@ import { DialogContentText, DialogTitle, IconButton, - Tooltip + Tooltip, } from "@mui/material"; -import DeleteIcon from '@mui/icons-material/Delete'; -import {useState} from "react"; -import {DELETE_EXPERT_MANAGEMENT} from "@/core/data/apiRoutes"; +import DeleteIcon from "@mui/icons-material/Delete"; +import { useState } from "react"; +import { DELETE_EXPERT_MANAGEMENT } from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; -const Delete = ({rowId, mutate}) => { +const Delete = ({ rowId, mutate }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}); + const requestServer = useRequest({ auth: true }); const [openDeleteDialog, setOpenDeleteDialog] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); const handleDelete = () => { - setIsSubmitting(true) - requestServer(`${DELETE_EXPERT_MANAGEMENT}/${rowId}`, 'post') + setIsSubmitting(true); + requestServer(`${DELETE_EXPERT_MANAGEMENT}/${rowId}`, "post") .then((response) => { - mutate() - }) - .catch(() => { + mutate(); }) + .catch(() => {}) .finally(() => { - setIsSubmitting(false) + setIsSubmitting(false); setOpenDeleteDialog(false); }); }; @@ -43,15 +42,15 @@ const Delete = ({rowId, mutate}) => { setOpenDeleteDialog(true); }} > - + {t("ExpertMangement.delete_expert")} @@ -70,4 +69,4 @@ const Delete = ({rowId, mutate}) => { ); }; -export default Delete; \ No newline at end of file +export default Delete; diff --git a/src/components/dashboard/expert-management/Form/UpdateForm/UpdateContent.jsx b/src/components/dashboard/expert-management/Form/UpdateForm/UpdateContent.jsx index 3c5e0ed..3575ee0 100644 --- a/src/components/dashboard/expert-management/Form/UpdateForm/UpdateContent.jsx +++ b/src/components/dashboard/expert-management/Form/UpdateForm/UpdateContent.jsx @@ -1,4 +1,4 @@ -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import { Box, Button, @@ -12,31 +12,31 @@ import { InputLabel, MenuItem, Select, - TextField + TextField, } from "@mui/material"; -import {useEffect, useState} from "react"; -import {useFormik} from "formik"; -import {GET_CITY_LIST, UPDATE_EXPERT_MANAGEMENT} from "@/core/data/apiRoutes"; +import { useEffect, useState } from "react"; +import { useFormik } from "formik"; +import { GET_CITY_LIST, UPDATE_EXPERT_MANAGEMENT } from "@/core/data/apiRoutes"; import * as Yup from "yup"; import useRequest from "@/lib/app/hooks/useRequest"; import useProvince from "@/lib/app/hooks/useProvince"; import useRole from "@/lib/app/hooks/useRole"; -const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { +const UpdateContent = ({ row, mutate, setOpenUpdateDialog }) => { const t = useTranslations(); const requestServer = useRequest(); const [cityList, setCityList] = useState([]); const [citiesExist, setCitiesExist] = useState(false); const [cityTextField, setCityTextField] = useState(t("ExpertMangement.text_field_please_select_province")); - const {provinceList, isLoadingProvinceList, errorProvinceList} = useProvince(); - const {roleList, isLoadingRoleList, errorRoleList} = useRole(); + const { provinceList, isLoadingProvinceList, errorProvinceList } = useProvince(); + const { roleList, isLoadingRoleList, errorRoleList } = useRole(); function getCities(province_id) { formik.setFieldTouched("city_id", false, false); - citiesExist && formik.setFieldValue("city_id", "") - setCityTextField(t("ExpertMangement.text_field_loading_cities_list")) - requestServer(`${GET_CITY_LIST}?province_id=${province_id}`, "get", {auth: true, notification: false}) - .then(({data}) => { + citiesExist && formik.setFieldValue("city_id", ""); + setCityTextField(t("ExpertMangement.text_field_loading_cities_list")); + requestServer(`${GET_CITY_LIST}?province_id=${province_id}`, "get", { auth: true, notification: false }) + .then(({ data }) => { const result = data.data; const formattedData = result.map((city, index) => ({ id: index, @@ -45,10 +45,11 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { })); setCitiesExist(true); setCityList(formattedData); - setCityTextField(t("ExpertMangement.text_field_city_id")) - }).catch(() => { - setCityTextField(t("ExpertMangement.text_field_error_fetching_cities")) - }); + setCityTextField(t("ExpertMangement.text_field_city_id")); + }) + .catch(() => { + setCityTextField(t("ExpertMangement.text_field_error_fetching_cities")); + }); } const validationSchema = Yup.object().shape({ @@ -60,7 +61,7 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { position: Yup.string().required(t("ExpertMangement.error_message_position")), province_id: Yup.string().required(t("ExpertMangement.error_message_province_id")), city_id: Yup.string(), - role_id: Yup.string().required(t("ExpertMangement.error_message_role_id")) + role_id: Yup.string().required(t("ExpertMangement.error_message_role_id")), }); const formik = useFormik({ initialValues: { @@ -72,10 +73,10 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { position: row.original.position, province_id: row.original.province_id, city_id: row.original.city_id, - role_id: row.original.roles[0].id + role_id: row.original.roles[0].id, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("name", values.name); formData.append("national_id", values.national_id); @@ -87,14 +88,15 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { formData.append("position", values.position); formData.append("role_id", values.role_id); - requestServer(`${UPDATE_EXPERT_MANAGEMENT}/${row.original.id}`, 'post', {auth: true, data: formData}) + requestServer(`${UPDATE_EXPERT_MANAGEMENT}/${row.original.id}`, "post", { auth: true, data: formData }) .then((response) => { setOpenUpdateDialog(false); - mutate() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + mutate(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -105,14 +107,12 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { return ( <> - + - + - + { onBlur={formik.handleBlur} error={formik.touched.name && !!formik.errors.name} helperText={formik.touched.name && formik.errors.name ? formik.errors.name : null} - sx={{width: "100%"}} + sx={{ width: "100%" }} /> @@ -139,8 +139,12 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.national_id && !!formik.errors.national_id} - helperText={formik.touched.national_id && formik.errors.national_id ? formik.errors.national_id : null} - sx={{width: "100%"}} + helperText={ + formik.touched.national_id && formik.errors.national_id + ? formik.errors.national_id + : null + } + sx={{ width: "100%" }} /> @@ -154,8 +158,12 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.phone_number && !!formik.errors.phone_number} - helperText={formik.touched.phone_number && formik.errors.phone_number ? formik.errors.phone_number : null} - sx={{width: "100%"}} + helperText={ + formik.touched.phone_number && formik.errors.phone_number + ? formik.errors.phone_number + : null + } + sx={{ width: "100%" }} /> @@ -170,18 +178,16 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { onBlur={formik.handleBlur} error={formik.touched.email && !!formik.errors.email} helperText={formik.touched.email && formik.errors.email ? formik.errors.email : null} - sx={{width: "100%"}} + sx={{ width: "100%" }} /> - + - + - + { onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.username && !!formik.errors.username} - helperText={formik.touched.username && formik.errors.username ? formik.errors.username : null} - sx={{width: "100%"}} + helperText={ + formik.touched.username && formik.errors.username ? formik.errors.username : null + } + sx={{ width: "100%" }} /> - + - + - + {t("ExpertMangement.text_field_province_id")} @@ -223,13 +229,9 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { variant="outlined" > {isLoadingProvinceList ? ( - - {t("ExpertMangement.text_field_loading_provinces_list")} - + {t("ExpertMangement.text_field_loading_provinces_list")} ) : errorProvinceList ? ( - - {t("ExpertMangement.text_field_error_fetching_provinces")} - + {t("ExpertMangement.text_field_error_fetching_provinces")} ) : ( provinceList.map((item) => ( @@ -239,7 +241,9 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { )} - {formik.touched.province_id && formik.errors.province_id ? formik.errors.province_id : ""} + {formik.touched.province_id && formik.errors.province_id + ? formik.errors.province_id + : ""} @@ -247,7 +251,7 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { {cityTextField} @@ -272,7 +276,7 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { - + { onChange={formik.handleChange} onBlur={formik.handleBlur} error={formik.touched.position && !!formik.errors.position} - helperText={formik.touched.position && formik.errors.position ? formik.errors.position : null} - sx={{width: "100%"}} + helperText={ + formik.touched.position && formik.errors.position ? formik.errors.position : null + } + sx={{ width: "100%" }} /> {t("ExpertMangement.text_field_role_id")} @@ -305,13 +311,9 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { variant="outlined" > {isLoadingRoleList ? ( - - {t("ExpertMangement.text_field_loading_roles_list")} - + {t("ExpertMangement.text_field_loading_roles_list")} ) : errorRoleList ? ( - - {t("ExpertMangement.text_field_error_fetching_roles")} - + {t("ExpertMangement.text_field_error_fetching_roles")} ) : ( roleList.map((item) => ( @@ -328,16 +330,25 @@ const UpdateContent = ({row, mutate, setOpenUpdateDialog}) => { - - ); }; -export default UpdateContent; \ No newline at end of file +export default UpdateContent; diff --git a/src/components/dashboard/expert-management/Form/UpdateForm/index.jsx b/src/components/dashboard/expert-management/Form/UpdateForm/index.jsx index 7197d1c..1045887 100644 --- a/src/components/dashboard/expert-management/Form/UpdateForm/index.jsx +++ b/src/components/dashboard/expert-management/Form/UpdateForm/index.jsx @@ -1,11 +1,10 @@ -import {useTranslations} from "next-intl"; -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import EditIcon from '@mui/icons-material/Edit'; -import {useState} from "react"; +import { useTranslations } from "next-intl"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import EditIcon from "@mui/icons-material/Edit"; +import { useState } from "react"; import UpdateContent from "./UpdateContent"; - -const Update = ({row, mutate}) => { +const Update = ({ row, mutate }) => { const t = useTranslations(); const [openUpdateDialog, setOpenUpdateDialog] = useState(false); @@ -15,18 +14,26 @@ const Update = ({row, mutate}) => { { - setOpenUpdateDialog(true) + setOpenUpdateDialog(true); }} > - + - + {t("ExpertMangement.update")} - + ); }; -export default Update; \ No newline at end of file +export default Update; diff --git a/src/components/dashboard/expert-management/TableRowActions.jsx b/src/components/dashboard/expert-management/TableRowActions.jsx index 1bf5968..7d5b5b3 100644 --- a/src/components/dashboard/expert-management/TableRowActions.jsx +++ b/src/components/dashboard/expert-management/TableRowActions.jsx @@ -1,24 +1,14 @@ -import {Box} from "@mui/material"; -import Update from "./Form/UpdateForm" +import { Box } from "@mui/material"; +import Update from "./Form/UpdateForm"; import Delete from "./Form/DeleteForm"; import ChangePassword from "./Form/ChangePassword"; -const TableRowActions = ({row, mutate}) => { +const TableRowActions = ({ row, mutate }) => { return ( - - - - - + + + + ); }; diff --git a/src/components/dashboard/expert-management/TableToolbar.jsx b/src/components/dashboard/expert-management/TableToolbar.jsx index de2a387..c03af9d 100644 --- a/src/components/dashboard/expert-management/TableToolbar.jsx +++ b/src/components/dashboard/expert-management/TableToolbar.jsx @@ -1,11 +1,11 @@ -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import Create from "./Form/CreateForm"; -function TableToolbar({mutate, fetchUrl}) { +function TableToolbar({ mutate, fetchUrl }) { const t = useTranslations(); return ( <> - + ); } diff --git a/src/components/dashboard/expert-management/index.jsx b/src/components/dashboard/expert-management/index.jsx index f8caab7..3982392 100644 --- a/src/components/dashboard/expert-management/index.jsx +++ b/src/components/dashboard/expert-management/index.jsx @@ -1,7 +1,7 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_EXPERT_MANAGEMENT} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_EXPERT_MANAGEMENT } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import DataTable from "@/core/components/DataTable"; import TableToolbar from "@/components/dashboard/expert-management/TableToolbar"; @@ -19,17 +19,8 @@ function DashboardExpertManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -39,9 +30,7 @@ function DashboardExpertManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.username, @@ -51,9 +40,7 @@ function DashboardExpertManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.phone_number, @@ -63,9 +50,7 @@ function DashboardExpertManagementComponent() { datatype: "numeric", filterFn: "equals", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -75,9 +60,7 @@ function DashboardExpertManagementComponent() { datatype: "numeric", filterFn: "equals", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.position, @@ -87,9 +70,7 @@ function DashboardExpertManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.province_name, @@ -99,9 +80,7 @@ function DashboardExpertManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.roles[0].name_fa, @@ -111,27 +90,22 @@ function DashboardExpertManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "updated_at", header: t("ExpertMangement.updated_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, ], @@ -139,20 +113,23 @@ function DashboardExpertManagementComponent() { ); return ( - + { - const theme = useTheme(); - const t = useTranslations(); - const requestServer = useRequest({ auth: true, notification: false }); - const [data, setData] = useState(null); - const isXL = useMediaQuery(theme.breakpoints.up('xl')); + const theme = useTheme(); + const t = useTranslations(); + const requestServer = useRequest({ auth: true, notification: false }); + const [data, setData] = useState(null); + const isXL = useMediaQuery(theme.breakpoints.up("xl")); - useEffect(() => { - requestServer( - `${GET_LOAN_STATISTICS}`, - "get" - ) - .then((res) => { - setData(res.data.data); - }) - .catch(() => {}); - }, []); + useEffect(() => { + requestServer(`${GET_LOAN_STATISTICS}`, "get") + .then((res) => { + setData(res.data.data); + }) + .catch(() => {}); + }, []); - if (!data) return ""; + if (!data) return ""; - return ( - <> - - - - - + + + - - + - - {Number(data.proposedCount).toLocaleString("en")} - - - - - - - - - - - {(Number(data.totalProposedAmount)/1000000).toLocaleString("en")} - - {t("million_rial")} + + + + + {Number(data.proposedCount).toLocaleString("en")} + - - - - - - - - - + + + - - {Number(data.totalApprovedLoans).toLocaleString("en")} - - - - - - - - - - - {(Number(data.totalApprovedAmount) / 1000000).toLocaleString("en")} - - {t("million_rial")} + + + + + {(Number(data.totalProposedAmount) / 1000000).toLocaleString("en")} + + {t("million_rial")} + + - - - - - - - - - + + + - - {Number(data.approvedCount).toLocaleString("en")} - - - - - - - - - - ); + + + + + {Number(data.totalApprovedLoans).toLocaleString("en")} + + + + + + + + + + + {(Number(data.totalApprovedAmount) / 1000000).toLocaleString("en")} + + {t("million_rial")} + + + + + + + + + + + + {Number(data.approvedCount).toLocaleString("en")} + + + + + + + + + + ); }; -export default DashboardFirstComponent; \ No newline at end of file +export default DashboardFirstComponent; diff --git a/src/components/dashboard/inspector-expert/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/inspector-expert/Form/ConfirmForm/ConfirmContent.jsx index 6fca794..3e61151 100644 --- a/src/components/dashboard/inspector-expert/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/inspector-expert/Form/ConfirmForm/ConfirmContent.jsx @@ -1,47 +1,49 @@ import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {CONFIRM_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { CONFIRM_INSPECTOR_EXPERT } from "@/core/data/apiRoutes"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import {useState} from "react"; +import { useState } from "react"; -const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { +const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const formik = useFormik({ initialValues: { description: "", - confirm_img: null + confirm_img: null, }, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); if (values.description != "") formData.append("description", values.description); if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - requestServer(`${CONFIRM_INSPECTOR_EXPERT}/${rowId}`, 'post', { + requestServer(`${CONFIRM_INSPECTOR_EXPERT}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) + formik.setFieldValue("description", event.target.value); }; const handleUploadChange = (event) => { @@ -73,17 +75,24 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { name="description" multiline rows={8} - label={<> - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} + label={ + <> + {t("ConfirmDialog.description")} + {t("ConfirmDialog.optional")} + + } value={formik.values.description} onChange={handleDescriptionChange} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) - -} -export default ConfirmContent \ No newline at end of file + ); +}; +export default ConfirmContent; diff --git a/src/components/dashboard/inspector-expert/Form/ConfirmForm/index.jsx b/src/components/dashboard/inspector-expert/Form/ConfirmForm/index.jsx index 95a6367..e849196 100644 --- a/src/components/dashboard/inspector-expert/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/inspector-expert/Form/ConfirmForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import {useState} from "react"; +import { useState } from "react"; import ConfirmContent from "./ConfirmContent"; -const Confirm = ({rowId, mutate}) => { +const Confirm = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,19 +13,25 @@ const Confirm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("ConfirmDialog.confirm")} - + - ) - -} -export default Confirm; \ No newline at end of file + ); +}; +export default Confirm; diff --git a/src/components/dashboard/inspector-expert/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/inspector-expert/Form/RejectForm/RejectContent.jsx index 340a757..2bcc40a 100644 --- a/src/components/dashboard/inspector-expert/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/inspector-expert/Form/RejectForm/RejectContent.jsx @@ -1,21 +1,21 @@ -import UploadSystem from "@/core/components/UploadSystem" +import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import * as Yup from "yup"; -import {REJECT_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; +import { REJECT_INSPECTOR_EXPERT } from "@/core/data/apiRoutes"; -const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { +const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), @@ -24,24 +24,26 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const formik = useFormik({ initialValues: { description: "", - reject_img: null + reject_img: null, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("description", values.description); if (values.reject_img != null) formData.append("attachment", values.reject_img); - requestServer(`${REJECT_INSPECTOR_EXPERT}/${rowId}`, 'post', { + requestServer(`${REJECT_INSPECTOR_EXPERT}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenRejectDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenRejectDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -80,17 +82,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) -} -export default RejectContent \ No newline at end of file + ); +}; +export default RejectContent; diff --git a/src/components/dashboard/inspector-expert/Form/RejectForm/index.jsx b/src/components/dashboard/inspector-expert/Form/RejectForm/index.jsx index 06608f5..a04d0e1 100644 --- a/src/components/dashboard/inspector-expert/Form/RejectForm/index.jsx +++ b/src/components/dashboard/inspector-expert/Form/RejectForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import RejectContent from "./RejectContent"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -const Reject = ({rowId, mutate}) => { +const Reject = ({ rowId, mutate }) => { const t = useTranslations(); const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> setOpenRejectDialog(true)}> - + - + {t("RejectDialog.reject")} - + - ) -} -export default Reject \ No newline at end of file + ); +}; +export default Reject; diff --git a/src/components/dashboard/inspector-expert/Form/ReviseForm/ReviseContent.jsx b/src/components/dashboard/inspector-expert/Form/ReviseForm/ReviseContent.jsx index b0c42ee..f8964c7 100644 --- a/src/components/dashboard/inspector-expert/Form/ReviseForm/ReviseContent.jsx +++ b/src/components/dashboard/inspector-expert/Form/ReviseForm/ReviseContent.jsx @@ -1,15 +1,15 @@ 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 { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -import {REVISE_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; +import { REVISE_INSPECTOR_EXPERT } from "@/core/data/apiRoutes"; -const ReviseContent = ({rowId, mutate, setOpenReviseDialog}) => { +const ReviseContent = ({ rowId, mutate, setOpenReviseDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("ReviseDialog.description_error")), @@ -20,20 +20,22 @@ const ReviseContent = ({rowId, mutate, setOpenReviseDialog}) => { description: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("description", values.description); - requestServer(`${REVISE_INSPECTOR_EXPERT}/${rowId}`, 'post', { + requestServer(`${REVISE_INSPECTOR_EXPERT}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenReviseDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenReviseDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -54,28 +56,35 @@ const ReviseContent = ({rowId, mutate, setOpenReviseDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - - - ) -} -export default ReviseContent \ No newline at end of file + ); +}; +export default ReviseContent; diff --git a/src/components/dashboard/inspector-expert/Form/ReviseForm/index.jsx b/src/components/dashboard/inspector-expert/Form/ReviseForm/index.jsx index 6b6691b..4fad1cd 100644 --- a/src/components/dashboard/inspector-expert/Form/ReviseForm/index.jsx +++ b/src/components/dashboard/inspector-expert/Form/ReviseForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; -import ReplyIcon from '@mui/icons-material/Reply'; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ReplyIcon from "@mui/icons-material/Reply"; +import { useState } from "react"; import ReviseContent from "./ReviseContent"; -const Revise = ({rowId, mutate}) => { +const Revise = ({ rowId, mutate }) => { const t = useTranslations(); const [openReviseDialog, setOpenReviseDialog] = useState(false); return ( @@ -13,19 +13,25 @@ const Revise = ({rowId, mutate}) => { { - setOpenReviseDialog(true) + setOpenReviseDialog(true); }} > - + - + {t("ReviseDialog.revise")} - + - ) - -} -export default Revise; \ No newline at end of file + ); +}; +export default Revise; diff --git a/src/components/dashboard/inspector-expert/TableRowActions.jsx b/src/components/dashboard/inspector-expert/TableRowActions.jsx index 1d7f15d..6a427f6 100644 --- a/src/components/dashboard/inspector-expert/TableRowActions.jsx +++ b/src/components/dashboard/inspector-expert/TableRowActions.jsx @@ -1,24 +1,14 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import Confirm from "./Form/ConfirmForm"; import Reject from "./Form/RejectForm"; import Revise from "./Form/ReviseForm"; -const TableRow = ({row, mutate}) => { - +const TableRow = ({ row, mutate }) => { return ( - - - - + + + + ); }; diff --git a/src/components/dashboard/inspector-expert/index.jsx b/src/components/dashboard/inspector-expert/index.jsx index 9ee841d..5d3cd8d 100644 --- a/src/components/dashboard/inspector-expert/index.jsx +++ b/src/components/dashboard/inspector-expert/index.jsx @@ -1,7 +1,7 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_INSPECTOR_EXPERT } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import moment from "jalali-moment"; import DataTable from "@/core/components/DataTable"; @@ -18,17 +18,8 @@ function DashboardInspectorExpertComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -38,9 +29,7 @@ function DashboardInspectorExpertComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -49,17 +38,8 @@ function DashboardInspectorExpertComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.phone_number, @@ -68,47 +48,32 @@ function DashboardInspectorExpertComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("InspectorExpert.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "updated_at", header: t("InspectorExpert.updated_at"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -116,16 +81,14 @@ function DashboardInspectorExpertComponent() { header: t("InspectorExpert.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { + const t = useTranslations(); + const requestServer = useRequest({ auth: true, notification: false }); + const [CouncilDetails, setCouncilDetails] = useState([]); + const [isLoading, setIsLoading] = useState(true); + const [error, setError] = useState(false); + const [isCommentExpanded, setIsCommentExpanded] = useState(false); + + useEffect(() => { + requestServer(`${GET_HISTORY_COUNCIL}/${rowId}`, "get") + .then((response) => { + setIsLoading(false); + setCouncilDetails(response.data.data); + }) + .catch(() => { + setError(true); + }); + }, []); + const handleToggleComment = () => { + setIsCommentExpanded((prev) => !prev); + }; + + return ( + + {error ? ( + + {t("LoanHistory.Table_history_error")} + + ) : isLoading ? ( + + ) : ( + + + + + + {t("CouncilHistory.Table_head_id")} + {t("CouncilHistory.Table_head_council_confirm")} + {t("CouncilHistory.Table_head_council_comment")} + {t("CouncilHistory.Table_head_planning_council_loan")} + + + + + {CouncilDetails.id} + + {CouncilConfirm[CouncilDetails.council_confirm]} + + + + + {CouncilDetails.council_reason_name} + + {CouncilDetails.council_comment && ( + + {isCommentExpanded + ? + : + } + + )} + + + + {t("CouncilHistory.council_opinion")} + + {CouncilDetails.council_comment} + + + + + + { + CouncilDetails.planning_council_loan ? + moment(CouncilDetails.planning_council_loan.date_confirm).locale("fa").format("HH:mm | yyyy/MM/DD") : + null + } + + + +
+
+
+ )} +
+ ); +}; + +export default PlanningCouncilTable; diff --git a/src/components/dashboard/loan-followup/Form/PlanningCouncilForm/index.jsx b/src/components/dashboard/loan-followup/Form/PlanningCouncilForm/index.jsx new file mode 100644 index 0000000..cddc5e5 --- /dev/null +++ b/src/components/dashboard/loan-followup/Form/PlanningCouncilForm/index.jsx @@ -0,0 +1,43 @@ +import { Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import Diversity3Icon from '@mui/icons-material/Diversity3'; +import PlanningCouncilTable from "./PlanningCouncilTable"; + +const PlanningCouncilForm = ({ rowId }) => { + const t = useTranslations(); + const [openPlanningCouncilDialog, setOpenPlanningCouncilDialog] = useState(false); + return ( + <> + + setOpenPlanningCouncilDialog(true)}> + + + + + {t("CouncilHistory.council_history_detail")} + + + + + + + ); +}; +export default PlanningCouncilForm; diff --git a/src/components/dashboard/loan-followup/Form/ReferPassengerBoss/ReferPassengerBossContent.jsx b/src/components/dashboard/loan-followup/Form/ReferPassengerBoss/ReferPassengerBossContent.jsx index 0815670..07b98d5 100644 --- a/src/components/dashboard/loan-followup/Form/ReferPassengerBoss/ReferPassengerBossContent.jsx +++ b/src/components/dashboard/loan-followup/Form/ReferPassengerBoss/ReferPassengerBossContent.jsx @@ -1,15 +1,15 @@ 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 { 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"; +import { REFER_LOAN_FOLLOWUP_PASSENGERBOSS } from "@/core/data/apiRoutes"; -const ReferPassengerBossContent = ({rowId, mutate, setOpenReferDialog}) => { +const ReferPassengerBossContent = ({ rowId, mutate, setOpenReferDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("ReferDialog.description_error")), @@ -20,19 +20,21 @@ const ReferPassengerBossContent = ({rowId, mutate, setOpenReferDialog}) => { description: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("expert_description", values.description); - requestServer(`${REFER_LOAN_FOLLOWUP_PASSENGERBOSS}/${rowId}`, 'post', { + requestServer(`${REFER_LOAN_FOLLOWUP_PASSENGERBOSS}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenReferDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenReferDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -53,28 +55,35 @@ const ReferPassengerBossContent = ({rowId, mutate, setOpenReferDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - - - ) -} -export default ReferPassengerBossContent \ No newline at end of file + ); +}; +export default ReferPassengerBossContent; diff --git a/src/components/dashboard/loan-followup/Form/ReferPassengerBoss/index.jsx b/src/components/dashboard/loan-followup/Form/ReferPassengerBoss/index.jsx index 54a98e1..f31f153 100644 --- a/src/components/dashboard/loan-followup/Form/ReferPassengerBoss/index.jsx +++ b/src/components/dashboard/loan-followup/Form/ReferPassengerBoss/index.jsx @@ -1,25 +1,32 @@ -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 { 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 ReferPassengerBoss = ({ rowId, mutate }) => { const t = useTranslations(); const [openReferDialog, setOpenReferDialog] = useState(false); return ( <> setOpenReferDialog(true)}> - + - + {t("ReferDialog.refer-passenger-boss")} - + - ) -} -export default ReferPassengerBoss \ No newline at end of file + ); +}; +export default ReferPassengerBoss; diff --git a/src/components/dashboard/loan-followup/Form/UserInfoForm/LegalTableContent.jsx b/src/components/dashboard/loan-followup/Form/UserInfoForm/LegalTableContent.jsx new file mode 100644 index 0000000..dbabcc4 --- /dev/null +++ b/src/components/dashboard/loan-followup/Form/UserInfoForm/LegalTableContent.jsx @@ -0,0 +1,397 @@ +import { Chip, DialogContent, DialogTitle, Divider, Grid, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import moment from "jalali-moment"; + +const LegalTableContent = ({ rowId, row }) => { + const t = useTranslations(); + return ( + <> + {t("UserInfoDialog.user_info")} + + + + + + + {t("UserInfoDialog.legal_person")} + + + + + + + {row.original.id || t("UserInfoDialog.no_info")} + + + + + + + + + + {row.original.project_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.activity_category_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.first_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.last_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.father_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.gender ? t("UserInfoDialog.female") : t("UserInfoDialog.male")} + + + + + + + + + + + {row.original.national_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.national_serial_number || + row.original.national_tracking_code || + t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.education_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.occupation_title || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.phone_number || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.birthday + ? moment(row.original.birthday).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.province_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.city_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.shenase_meli || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.postal_code || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.company_register_date + ? moment(row.original.company_register_date).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.register_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.navgan_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.navgan_type || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.company_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.telephone_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.vehicle_type || t("UserInfoDialog.no_info")} + + + + + + + + + { + (row.original.investment_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", { value: (row.original.investment_amount / 1000000000) }) + : t("UserInfoDialog.toman", { value: (row.original.investment_amount / 1000000) }) + } + + + + + + + + + + + { + (row.original.requested_facility_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.requested_facility_amount / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.requested_facility_amount / 1000000)}) + } + + + + + + + + + { + (row.original.person_share / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.person_share / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.person_share / 1000000)}) + } + + + + + + + + + + + {row.original.user_committed_employment || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.user_existing_employment || t("UserInfoDialog.no_info")} + + + + + + + + + + + + {row.original.plate_number.split("-")[3] || t("UserInfoDialog.no_info")} + + + + {row.original.plate_number.split("-")[2] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[1] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[0] || t("UserInfoDialog.no_info")} + + + + + + + + + + + + + {row.original.address || t("UserInfoDialog.no_info")} + + + + + + + ); +}; +export default LegalTableContent; diff --git a/src/components/dashboard/loan-followup/Form/UserInfoForm/RealTableContent.jsx b/src/components/dashboard/loan-followup/Form/UserInfoForm/RealTableContent.jsx new file mode 100644 index 0000000..cd6e622 --- /dev/null +++ b/src/components/dashboard/loan-followup/Form/UserInfoForm/RealTableContent.jsx @@ -0,0 +1,353 @@ +import { Chip, DialogContent, DialogTitle, Divider, Grid, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import moment from "jalali-moment"; + +const RealTableContent = ({ rowId, row }) => { + const t = useTranslations(); + return ( + <> + {t("UserInfoDialog.user_info")} + + + + + + + {t("UserInfoDialog.real_person")} + + + + + + + {row.original.id || t("UserInfoDialog.no_info")} + + + + + + + + + + {row.original.project_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.activity_category_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.first_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.last_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.national_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.national_serial_number || + row.original.national_tracking_code || + t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.education_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.occupation_title || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.phone_number || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.telephone_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.birthday + ? moment(row.original.birthday).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.postal_code || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.father_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.gender ? t("UserInfoDialog.female") : t("UserInfoDialog.male")} + + + + + + + + + + + {row.original.province_name || t("UserInfoDialog.no_info")} + + + + + + + + {row.original.city_name} + + + + + + + + + + {row.original.navgan_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.navgan_type || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.user_committed_employment || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.user_existing_employment || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.vehicle_type || t("UserInfoDialog.no_info")} + + + + + + + + + { + (row.original.investment_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", { value: (row.original.investment_amount / 1000000000) }) + : t("UserInfoDialog.toman", { value: (row.original.investment_amount / 1000000) }) + } + + + + + + + + + + + { + (row.original.requested_facility_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.requested_facility_amount / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.requested_facility_amount / 1000000)}) + } + + + + + + + + + { + (row.original.person_share / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.person_share / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.person_share / 1000000)}) + } + + + + + + + + + + + + {row.original.plate_number.split("-")[3] || t("UserInfoDialog.no_info")} + + + + {row.original.plate_number.split("-")[2] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[1] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[0] || t("UserInfoDialog.no_info")} + + + + + + + + + + + + + {row.original.address || t("UserInfoDialog.no_info")} + + + + + + + ); +}; +export default RealTableContent; diff --git a/src/components/dashboard/loan-followup/Form/UserInfoForm/index.jsx b/src/components/dashboard/loan-followup/Form/UserInfoForm/index.jsx new file mode 100644 index 0000000..aa67e15 --- /dev/null +++ b/src/components/dashboard/loan-followup/Form/UserInfoForm/index.jsx @@ -0,0 +1,47 @@ +import { Button, Dialog, DialogActions, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import ContactPageIcon from "@mui/icons-material/ContactPage"; +import LegalTableContent from "./LegalTableContent"; +import RealTableContent from "./RealTableContent"; +const UserInfoForm = ({ rowId, row }) => { + const t = useTranslations(); + const [openUserInfoDialog, setOpenUserInfoDialog] = useState(false); + return ( + <> + + { + setOpenUserInfoDialog(true); + }} + > + + + + + {row.original.is_legal_person === 1 ? ( + + ) : ( + + )} + + + + + + ); +}; +export default UserInfoForm; diff --git a/src/components/dashboard/loan-followup/TableRowActions.jsx b/src/components/dashboard/loan-followup/TableRowActions.jsx index 62a4d73..20e4b4f 100644 --- a/src/components/dashboard/loan-followup/TableRowActions.jsx +++ b/src/components/dashboard/loan-followup/TableRowActions.jsx @@ -1,18 +1,17 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import ReferPassengerBoss from "@/components/dashboard/loan-followup/Form/ReferPassengerBoss"; +import UserInfoForm from "./Form/UserInfoForm"; +import PlanningCouncilForm from "@/components/dashboard/loan-followup/Form/PlanningCouncilForm"; -const TableRow = ({row, mutate}) => { +const TableRow = ({ row, mutate }) => { return ( - - { - row.original.state_id === 11 || row.original.state_id === 16 ? ( - - ) : null - } + + + + {row.original.state_id === 11 || row.original.state_id === 16 ? ( + + ) : null} ); }; -export default TableRow; \ No newline at end of file +export default TableRow; diff --git a/src/components/dashboard/loan-followup/TableToolbar.jsx b/src/components/dashboard/loan-followup/TableToolbar.jsx index 0eea2f8..7be1e50 100644 --- a/src/components/dashboard/loan-followup/TableToolbar.jsx +++ b/src/components/dashboard/loan-followup/TableToolbar.jsx @@ -1,10 +1,7 @@ -import {Stack} from "@mui/material"; +import { Stack } from "@mui/material"; -const TableToolbar = ({table}) => { - return ( - - - ) -} +const TableToolbar = ({ table }) => { + return ; +}; -export default TableToolbar \ No newline at end of file +export default TableToolbar; diff --git a/src/components/dashboard/loan-followup/index.jsx b/src/components/dashboard/loan-followup/index.jsx index 7455874..a2533b2 100644 --- a/src/components/dashboard/loan-followup/index.jsx +++ b/src/components/dashboard/loan-followup/index.jsx @@ -1,14 +1,14 @@ -import {useTranslations} from "next-intl"; -import {useMemo} from "react"; -import {Box, Typography} from "@mui/material"; +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 { GET_LOAN_FOLLOWUP } from "@/core/data/apiRoutes"; import TableToolbar from "./TableToolbar"; import TableRowActions from "./TableRowActions"; -function DashboardLoanFollowUpComponent () { +function DashboardLoanFollowUpComponent() { const t = useTranslations(); const columns = useMemo( () => [ @@ -19,17 +19,8 @@ function DashboardLoanFollowUpComponent () { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.navgan_id, @@ -38,17 +29,8 @@ function DashboardLoanFollowUpComponent () { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -58,9 +40,7 @@ function DashboardLoanFollowUpComponent () { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -69,17 +49,8 @@ function DashboardLoanFollowUpComponent () { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.shenase_meli, @@ -88,17 +59,8 @@ function DashboardLoanFollowUpComponent () { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_serial_number, @@ -107,17 +69,8 @@ function DashboardLoanFollowUpComponent () { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_tracking_code, @@ -126,14 +79,8 @@ function DashboardLoanFollowUpComponent () { enableColumnFilter: true, datatype: "text", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.birthday, @@ -143,9 +90,10 @@ function DashboardLoanFollowUpComponent () { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {moment(renderedCellValue).locale("fa").format("yyyy/MM/DD")} + Cell: ({ renderedCellValue }) => ( + + {moment(renderedCellValue).locale("fa").format("yyyy/MM/DD")} + ), }, { @@ -155,12 +103,8 @@ function DashboardLoanFollowUpComponent () { enableColumnFilter: true, datatype: "text", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - ], - Cell: ({renderedCellValue}) => ( + columnFilterModeOptions: ["equals", "notEquals", "contains"], + Cell: ({ renderedCellValue }) => ( {Number(renderedCellValue).toLocaleString()} ), }, @@ -172,9 +116,7 @@ function DashboardLoanFollowUpComponent () { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.province_name, @@ -184,9 +126,7 @@ function DashboardLoanFollowUpComponent () { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.city_name, @@ -196,27 +136,22 @@ function DashboardLoanFollowUpComponent () { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + 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}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { @@ -226,17 +161,8 @@ function DashboardLoanFollowUpComponent () { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -244,15 +170,13 @@ function DashboardLoanFollowUpComponent () { header: t("LoanFollowUp.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + ); } -export default DashboardLoanFollowUpComponent \ No newline at end of file +export default DashboardLoanFollowUpComponent; diff --git a/src/components/dashboard/loan-history/Buttons/printExcel.jsx b/src/components/dashboard/loan-history/Buttons/printExcel.jsx index 914e72f..9afd5e8 100644 --- a/src/components/dashboard/loan-history/Buttons/printExcel.jsx +++ b/src/components/dashboard/loan-history/Buttons/printExcel.jsx @@ -1,18 +1,18 @@ -import {Button, CircularProgress} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useMemo, useState} from "react"; +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 { EXPORT_LOAN_HISTORY } from "@/core/data/apiRoutes"; import moment from "jalali-moment"; -import FileSaver from 'file-saver'; -import DescriptionIcon from '@mui/icons-material/Description'; +import FileSaver from "file-saver"; +import DescriptionIcon from "@mui/icons-material/Description"; -const PrintExcel = ({table}) => { +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 [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(); @@ -24,30 +24,32 @@ const PrintExcel = ({table}) => { } } return { - ...filter, fn: columnFilterFns[filter.id], datatype: datatype, + ...filter, + fn: columnFilterFns[filter.id], + datatype: datatype, }; }); - params.set("start", '0'); + params.set("start", "0"); params.set("filters", JSON.stringify(filters ?? [])); params.set("sorting", JSON.stringify(sorting ?? [])); return params; - }, [columnFilters, columnFilterFns, sorting, columns,]); - + }, [columnFilters, columnFilterFns, sorting, columns]); const clickHandler = () => { - setLoading(true) - requestServer(`${EXPORT_LOAN_HISTORY}?${filterParams}`, 'get', { + 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) + 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 \ No newline at end of file +export default PrintExcel; diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx b/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx index d4d214c..eda6f7c 100644 --- a/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx +++ b/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx @@ -1,9 +1,9 @@ -import {Button, DialogActions, DialogContent,} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useFormik} from "formik"; +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"; -const HistoryContent = ({mutate, setOpenConfirmDialog, rowId}) => { +const HistoryContent = ({ mutate, setOpenConfirmDialog, rowId }) => { const t = useTranslations(); const formik = useFormik({}); @@ -11,16 +11,20 @@ const HistoryContent = ({mutate, setOpenConfirmDialog, rowId}) => { return ( <> - + - - ) - -} -export default HistoryContent \ No newline at end of file + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/PrintHistory.jsx b/src/components/dashboard/loan-history/Form/HistoryForm/PrintHistory.jsx index 821a31f..dfcce4a 100644 --- a/src/components/dashboard/loan-history/Form/HistoryForm/PrintHistory.jsx +++ b/src/components/dashboard/loan-history/Form/HistoryForm/PrintHistory.jsx @@ -1,11 +1,11 @@ -import {Button, CircularProgress} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +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 DescriptionIcon from "@mui/icons-material/Description"; import Link from "next/link"; -const PrintHistory = ({attachment}) => { +const PrintHistory = ({ attachment }) => { const t = useTranslations(); return ( ); -} +}; -export default PrintHistory \ No newline at end of file +export default PrintHistory; diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx b/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx index a8b45ad..c794422 100644 --- a/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx +++ b/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx @@ -8,92 +8,127 @@ import { TableContainer, TableHead, TableRow, - Typography + Typography, } from "@mui/material"; -import {useTranslations} from "next-intl"; -import {GET_HISTORY_DETAIL} from "@/core/data/apiRoutes"; +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 useRequest from "@/lib/app/hooks/useRequest"; -import {useEffect, useState} from "react"; +import { useEffect, useState } from "react"; const action_name = { - "confirm" : "تایید", - "reject":"عدم تایید", - "refer":"ارجاع", - "reserve" : "رزرو" -} + confirm: "تایید", + reject: "عدم تایید", + refer: "ارجاع", + reserve: "رزرو", +}; -const TableContent = ({rowId}) => { +const TableContent = ({ rowId }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true, notification: false}) + 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); - }) + 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} - {moment(latest_history.created_at).locale("fa").format("HH:mm | yyyy/MM/DD")} - {latest_history.expert.position} - {latest_history.previous_state_name} - {action_name[latest_history.action]} - {latest_history.expert_description} - - {latest_history.attachments.map((attachment, index) => )} - - ) - })} - -
-
-
)))} + 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} + + {moment(latest_history.created_at) + .locale("fa") + .format("HH:mm | yyyy/MM/DD")} + + {latest_history.expert.position} + {latest_history.previous_state_name} + {action_name[latest_history.action]} + {latest_history.expert_description} + + {latest_history.attachments.map((attachment, index) => ( + + ))} + + + ); + })} + +
+
+
+ )}
- - ) -} -export default TableContent \ No newline at end of file + ); +}; +export default TableContent; diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/index.jsx b/src/components/dashboard/loan-history/Form/HistoryForm/index.jsx index a7f8eef..872128a 100644 --- a/src/components/dashboard/loan-history/Form/HistoryForm/index.jsx +++ b/src/components/dashboard/loan-history/Form/HistoryForm/index.jsx @@ -1,10 +1,10 @@ -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 { 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"; -const History = ({rowId, mutate}) => { +const History = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,19 +13,27 @@ const History = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("LoanHistory.history")} - + - ) - -} -export default History; \ No newline at end of file + ); +}; +export default History; diff --git a/src/components/dashboard/loan-history/TableRowActions.jsx b/src/components/dashboard/loan-history/TableRowActions.jsx index d0a967f..ab4f3a8 100644 --- a/src/components/dashboard/loan-history/TableRowActions.jsx +++ b/src/components/dashboard/loan-history/TableRowActions.jsx @@ -1,14 +1,10 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import History from "@/components/dashboard/loan-history/Form/HistoryForm"; -const TableRow = ({row, mutate}) => { +const TableRow = ({ row, mutate }) => { return ( - - + + ); }; diff --git a/src/components/dashboard/loan-history/TableToolbar.jsx b/src/components/dashboard/loan-history/TableToolbar.jsx index a79df69..76d7002 100644 --- a/src/components/dashboard/loan-history/TableToolbar.jsx +++ b/src/components/dashboard/loan-history/TableToolbar.jsx @@ -1,12 +1,12 @@ -import {Stack} from "@mui/material"; +import { Stack } from "@mui/material"; import PrintExcel from "@/components/dashboard/loan-history/Buttons/printExcel"; -const TableToolbar = ({table}) => { +const TableToolbar = ({ table }) => { return ( - + - ) -} + ); +}; -export default TableToolbar \ No newline at end of file +export default TableToolbar; diff --git a/src/components/dashboard/loan-history/index.jsx b/src/components/dashboard/loan-history/index.jsx index a7767b5..3b9e0c1 100644 --- a/src/components/dashboard/loan-history/index.jsx +++ b/src/components/dashboard/loan-history/index.jsx @@ -1,7 +1,7 @@ -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 { 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"; @@ -19,17 +19,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.is_legal_person, @@ -39,9 +30,10 @@ function DashboardLoanHistoryComponent() { datatype: "numeric", filterFn: "equals", columnFilterModeOptions: ["equals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue === 1 ? `${t("LoanHistory.hoghoghi")}` : `${t("LoanHistory.haghighi")}`} + Cell: ({ renderedCellValue }) => ( + + {renderedCellValue === 1 ? `${t("LoanHistory.hoghoghi")}` : `${t("LoanHistory.haghighi")}`} + ), }, { @@ -51,17 +43,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -71,9 +54,7 @@ function DashboardLoanHistoryComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -82,17 +63,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.shenase_meli, @@ -101,17 +73,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.province_name, @@ -121,9 +84,7 @@ function DashboardLoanHistoryComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.city_name, @@ -133,9 +94,7 @@ function DashboardLoanHistoryComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.postal_code, @@ -144,32 +103,23 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "text", filterFn: "contains", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + 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}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { @@ -179,17 +129,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.statement_count, @@ -198,12 +139,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.navgan_capacity, @@ -212,17 +149,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.manufacture_date, @@ -231,17 +159,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.vehicle_type, @@ -251,9 +170,7 @@ function DashboardLoanHistoryComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.plate_number, @@ -263,24 +180,36 @@ function DashboardLoanHistoryComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - - - {renderedCellValue.split('-')[3]} + Cell: ({ renderedCellValue }) => ( + + + {renderedCellValue.split("-")[3]} - - {renderedCellValue.split('-')[2]} - {renderedCellValue.split('-')[1]} - {renderedCellValue.split('-')[0]} + + + {renderedCellValue.split("-")[2]} + + + {renderedCellValue.split("-")[1]} + + + {renderedCellValue.split("-")[0]} + ), @@ -292,17 +221,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_bank, @@ -311,17 +231,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_gov, @@ -330,17 +241,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_person, @@ -349,17 +251,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.physical_progress, @@ -368,17 +261,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.repayment_period, @@ -387,17 +271,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.sakht_period, @@ -406,12 +281,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.tanafos_period, @@ -420,12 +291,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.committed_employment, @@ -434,17 +301,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.existing_employment, @@ -453,17 +311,8 @@ function DashboardLoanHistoryComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -473,15 +322,13 @@ function DashboardLoanHistoryComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +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 [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(); @@ -24,30 +24,32 @@ const PrintExcel = ({table}) => { } } return { - ...filter, fn: columnFilterFns[filter.id], datatype: datatype, + ...filter, + fn: columnFilterFns[filter.id], + datatype: datatype, }; }); - params.set("start", '0'); + params.set("start", "0"); params.set("filters", JSON.stringify(filters ?? [])); params.set("sorting", JSON.stringify(sorting ?? [])); return params; - }, [columnFilters, columnFilterFns, sorting, columns,]); - + }, [columnFilters, columnFilterFns, sorting, columns]); const clickHandler = () => { - setLoading(true) - requestServer(`${EXPORT_LOAN_MANAGEMENT_HISTORY}?${filterParams}`, 'get', { + setLoading(true); + requestServer(`${EXPORT_LOAN_MANAGEMENT_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) + 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 \ No newline at end of file +export default PrintExcel; diff --git a/src/components/dashboard/navgan-loan-management/Form/UpdateForm/UpdateContent.jsx b/src/components/dashboard/navgan-loan-management/Form/UpdateForm/UpdateContent.jsx index 540a7c8..c898fb3 100644 --- a/src/components/dashboard/navgan-loan-management/Form/UpdateForm/UpdateContent.jsx +++ b/src/components/dashboard/navgan-loan-management/Form/UpdateForm/UpdateContent.jsx @@ -1,4 +1,4 @@ -import {UPDATE_LOAN_MANAGEMENT_NAVGAN} from "@/core/data/apiRoutes"; +import { UPDATE_LOAN_MANAGEMENT_NAVGAN } from "@/core/data/apiRoutes"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; import useLoanStateNavgan from "@/lib/prefetchDataTable/hooks/useLoanStateNavgan"; @@ -12,52 +12,54 @@ import { MenuItem, Select, Stack, - TextField -} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; + TextField, +} from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -const UpdateContent = ({rowId, mutate, setOpenConfirmDialog}) => { +const UpdateContent = ({ rowId, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); - const {loan_state_navgan} = useLoanStateNavgan() - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const { loan_state_navgan } = useLoanStateNavgan(); + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("UpdateDialog.description_error")), - next_state_id: Yup.number().required(t("UpdateDialog.next-state-id-error")) + next_state_id: Yup.number().required(t("UpdateDialog.next-state-id-error")), }); const formik = useFormik({ initialValues: { description: "", - next_state_id: "" + next_state_id: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("expert_description", values.description); formData.append("next_state_id", values.next_state_id); - requestServer(`${UPDATE_LOAN_MANAGEMENT_NAVGAN}/${rowId}`, 'post', { + requestServer(`${UPDATE_LOAN_MANAGEMENT_NAVGAN}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) + formik.setFieldValue("description", event.target.value); }; const handleNextStateIDChange = (event) => { - formik.setFieldValue("next_state_id", event.target.value) + formik.setFieldValue("next_state_id", event.target.value); }; return ( <> @@ -73,20 +75,17 @@ const UpdateContent = ({rowId, mutate, setOpenConfirmDialog}) => { onChange={handleDescriptionChange} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} /> + error={formik.touched.next_state_id && Boolean(formik.errors.next_state_id)} + fullWidth + > {t("UpdateDialog.next-state-id")} {formik.touched.next_state_id && formik.errors.next_state_id} @@ -110,16 +113,25 @@ const UpdateContent = ({rowId, mutate, setOpenConfirmDialog}) => { - - - ) -} -export default UpdateContent \ No newline at end of file + ); +}; +export default UpdateContent; diff --git a/src/components/dashboard/navgan-loan-management/Form/UpdateForm/index.jsx b/src/components/dashboard/navgan-loan-management/Form/UpdateForm/index.jsx index 321a709..e4cebb1 100644 --- a/src/components/dashboard/navgan-loan-management/Form/UpdateForm/index.jsx +++ b/src/components/dashboard/navgan-loan-management/Form/UpdateForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; -import ChangeCircleIcon from '@mui/icons-material/ChangeCircle'; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; +import { useState } from "react"; import UpdateContent from "./UpdateContent"; -const Update = ({rowId, mutate}) => { +const Update = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,18 +13,25 @@ const Update = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("UpdateDialog.update")} - + - ) -} -export default Update \ No newline at end of file + ); +}; +export default Update; diff --git a/src/components/dashboard/navgan-loan-management/TableRowActions.jsx b/src/components/dashboard/navgan-loan-management/TableRowActions.jsx index a9d524c..efb3fc6 100644 --- a/src/components/dashboard/navgan-loan-management/TableRowActions.jsx +++ b/src/components/dashboard/navgan-loan-management/TableRowActions.jsx @@ -1,14 +1,10 @@ -import {Box} from "@mui/material"; -import Update from "./Form/UpdateForm" - -const TableRowActions = ({row, mutate}) => { +import { Box } from "@mui/material"; +import Update from "./Form/UpdateForm"; +const TableRowActions = ({ row, mutate }) => { return ( - - + + ); }; diff --git a/src/components/dashboard/navgan-loan-management/TableToolbar.jsx b/src/components/dashboard/navgan-loan-management/TableToolbar.jsx index ea08f96..2ad283e 100644 --- a/src/components/dashboard/navgan-loan-management/TableToolbar.jsx +++ b/src/components/dashboard/navgan-loan-management/TableToolbar.jsx @@ -1,12 +1,12 @@ -import {Stack} from "@mui/material"; +import { Stack } from "@mui/material"; import PrintExcel from "@/components/dashboard/navgan-loan-management/Buttons/printExcel"; -const TableToolbar = ({table}) => { +const TableToolbar = ({ table }) => { return ( - + - ) -} + ); +}; -export default TableToolbar \ No newline at end of file +export default TableToolbar; diff --git a/src/components/dashboard/navgan-loan-management/index.jsx b/src/components/dashboard/navgan-loan-management/index.jsx index cd38fad..ef3c4d3 100644 --- a/src/components/dashboard/navgan-loan-management/index.jsx +++ b/src/components/dashboard/navgan-loan-management/index.jsx @@ -1,7 +1,7 @@ -import {Box, Stack, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_LOAN_MANAGEMENT_NAVGAN} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Stack, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_LOAN_MANAGEMENT_NAVGAN } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import DataTable from "@/core/components/DataTable"; import moment from "jalali-moment"; @@ -20,17 +20,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.is_legal_person, @@ -40,9 +31,12 @@ function DashboardNavganLoanManagementComponent() { datatype: "numeric", filterFn: "equals", columnFilterModeOptions: ["equals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue === 1 ? `${t("NavganLoanManagement.hoghoghi")}` : `${t("NavganLoanManagement.haghighi")}`} + Cell: ({ renderedCellValue }) => ( + + {renderedCellValue === 1 + ? `${t("NavganLoanManagement.hoghoghi")}` + : `${t("NavganLoanManagement.haghighi")}`} + ), }, { @@ -52,17 +46,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -72,9 +57,7 @@ function DashboardNavganLoanManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -83,17 +66,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.shenase_meli, @@ -102,17 +76,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.province_name, @@ -122,9 +87,7 @@ function DashboardNavganLoanManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.city_name, @@ -134,27 +97,22 @@ function DashboardNavganLoanManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("NavganLoanManagement.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { @@ -164,17 +122,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.statement_count, @@ -183,12 +132,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.navgan_capacity, @@ -197,17 +142,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.manufacture_date, @@ -216,17 +152,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.vehicle_type, @@ -236,9 +163,7 @@ function DashboardNavganLoanManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.plate_number, @@ -248,24 +173,36 @@ function DashboardNavganLoanManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - - - {renderedCellValue.split('-')[3]} + Cell: ({ renderedCellValue }) => ( + + + {renderedCellValue.split("-")[3]} - - {renderedCellValue.split('-')[2]} - {renderedCellValue.split('-')[1]} - {renderedCellValue.split('-')[0]} + + + {renderedCellValue.split("-")[2]} + + + {renderedCellValue.split("-")[1]} + + + {renderedCellValue.split("-")[0]} + ), @@ -277,17 +214,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_bank, @@ -296,17 +224,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_gov, @@ -315,17 +234,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_person, @@ -334,17 +244,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.physical_progress, @@ -353,17 +254,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.repayment_period, @@ -372,17 +264,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.sakht_period, @@ -391,12 +274,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.tanafos_period, @@ -405,12 +284,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.committed_employment, @@ -419,17 +294,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.existing_employment, @@ -438,17 +304,8 @@ function DashboardNavganLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -458,16 +315,14 @@ function DashboardNavganLoanManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +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 [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(); @@ -24,30 +24,32 @@ const PrintExcel = ({table}) => { } } return { - ...filter, fn: columnFilterFns[filter.id], datatype: datatype, + ...filter, + fn: columnFilterFns[filter.id], + datatype: datatype, }; }); - params.set("start", '0'); + params.set("start", "0"); params.set("filters", JSON.stringify(filters ?? [])); params.set("sorting", JSON.stringify(sorting ?? [])); return params; - }, [columnFilters, columnFilterFns, sorting, columns,]); - + }, [columnFilters, columnFilterFns, sorting, columns]); const clickHandler = () => { - setLoading(true) - requestServer(`${EXPORT_NAVGAN_PROVINCE_MANAGER}?${filterParams}`, 'get', { + setLoading(true); + requestServer(`${EXPORT_NAVGAN_PROVINCE_MANAGER}?${filterParams}`, "get", { auth: true, - requestOptions: {responseType: 'blob'} - }).then((response) => { - const filename = `خروجی کارتابل بررسی وام های تبصره 18 تاریخ_${moment().format('jYYYY_jMM_jDD')}.xlsx`; - FileSaver.saveAs(response.data, filename); - }).catch(() => { - }).finally(() => { - setLoading(false) + requestOptions: { responseType: "blob" }, }) - } - + .then((response) => { + const filename = `خروجی کارتابل بررسی وام های تبصره 18 تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`; + FileSaver.saveAs(response.data, filename); + }) + .catch(() => {}) + .finally(() => { + setLoading(false); + }); + }; return ( - ) -} + ); +}; -export default PrintExcel \ No newline at end of file +export default PrintExcel; diff --git a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx index 312bbf2..aa4efbd 100644 --- a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx @@ -10,25 +10,25 @@ import { LinearProgress, Stack, TextField, - Typography -} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {CONFIRM_NAVGAN_PROVINCE_MANAGER, CONFIRM_PROVINCE_MANAGER_DETAILS} from "@/core/data/apiRoutes"; -import {useEffect, useState} from "react"; + Typography, +} from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { CONFIRM_NAVGAN_PROVINCE_MANAGER, CONFIRM_PROVINCE_MANAGER_DETAILS } from "@/core/data/apiRoutes"; +import { useEffect, useState } from "react"; import * as Yup from "yup"; import CustomAccordion from "@/core/components/CustomAccordion"; import ImageContent from "@/core/components/ImageContent"; import NumberShowBox from "@/core/components/NumberShowBox"; -const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeClick}) => { +const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog, handleSizeChangeClick }) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - const requestServer = useRequest({auth: true, notification: false}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true, notification: false }); + const { update_notification } = useNotification(); const [attachmentsData, setAttachmentsData] = useState([]); const [accordionStates, setAccordionStates] = useState([]); const [hasImageShown, setHasImageShown] = useState(false); @@ -38,101 +38,105 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl const [isSkeleton, setIsSkeleton] = useState(false); const validationSchema = Yup.object().shape({ - confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error")) - .test('fileSize', `${t("NavganProvinceManager.upload_file_unit")}`, (value) => { - if (!value) return true + confirm_img: Yup.mixed() + .notRequired(t("ConfirmDialog.approved_amount_error")) + .test("fileSize", `${t("NavganProvinceManager.upload_file_unit")}`, (value) => { + if (!value) return true; return value.size <= 5 * 1024 * 1024; }) - .test('fileType', `${t("NavganProvinceManager.upload_file_format")}`, (value) => { - if (!value) return true - const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types + .test("fileType", `${t("NavganProvinceManager.upload_file_format")}`, (value) => { + if (!value) return true; + const allowedTypes = ["image/jpg", "image/jpeg", "image/png", "application/pdf"]; // Define your allowed file types return allowedTypes.includes(value.type); - }) - }) + }), + }); useEffect(() => { - requestServer(`${CONFIRM_PROVINCE_MANAGER_DETAILS}/${rowId}`, 'get') + requestServer(`${CONFIRM_PROVINCE_MANAGER_DETAILS}/${rowId}`, "get") .then((response) => { if (response.data.data.latest_histories.length !== 0) { - let latest_attachments = [] - let attachments = [] + let latest_attachments = []; + let attachments = []; response.data.data.latest_histories.map((allAttachment) => { if (allAttachment.previous_state_id === 4 || allAttachment.previous_state_id === 5) { if (!latest_attachments.includes(allAttachment.previous_state_id)) { - attachments = [...attachments, ...allAttachment.attachments] - latest_attachments.push(allAttachment.previous_state_id) + attachments = [...attachments, ...allAttachment.attachments]; + latest_attachments.push(allAttachment.previous_state_id); } } setDetailsData(response.data); setAttachmentsData(attachments); - }) + }); } }) - .catch(() => { - }).finally(() => { - setLoading(false); - }); + .catch(() => {}) + .finally(() => { + setLoading(false); + }); }, []); useEffect(() => { if (attachmentsData.length !== 0) { - const booleanData = Array.from({length: attachmentsData.length}, () => false); + const booleanData = Array.from({ length: attachmentsData.length }, () => false); setAccordionStates(booleanData); } }, [attachmentsData]); const handleAccordionChange = (index) => { - const newAccordionStates = accordionStates.map((state, i) => i === index ? !state : false); + const newAccordionStates = accordionStates.map((state, i) => (i === index ? !state : false)); setAccordionStates(newAccordionStates); if (!newAccordionStates[index]) { - handleSizeChangeClick('sm'); + handleSizeChangeClick("sm"); setHasImageShown(false); - setIsSkeleton(false) + setIsSkeleton(false); } else { - handleSizeChangeClick('xl'); + handleSizeChangeClick("xl"); setHasImageShown(true); - setImageLink(attachmentsData[index]) - setIsSkeleton(true) + setImageLink(attachmentsData[index]); + setIsSkeleton(true); } }; const formik = useFormik({ initialValues: { description: "", - confirm_img: null - }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + confirm_img: null, + }, + validationSchema, + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); if (values.description !== "") formData.append("expert_description", values.description); if (values.confirm_img != null) { const attachments = [ { title: "فایل ضمیمه کارتابل بررسی وام های تبصره 18", - file: values.confirm_img - } + file: values.confirm_img, + }, ]; attachments.forEach((attachment, index) => { formData.append(`attachment[${index}][title]`, attachment.title); formData.append(`attachment[${index}][file]`, attachment.file); }); } - requestServer(`${CONFIRM_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', { + requestServer(`${CONFIRM_NAVGAN_PROVINCE_MANAGER}/${rowId}`, "post", { data: formData, - notification: true - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + notification: true, + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) + formik.setFieldValue("description", event.target.value); }; const handleUploadChange = (event) => { @@ -145,7 +149,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl setfileName(fileName); formik.setFieldValue("confirm_img", uploadedFile).then(() => { formik.setFieldTouched("confirm_img", true); - }) + }); setShowAddIcon(false); } }; @@ -172,25 +176,27 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl - {loading ? : + {loading ? ( + + ) : ( <> @@ -211,24 +217,31 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl /> {renderCustomAccordions()} - } + )} - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} + label={ + <> + {t("ConfirmDialog.description")} + {t("ConfirmDialog.optional")} + + } value={formik.values.description} onChange={handleDescriptionChange} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + formik.handleBlur("confirm_img")} - error={ - formik.touched.confirm_img && - Boolean(formik.errors.confirm_img) - } + error={formik.touched.confirm_img && Boolean(formik.errors.confirm_img)} /> - + {formik.touched.confirm_img && formik.errors.confirm_img} - - + + - - - ) - -} -export default ConfirmContent \ No newline at end of file + ); +}; +export default ConfirmContent; diff --git a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/index.jsx b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/index.jsx index e8ca6ba..a2928fc 100644 --- a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/index.jsx @@ -1,16 +1,16 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useEffect, useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useEffect, useState } from "react"; import ConfirmContent from "./ConfirmContent"; -import CallMadeIcon from '@mui/icons-material/CallMade'; -const Confirm = ({rowId, mutate}) => { +import CallMadeIcon from "@mui/icons-material/CallMade"; +const Confirm = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const [dialogSize, setDialogSize] = useState('sm'); + const [dialogSize, setDialogSize] = useState("sm"); useEffect(() => { if (!openConfirmDialog) { - setDialogSize('sm'); + setDialogSize("sm"); } }, [openConfirmDialog]); @@ -23,19 +23,32 @@ const Confirm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("NavganProvinceManager.confirm")} - + - ) - -} -export default Confirm; \ No newline at end of file + ); +}; +export default Confirm; diff --git a/src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx index 9907263..9267c32 100644 --- a/src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx @@ -1,30 +1,31 @@ -import UploadSystem from "@/core/components/UploadSystem" +import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import * as Yup from "yup"; -import {REJECT_NAVGAN_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; +import { REJECT_NAVGAN_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; -const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { +const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), - reject_img: Yup.mixed().notRequired(t("RejectDialog.choose_file")) - .test('fileSize', `${t("NavganProvinceManager.upload_file_unit")}`, (value) => { + reject_img: Yup.mixed() + .notRequired(t("RejectDialog.choose_file")) + .test("fileSize", `${t("NavganProvinceManager.upload_file_unit")}`, (value) => { return !value || (value.size && value.size <= 5 * 1024 * 1024); }) - .test('fileType', `${t("NavganProvinceManager.upload_file_format")}`, (value) => { - const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types + .test("fileType", `${t("NavganProvinceManager.upload_file_format")}`, (value) => { + const allowedTypes = ["image/jpg", "image/jpeg", "image/png", "application/pdf"]; // Define your allowed file types return !value || (value.type && allowedTypes.includes(value.type)); }), }); @@ -32,34 +33,36 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const formik = useFormik({ initialValues: { description: "", - reject_img: null + reject_img: null, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("expert_description", values.description); if (values.reject_img != null) { const attachments = [ { title: "فایل ضمیمه کارتابل بررسی وام های تبصره 18", - file: values.reject_img - } + file: values.reject_img, + }, ]; attachments.forEach((attachment, index) => { formData.append(`attachment[${index}][title]`, attachment.title); formData.append(`attachment[${index}][file]`, attachment.file); }); } - requestServer(`${REJECT_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', { + requestServer(`${REJECT_NAVGAN_PROVINCE_MANAGER}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenRejectDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenRejectDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -77,7 +80,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { setfileName(fileName); formik.setFieldValue("reject_img", uploadedFile).then(() => { formik.setFieldTouched("reject_img", true); - }) + }); setShowAddIcon(false); } }; @@ -95,17 +98,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { setShowAddIcon={setShowAddIcon} showAddIcon={showAddIcon} onBlur={() => formik.handleBlur("reject_img")} - error={ - formik.touched.reject_img && - Boolean(formik.errors.reject_img) - } + error={formik.touched.reject_img && Boolean(formik.errors.reject_img)} /> - + {formik.touched.reject_img && formik.errors.reject_img} - - - ) -} -export default RejectContent \ No newline at end of file + ); +}; +export default RejectContent; diff --git a/src/components/dashboard/navgan-province-manager/Form/RejectForm/index.jsx b/src/components/dashboard/navgan-province-manager/Form/RejectForm/index.jsx index 06608f5..a04d0e1 100644 --- a/src/components/dashboard/navgan-province-manager/Form/RejectForm/index.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/RejectForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import RejectContent from "./RejectContent"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -const Reject = ({rowId, mutate}) => { +const Reject = ({ rowId, mutate }) => { const t = useTranslations(); const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> setOpenRejectDialog(true)}> - + - + {t("RejectDialog.reject")} - + - ) -} -export default Reject \ No newline at end of file + ); +}; +export default Reject; diff --git a/src/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent.jsx b/src/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent.jsx index 64d1dec..4e83971 100644 --- a/src/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent.jsx @@ -1,15 +1,15 @@ 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 { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -import {REFER_NAVGAN_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; +import { REFER_NAVGAN_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; -const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { +const RevertContent = ({ rowId, mutate, setOpenRevertDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RevertDialog.description_error")), @@ -20,19 +20,21 @@ const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { description: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { - requestServer(`${REFER_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', { + onSubmit: (values, { setSubmitting }) => { + requestServer(`${REFER_NAVGAN_PROVINCE_MANAGER}/${rowId}`, "post", { data: { - expert_description: values.description + expert_description: values.description, }, - }).then(() => { - setOpenRevertDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then(() => { + setOpenRevertDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -53,28 +55,35 @@ const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - - - ) -} -export default RevertContent \ No newline at end of file + ); +}; +export default RevertContent; diff --git a/src/components/dashboard/navgan-province-manager/Form/RevertForm/index.jsx b/src/components/dashboard/navgan-province-manager/Form/RevertForm/index.jsx index 5229058..182428d 100644 --- a/src/components/dashboard/navgan-province-manager/Form/RevertForm/index.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/RevertForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import CallReceivedIcon from '@mui/icons-material/CallReceived'; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import CallReceivedIcon from "@mui/icons-material/CallReceived"; import RevertContent from "@/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent"; -const Revert = ({rowId, mutate}) => { +const Revert = ({ rowId, mutate }) => { const t = useTranslations(); const [openRevertDialog, setOpenRevertDialog] = useState(false); return ( <> setOpenRevertDialog(true)}> - + - + {t("NavganProvinceManager.revert")} - + - ) -} -export default Revert \ No newline at end of file + ); +}; +export default Revert; diff --git a/src/components/dashboard/navgan-province-manager/Form/UserInfoForm/LegalTableContent.jsx b/src/components/dashboard/navgan-province-manager/Form/UserInfoForm/LegalTableContent.jsx new file mode 100644 index 0000000..dbabcc4 --- /dev/null +++ b/src/components/dashboard/navgan-province-manager/Form/UserInfoForm/LegalTableContent.jsx @@ -0,0 +1,397 @@ +import { Chip, DialogContent, DialogTitle, Divider, Grid, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import moment from "jalali-moment"; + +const LegalTableContent = ({ rowId, row }) => { + const t = useTranslations(); + return ( + <> + {t("UserInfoDialog.user_info")} + + + + + + + {t("UserInfoDialog.legal_person")} + + + + + + + {row.original.id || t("UserInfoDialog.no_info")} + + + + + + + + + + {row.original.project_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.activity_category_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.first_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.last_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.father_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.gender ? t("UserInfoDialog.female") : t("UserInfoDialog.male")} + + + + + + + + + + + {row.original.national_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.national_serial_number || + row.original.national_tracking_code || + t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.education_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.occupation_title || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.phone_number || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.birthday + ? moment(row.original.birthday).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.province_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.city_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.shenase_meli || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.postal_code || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.company_register_date + ? moment(row.original.company_register_date).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.register_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.navgan_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.navgan_type || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.company_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.telephone_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.vehicle_type || t("UserInfoDialog.no_info")} + + + + + + + + + { + (row.original.investment_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", { value: (row.original.investment_amount / 1000000000) }) + : t("UserInfoDialog.toman", { value: (row.original.investment_amount / 1000000) }) + } + + + + + + + + + + + { + (row.original.requested_facility_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.requested_facility_amount / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.requested_facility_amount / 1000000)}) + } + + + + + + + + + { + (row.original.person_share / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.person_share / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.person_share / 1000000)}) + } + + + + + + + + + + + {row.original.user_committed_employment || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.user_existing_employment || t("UserInfoDialog.no_info")} + + + + + + + + + + + + {row.original.plate_number.split("-")[3] || t("UserInfoDialog.no_info")} + + + + {row.original.plate_number.split("-")[2] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[1] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[0] || t("UserInfoDialog.no_info")} + + + + + + + + + + + + + {row.original.address || t("UserInfoDialog.no_info")} + + + + + + + ); +}; +export default LegalTableContent; diff --git a/src/components/dashboard/navgan-province-manager/Form/UserInfoForm/RealTableContent.jsx b/src/components/dashboard/navgan-province-manager/Form/UserInfoForm/RealTableContent.jsx new file mode 100644 index 0000000..cd6e622 --- /dev/null +++ b/src/components/dashboard/navgan-province-manager/Form/UserInfoForm/RealTableContent.jsx @@ -0,0 +1,353 @@ +import { Chip, DialogContent, DialogTitle, Divider, Grid, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import moment from "jalali-moment"; + +const RealTableContent = ({ rowId, row }) => { + const t = useTranslations(); + return ( + <> + {t("UserInfoDialog.user_info")} + + + + + + + {t("UserInfoDialog.real_person")} + + + + + + + {row.original.id || t("UserInfoDialog.no_info")} + + + + + + + + + + {row.original.project_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.activity_category_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.first_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.last_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.national_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.national_serial_number || + row.original.national_tracking_code || + t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.education_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.occupation_title || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.phone_number || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.telephone_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.birthday + ? moment(row.original.birthday).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.postal_code || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.father_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.gender ? t("UserInfoDialog.female") : t("UserInfoDialog.male")} + + + + + + + + + + + {row.original.province_name || t("UserInfoDialog.no_info")} + + + + + + + + {row.original.city_name} + + + + + + + + + + {row.original.navgan_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.navgan_type || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.user_committed_employment || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.user_existing_employment || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.vehicle_type || t("UserInfoDialog.no_info")} + + + + + + + + + { + (row.original.investment_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", { value: (row.original.investment_amount / 1000000000) }) + : t("UserInfoDialog.toman", { value: (row.original.investment_amount / 1000000) }) + } + + + + + + + + + + + { + (row.original.requested_facility_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.requested_facility_amount / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.requested_facility_amount / 1000000)}) + } + + + + + + + + + { + (row.original.person_share / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.person_share / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.person_share / 1000000)}) + } + + + + + + + + + + + + {row.original.plate_number.split("-")[3] || t("UserInfoDialog.no_info")} + + + + {row.original.plate_number.split("-")[2] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[1] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[0] || t("UserInfoDialog.no_info")} + + + + + + + + + + + + + {row.original.address || t("UserInfoDialog.no_info")} + + + + + + + ); +}; +export default RealTableContent; diff --git a/src/components/dashboard/navgan-province-manager/Form/UserInfoForm/index.jsx b/src/components/dashboard/navgan-province-manager/Form/UserInfoForm/index.jsx new file mode 100644 index 0000000..aa67e15 --- /dev/null +++ b/src/components/dashboard/navgan-province-manager/Form/UserInfoForm/index.jsx @@ -0,0 +1,47 @@ +import { Button, Dialog, DialogActions, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import ContactPageIcon from "@mui/icons-material/ContactPage"; +import LegalTableContent from "./LegalTableContent"; +import RealTableContent from "./RealTableContent"; +const UserInfoForm = ({ rowId, row }) => { + const t = useTranslations(); + const [openUserInfoDialog, setOpenUserInfoDialog] = useState(false); + return ( + <> + + { + setOpenUserInfoDialog(true); + }} + > + + + + + {row.original.is_legal_person === 1 ? ( + + ) : ( + + )} + + + + + + ); +}; +export default UserInfoForm; diff --git a/src/components/dashboard/navgan-province-manager/TableRowActions.jsx b/src/components/dashboard/navgan-province-manager/TableRowActions.jsx index c5b1843..79afcbc 100644 --- a/src/components/dashboard/navgan-province-manager/TableRowActions.jsx +++ b/src/components/dashboard/navgan-province-manager/TableRowActions.jsx @@ -1,24 +1,16 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import Confirm from "./Form/ConfirmForm"; import Reject from "./Form/RejectForm"; import Revert from "@/components/dashboard/navgan-province-manager/Form/RevertForm"; +import UserInfoForm from "./Form/UserInfoForm"; -const TableRow = ({row, mutate}) => { - +const TableRow = ({ row, mutate }) => { return ( - - - - + + + + + ); }; diff --git a/src/components/dashboard/navgan-province-manager/TableToolbar.jsx b/src/components/dashboard/navgan-province-manager/TableToolbar.jsx index 44a75d9..0a4ba8c 100644 --- a/src/components/dashboard/navgan-province-manager/TableToolbar.jsx +++ b/src/components/dashboard/navgan-province-manager/TableToolbar.jsx @@ -1,13 +1,12 @@ -import {Stack} from "@mui/material"; +import { Stack } from "@mui/material"; import PrintExcel from "@/components/dashboard/navgan-province-manager/Buttons/printExcel"; -const TableToolbar = ({table}) => { - +const TableToolbar = ({ table }) => { return ( - + - ) -} + ); +}; -export default TableToolbar \ No newline at end of file +export default TableToolbar; diff --git a/src/components/dashboard/navgan-province-manager/index.jsx b/src/components/dashboard/navgan-province-manager/index.jsx index 744ed31..2fa31be 100644 --- a/src/components/dashboard/navgan-province-manager/index.jsx +++ b/src/components/dashboard/navgan-province-manager/index.jsx @@ -1,7 +1,7 @@ -import {Box, Stack, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_NAVGAN_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Stack, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_NAVGAN_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import moment from "jalali-moment"; import DataTable from "@/core/components/DataTable"; @@ -20,17 +20,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.is_legal_person, @@ -40,9 +31,12 @@ function DashboardNavganProvinceManagerComponent() { datatype: "numeric", filterFn: "equals", columnFilterModeOptions: ["equals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue === 1 ? `${t("NavganProvinceManager.hoghoghi")}` : `${t("NavganProvinceManager.haghighi")}`} + Cell: ({ renderedCellValue }) => ( + + {renderedCellValue === 1 + ? `${t("NavganProvinceManager.hoghoghi")}` + : `${t("NavganProvinceManager.haghighi")}`} + ), }, { @@ -52,17 +46,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -72,9 +57,7 @@ function DashboardNavganProvinceManagerComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -83,17 +66,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.shenase_meli, @@ -102,17 +76,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.province_name, @@ -122,9 +87,7 @@ function DashboardNavganProvinceManagerComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.city_name, @@ -134,27 +97,22 @@ function DashboardNavganProvinceManagerComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("NavganProvinceManager.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { @@ -164,17 +122,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.statement_count, @@ -183,12 +132,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.vehicle_type, @@ -198,9 +143,7 @@ function DashboardNavganProvinceManagerComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.plate_number, @@ -210,24 +153,36 @@ function DashboardNavganProvinceManagerComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - - - {renderedCellValue.split('-')[3]} + Cell: ({ renderedCellValue }) => ( + + + {renderedCellValue.split("-")[3]} - - {renderedCellValue.split('-')[2]} - {renderedCellValue.split('-')[1]} - {renderedCellValue.split('-')[0]} + + + {renderedCellValue.split("-")[2]} + + + {renderedCellValue.split("-")[1]} + + + {renderedCellValue.split("-")[0]} + ), @@ -239,17 +194,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_bank, @@ -258,17 +204,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_gov, @@ -277,17 +214,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_person, @@ -296,17 +224,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.physical_progress, @@ -315,17 +234,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.repayment_period, @@ -334,17 +244,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.sakht_period, @@ -353,12 +254,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.tanafos_period, @@ -367,12 +264,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.committed_employment, @@ -381,17 +274,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.existing_employment, @@ -400,17 +284,8 @@ function DashboardNavganProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -418,16 +293,14 @@ function DashboardNavganProvinceManagerComponent() { header: t("NavganProvinceManager.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { const t = useTranslations(); - const requestServer = useRequest() + const requestServer = useRequest(); const filterItem = [ - {type: "province", type_fa: "استان", multiple: false}, - {type: "year", type_fa: "سال", multiple: false} + { type: "province", type_fa: "استان", multiple: false }, + { type: "year", type_fa: "سال", multiple: false }, ]; const filter_by_province = filterItem.find((item) => item.type === "province"); const filter_by_year = filterItem.find((item) => item.type === "year"); - const [filteredText, setFilteredText] = useState({province: "", year: ""}); + const [filteredText, setFilteredText] = useState({ province: "", year: "" }); const formik = useFormik({ initialValues: { ...(filter_by_year && { - date: filter_by_year.multiple ? [] : `${moment().format('jYYYY')}` + date: filter_by_year.multiple ? [] : `${moment().format("jYYYY")}`, }), ...(filter_by_province && { - province_id: filter_by_province.multiple ? [] : "" + province_id: filter_by_province.multiple ? [] : "", }), - from_date: periodOfYear(moment().format('jYYYY')).from, - to_date: periodOfYear(moment().format('jYYYY')).to - }, onSubmit: (values, {setSubmitting}) => { + from_date: periodOfYear(moment().format("jYYYY")).from, + to_date: periodOfYear(moment().format("jYYYY")).to, + }, + onSubmit: (values, { setSubmitting }) => { const province = values.province_id; const fields = [ - values.from_date ? {key: "from_date", value: values.from_date} : null, - values.to_date ? {key: "to_date", value: values.to_date} : null, + values.from_date ? { key: "from_date", value: values.from_date } : null, + values.to_date ? { key: "to_date", value: values.to_date } : null, ...(Array.isArray(province) - ? province.length !== 0 - ? province.map((item, index) => ({key: `province_id[${index}]`, value: item})) - : [] - : province - ? [{key: "province_id", value: province}] - : [] - ), + ? province.length !== 0 + ? province.map((item, index) => ({ key: `province_id[${index}]`, value: item })) + : [] + : province + ? [{ key: "province_id", value: province }] + : []), ].filter(Boolean); - const queryString = fields.length !== 0 - ? `?${fields.map((option) => `${option.key}=${option.value}`).join('&')}` - : ''; - setSubmitting(true) - requestServer(`${GET_EXPORT}${queryString}`, 'GET', { + const queryString = + fields.length !== 0 ? `?${fields.map((option) => `${option.key}=${option.value}`).join("&")}` : ""; + setSubmitting(true); + requestServer(`${GET_EXPORT}${queryString}`, "GET", { auth: true, notification: false, - requestOptions: {responseType: 'blob'} + requestOptions: { responseType: "blob" }, }) .then((response) => { - const filename = `گزارش درخواست های وام ناوگان تاریخ_${moment().format('jYYYY_jMM_jDD')}.xlsx`; + const filename = `گزارش درخواست های وام ناوگان تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`; FileSaver.saveAs(response.data, filename); - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); return ( - - + + - - - - + + + + {t("filters.excel_export")} - + - - {filter_by_province ? - : "" - } - {filter_by_year ? - : "" - } + }} + > + + {filter_by_province ? ( + + ) : ( + "" + )} + {filter_by_year ? ( + + ) : ( + "" + )} - @@ -129,7 +145,7 @@ const ExcelExport = () => { - ) + ); }; -export default ExcelExport; \ No newline at end of file +export default ExcelExport; diff --git a/src/components/dashboard/old-reports/Filter/ProvinceFilter.jsx b/src/components/dashboard/old-reports/Filter/ProvinceFilter.jsx index 7dacacc..a785384 100644 --- a/src/components/dashboard/old-reports/Filter/ProvinceFilter.jsx +++ b/src/components/dashboard/old-reports/Filter/ProvinceFilter.jsx @@ -7,47 +7,48 @@ import { MenuItem, OutlinedInput, Select, - Typography + Typography, } from "@mui/material"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import useProvince from "@/lib/app/hooks/useProvince"; -import ClearIcon from '@mui/icons-material/Clear'; +import ClearIcon from "@mui/icons-material/Clear"; const provinceList = [ - {name: "قزوین", id: 1}, - {name: "تبریز", id: 2}, - {name: "مشهد", id: 3} -] + { name: "قزوین", id: 1 }, + { name: "تبریز", id: 2 }, + { name: "مشهد", id: 3 }, +]; -const ProvinceFilter = ({formik, multiple, setFilteredText}) => { - const {errorProvinceList, isLoadingProvinceList, provinceList} = useProvince(); +const ProvinceFilter = ({ formik, multiple, setFilteredText }) => { + const { errorProvinceList, isLoadingProvinceList, provinceList } = useProvince(); const t = useTranslations(); const provinceChange = (event) => { - const {target: {value}} = event; + const { + target: { value }, + } = event; formik.handleChange(event); - formik.setFieldValue('province_id', value); + formik.setFieldValue("province_id", value); if (Array.isArray(value)) { - const province_names = [] + const province_names = []; value.map((item) => { - province_names.push(provinceList.find(province => province.id === item).name) - }) - setFilteredText(prevState => ({ + province_names.push(provinceList.find((province) => province.id === item).name); + }); + setFilteredText((prevState) => ({ ...prevState, - province: province_names.length !== 0 ? `| ${t("filters.provinces")}: ${province_names.join(' , ')}` : "" + province: + province_names.length !== 0 ? `| ${t("filters.provinces")}: ${province_names.join(" , ")}` : "", })); } else { - const selectedProvince = provinceList.find(province => province.id === value); - setFilteredText(prevState => ({ + const selectedProvince = provinceList.find((province) => province.id === value); + setFilteredText((prevState) => ({ ...prevState, - province: `| ${t("filters.province")}: ${selectedProvince.name}` + province: `| ${t("filters.province")}: ${selectedProvince.name}`, })); } }; - const needAdorment = multiple - ? formik.values.province_id.length === 0 : - formik.values.province_id === ""; + const needAdorment = multiple ? formik.values.province_id.length === 0 : formik.values.province_id === ""; return ( - + {t("filters.choose_province")} - ) + ); }; -export default ProvinceFilter; \ No newline at end of file +export default ProvinceFilter; diff --git a/src/components/dashboard/old-reports/Filter/YearFilter.jsx b/src/components/dashboard/old-reports/Filter/YearFilter.jsx index a18e9db..72cda4c 100644 --- a/src/components/dashboard/old-reports/Filter/YearFilter.jsx +++ b/src/components/dashboard/old-reports/Filter/YearFilter.jsx @@ -1,34 +1,38 @@ -import {Box, Chip, FormControl, InputLabel, MenuItem, OutlinedInput, Select} from "@mui/material"; +import { Box, Chip, FormControl, InputLabel, MenuItem, OutlinedInput, Select } from "@mui/material"; import moment from "jalali-moment"; -import {useTranslations} from "next-intl"; -import {periodOfYear} from "@/core/utils/yearPeriodFinder"; +import { useTranslations } from "next-intl"; +import { periodOfYear } from "@/core/utils/yearPeriodFinder"; -const currentShamsiYear = moment().format('jYYYY'); -const shamsiYearList = Array.from({length: currentShamsiYear - 1399}, (_, index) => (currentShamsiYear - index).toString()); +const currentShamsiYear = moment().format("jYYYY"); +const shamsiYearList = Array.from({ length: currentShamsiYear - 1399 }, (_, index) => + (currentShamsiYear - index).toString() +); -const YearFilter = ({formik, multiple, setFilteredText}) => { +const YearFilter = ({ formik, multiple, setFilteredText }) => { const t = useTranslations(); const yearChange = (event) => { - const {target: {value}} = event; + const { + target: { value }, + } = event; formik.handleChange(event); - formik.setFieldValue('date', value); - const {from, to} = periodOfYear(value); - formik.setFieldValue('from_date', from); - formik.setFieldValue('to_date', to); + formik.setFieldValue("date", value); + const { from, to } = periodOfYear(value); + formik.setFieldValue("from_date", from); + formik.setFieldValue("to_date", to); if (Array.isArray(value)) { - setFilteredText(prevState => ({ + setFilteredText((prevState) => ({ ...prevState, - year: `| ${t("filters.years")}: ${value.join(' , ')}` + year: `| ${t("filters.years")}: ${value.join(" , ")}`, })); } else { - setFilteredText(prevState => ({ + setFilteredText((prevState) => ({ ...prevState, - year: `| ${t("filters.year")}: ${value}` + year: `| ${t("filters.year")}: ${value}`, })); } }; return ( - + {t("filters.choose_year")} - ) + ); }; -export default YearFilter; \ No newline at end of file +export default YearFilter; diff --git a/src/components/dashboard/old-reports/Filter/index.jsx b/src/components/dashboard/old-reports/Filter/index.jsx index f42d2aa..5b0ac80 100644 --- a/src/components/dashboard/old-reports/Filter/index.jsx +++ b/src/components/dashboard/old-reports/Filter/index.jsx @@ -8,137 +8,153 @@ import { IconButton, Stack, Tooltip, - Typography + Typography, } from "@mui/material"; -import {useFormik} from "formik"; +import { useFormik } from "formik"; import ProvinceFilter from "../Filter/ProvinceFilter"; import YearFilter from "../Filter/YearFilter"; -import FilterAltIcon from '@mui/icons-material/FilterAlt'; -import EqualizerIcon from '@mui/icons-material/Equalizer'; -import {useTranslations} from "next-intl"; -import TroubleshootIcon from '@mui/icons-material/Troubleshoot'; -import CachedIcon from '@mui/icons-material/Cached'; -import {useEffect, useState} from "react"; +import FilterAltIcon from "@mui/icons-material/FilterAlt"; +import EqualizerIcon from "@mui/icons-material/Equalizer"; +import { useTranslations } from "next-intl"; +import TroubleshootIcon from "@mui/icons-material/Troubleshoot"; +import CachedIcon from "@mui/icons-material/Cached"; +import { useEffect, useState } from "react"; import moment from "jalali-moment"; -import {periodOfYear} from "@/core/utils/yearPeriodFinder"; +import { periodOfYear } from "@/core/utils/yearPeriodFinder"; -const Filter = ({title, filterItem, setFilterOption, isLoadingReportList, mutate}) => { +const Filter = ({ title, filterItem, setFilterOption, isLoadingReportList, mutate }) => { const t = useTranslations(); const filter_by_province = filterItem.find((item) => item.type === "province"); const filter_by_year = filterItem.find((item) => item.type === "year"); const [expanded, setExpanded] = useState(false); - const [filteredText, setFilteredText] = useState({province: "", year: ""}); + const [filteredText, setFilteredText] = useState({ province: "", year: "" }); const [stepValue, setStepValue] = useState({ ...(filter_by_year && { - date: filter_by_year.multiple ? [] : `${moment().format('jYYYY')}` + date: filter_by_year.multiple ? [] : `${moment().format("jYYYY")}`, }), ...(filter_by_province && { - province_id: filter_by_province.multiple ? [] : "" + province_id: filter_by_province.multiple ? [] : "", }), - from_date: periodOfYear(moment().format('jYYYY')).from, - to_date: periodOfYear(moment().format('jYYYY')).to - }) - + from_date: periodOfYear(moment().format("jYYYY")).from, + to_date: periodOfYear(moment().format("jYYYY")).to, + }); const formik = useFormik({ enableReinitialize: true, - initialValues: stepValue, onSubmit: (values, {setSubmitting}) => { - setStepValue(values) + initialValues: stepValue, + onSubmit: (values, { setSubmitting }) => { + setStepValue(values); const province = values.province_id; const fields = [ - values.from_date ? {key: "from_date", value: values.from_date} : null, - values.to_date ? {key: "to_date", value: values.to_date} : null, + values.from_date ? { key: "from_date", value: values.from_date } : null, + values.to_date ? { key: "to_date", value: values.to_date } : null, ...(Array.isArray(province) - ? province.length !== 0 - ? province.map((item, index) => ({key: `province_id[${index}]`, value: item})) - : [] - : province - ? [{key: "province_id", value: province}] - : [] - ), + ? province.length !== 0 + ? province.map((item, index) => ({ key: `province_id[${index}]`, value: item })) + : [] + : province + ? [{ key: "province_id", value: province }] + : []), ].filter(Boolean); - setFilterOption(fields) + setFilterOption(fields); }, }); useEffect(() => { const province = formik.values.province_id; const fields = [ - formik.values.from_date ? {key: "from_date", value: formik.values.from_date} : null, - formik.values.to_date ? {key: "to_date", value: formik.values.to_date} : null, + formik.values.from_date ? { key: "from_date", value: formik.values.from_date } : null, + formik.values.to_date ? { key: "to_date", value: formik.values.to_date } : null, ...(Array.isArray(province) - ? province.length !== 0 - ? province.map((item, index) => ({key: `province_id[${index}]`, value: item})) - : [] - : province - ? [{key: "province_id", value: province}] - : [] - ), + ? province.length !== 0 + ? province.map((item, index) => ({ key: `province_id[${index}]`, value: item })) + : [] + : province + ? [{ key: "province_id", value: province }] + : []), ].filter(Boolean); - setFilterOption(fields) + setFilterOption(fields); }, []); return ( - { - }} sx={{ - mb: 2, - borderBottom: 2, - borderBottomColor: "divider", - backgroundColor: "#f1f1f1", - }}> - - - - - {title} - + {}} + sx={{ + mb: 2, + borderBottom: 2, + borderBottomColor: "divider", + backgroundColor: "#f1f1f1", + }} + > + + + + + {title} + {filteredText.province} {filteredText.year} - mutate()} - size="small"> - + mutate()} size="small"> + - setExpanded((prevExpanded) => !prevExpanded)} - size="small"> - + setExpanded((prevExpanded) => !prevExpanded)} size="small"> + - - - {filter_by_province ? - : "" - } - {filter_by_year ? - : "" - } + + + {filter_by_province ? ( + + ) : ( + "" + )} + {filter_by_year ? ( + + ) : ( + "" + )} - + - ) + ); }; -export default Filter; \ No newline at end of file +export default Filter; diff --git a/src/components/dashboard/old-reports/LoanDetails/RadialBarChart.jsx b/src/components/dashboard/old-reports/LoanDetails/RadialBarChart.jsx index 69e0bc0..26cb57c 100644 --- a/src/components/dashboard/old-reports/LoanDetails/RadialBarChart.jsx +++ b/src/components/dashboard/old-reports/LoanDetails/RadialBarChart.jsx @@ -1,7 +1,7 @@ import Chart from "@/core/components/Chart"; -import {calculateGradientColor} from "@/core/utils/gradientColorHandler"; +import { calculateGradientColor } from "@/core/utils/gradientColorHandler"; -const RadialBarChart = ({data}) => { +const RadialBarChart = ({ data }) => { const specialOption = { title: { text: undefined, @@ -12,36 +12,34 @@ const RadialBarChart = ({data}) => { endAngle: 90, track: { background: "#e7e7e7", - strokeWidth: '90%', + strokeWidth: "90%", margin: 5, // margin is in pixels dropShadow: { enabled: true, top: 2, left: 0, - color: '#999', + color: "#999", opacity: 1, - blur: 2 - } + blur: 2, + }, }, dataLabels: { name: { - show: false + show: false, }, value: { offsetY: -2, - fontSize: '22px' - } - } - } + fontSize: "22px", + }, + }, + }, }, fill: { - colors: calculateGradientColor(data) + colors: calculateGradientColor(data), }, }; - const series = [data] - return ( - - ) + const series = [data]; + return ; }; -export default RadialBarChart; \ No newline at end of file +export default RadialBarChart; diff --git a/src/components/dashboard/old-reports/LoanDetails/RadialBarSemiCircularChart.jsx b/src/components/dashboard/old-reports/LoanDetails/RadialBarSemiCircularChart.jsx index 4a8fd11..c214235 100644 --- a/src/components/dashboard/old-reports/LoanDetails/RadialBarSemiCircularChart.jsx +++ b/src/components/dashboard/old-reports/LoanDetails/RadialBarSemiCircularChart.jsx @@ -1,7 +1,7 @@ import Chart from "@/core/components/Chart"; -import {calculateGradientColor} from "@/core/utils/gradientColorHandler"; +import { calculateGradientColor } from "@/core/utils/gradientColorHandler"; -const RadialBarSemiCircularChart = ({data, label}) => { +const RadialBarSemiCircularChart = ({ data, label }) => { const specialOption = { title: { text: undefined, @@ -12,35 +12,33 @@ const RadialBarSemiCircularChart = ({data, label}) => { endAngle: 110, track: { background: "#e7e7e7", - strokeWidth: '80%', + strokeWidth: "80%", }, dataLabels: { name: { - fontSize: '20px', + fontSize: "20px", offsetY: 110, - color: "#8c8c8c" + color: "#8c8c8c", }, value: { offsetY: 50, - fontSize: '50px', + fontSize: "50px", fontWeight: 500, color: "#8c8c8c", formatter: function (val) { return val + "%"; - } - } - } - } + }, + }, + }, + }, }, fill: { - colors: calculateGradientColor(data) + colors: calculateGradientColor(data), }, labels: [label], }; - const series = [data] - return ( - - ) + const series = [data]; + return ; }; -export default RadialBarSemiCircularChart; \ No newline at end of file +export default RadialBarSemiCircularChart; diff --git a/src/components/dashboard/old-reports/LoanDetails/RadialBarStrokedChart.jsx b/src/components/dashboard/old-reports/LoanDetails/RadialBarStrokedChart.jsx index 6482994..e3ec2f3 100644 --- a/src/components/dashboard/old-reports/LoanDetails/RadialBarStrokedChart.jsx +++ b/src/components/dashboard/old-reports/LoanDetails/RadialBarStrokedChart.jsx @@ -1,8 +1,8 @@ import Chart from "@/core/components/Chart"; -import {calculateGradientColor} from "@/core/utils/gradientColorHandler"; -import {useTranslations} from "next-intl"; +import { calculateGradientColor } from "@/core/utils/gradientColorHandler"; +import { useTranslations } from "next-intl"; -const RadialBarStrokedChart = ({data, label}) => { +const RadialBarStrokedChart = ({ data, label }) => { const t = useTranslations(); const specialOption = { title: { @@ -14,38 +14,36 @@ const RadialBarStrokedChart = ({data, label}) => { endAngle: 110, track: { background: "#e7e7e7", - strokeWidth: '80%', + strokeWidth: "80%", }, dataLabels: { name: { - fontSize: '20px', + fontSize: "20px", offsetY: 110, - color: "#8c8c8c" + color: "#8c8c8c", }, value: { offsetY: 50, - fontSize: '50px', + fontSize: "50px", fontWeight: 500, color: "#8c8c8c", formatter: function (val) { return val + "%"; - } - } - } - } + }, + }, + }, + }, }, stroke: { - dashArray: 4 + dashArray: 4, }, fill: { - colors: calculateGradientColor(data) + colors: calculateGradientColor(data), }, labels: [label], }; - const series = [data] - return ( - - ) + const series = [data]; + return ; }; -export default RadialBarStrokedChart; \ No newline at end of file +export default RadialBarStrokedChart; diff --git a/src/components/dashboard/old-reports/LoanDetails/index.jsx b/src/components/dashboard/old-reports/LoanDetails/index.jsx index 0ba3c9b..ee647bc 100644 --- a/src/components/dashboard/old-reports/LoanDetails/index.jsx +++ b/src/components/dashboard/old-reports/LoanDetails/index.jsx @@ -1,13 +1,12 @@ -import {Grid, Paper} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Grid, Paper } from "@mui/material"; +import { useTranslations } from "next-intl"; import RadialBarSemiCircularChart from "@/components/dashboard/old-reports/LoanDetails/RadialBarSemiCircularChart"; import RadialBarStrokedChart from "@/components/dashboard/old-reports/LoanDetails/RadialBarStrokedChart"; - const LoanDetails = () => { const t = useTranslations(); return ( - + {/* { {/* setFilterOption={setFilterOption}*/} {/* isLoadingReportList={isLoadingReportList}*/} {/*/>*/} - - - + + + - - + + - - + + - - + + - ) + ); }; -export default LoanDetails; \ No newline at end of file +export default LoanDetails; diff --git a/src/components/dashboard/old-reports/LoanDistribution/PieChart.jsx b/src/components/dashboard/old-reports/LoanDistribution/PieChart.jsx index 1ce3242..23368a3 100644 --- a/src/components/dashboard/old-reports/LoanDistribution/PieChart.jsx +++ b/src/components/dashboard/old-reports/LoanDistribution/PieChart.jsx @@ -1,11 +1,10 @@ import Chart from "@/core/components/Chart"; -import {useTheme} from "@mui/material/styles"; -import {useMediaQuery} from "@mui/material"; +import { useTheme } from "@mui/material/styles"; +import { useMediaQuery } from "@mui/material"; - -const Pie = ({data}) => { +const Pie = ({ data }) => { const theme = useTheme(); - const upperMd = useMediaQuery((theme.breakpoints.up("md"))) + const upperMd = useMediaQuery(theme.breakpoints.up("md")); const specialOption = { title: { text: undefined, @@ -17,18 +16,16 @@ const Pie = ({data}) => { dataLabels: { enabled: true, style: { - fontSize: '14px', + fontSize: "14px", fontWeight: 300, }, }, legend: { - show: upperMd - } + show: upperMd, + }, }; - const series = data.map((item) => +item.percentage) - return ( - - ) + const series = data.map((item) => +item.percentage); + return ; }; -export default Pie; \ No newline at end of file +export default Pie; diff --git a/src/components/dashboard/old-reports/LoanDistribution/PolarChart.jsx b/src/components/dashboard/old-reports/LoanDistribution/PolarChart.jsx index d6b73ff..d804a8c 100644 --- a/src/components/dashboard/old-reports/LoanDistribution/PolarChart.jsx +++ b/src/components/dashboard/old-reports/LoanDistribution/PolarChart.jsx @@ -1,10 +1,10 @@ import Chart from "@/core/components/Chart"; -import {useTheme} from "@mui/material/styles"; -import {useMediaQuery} from "@mui/material"; +import { useTheme } from "@mui/material/styles"; +import { useMediaQuery } from "@mui/material"; -const PolarChart = ({data}) => { +const PolarChart = ({ data }) => { const theme = useTheme(); - const upperMd = useMediaQuery((theme.breakpoints.up("md"))) + const upperMd = useMediaQuery(theme.breakpoints.up("md")); const specialOption = { title: { text: undefined, @@ -13,7 +13,7 @@ const PolarChart = ({data}) => { polarArea: { rings: { strokeWidth: 2, - strokeColor: '#e3e3e3', + strokeColor: "#e3e3e3", }, }, }, @@ -24,18 +24,16 @@ const PolarChart = ({data}) => { dataLabels: { enabled: true, style: { - fontSize: '14px', + fontSize: "14px", fontWeight: 400, }, }, legend: { - show: upperMd - } + show: upperMd, + }, }; - const series = data.map((item) => +item.percentage) - return ( - - ) + const series = data.map((item) => +item.percentage); + return ; }; -export default PolarChart; \ No newline at end of file +export default PolarChart; diff --git a/src/components/dashboard/old-reports/LoanDistribution/index.jsx b/src/components/dashboard/old-reports/LoanDistribution/index.jsx index 1e62597..3ff04f6 100644 --- a/src/components/dashboard/old-reports/LoanDistribution/index.jsx +++ b/src/components/dashboard/old-reports/LoanDistribution/index.jsx @@ -1,60 +1,70 @@ -import {Grid, Paper, Typography} from "@mui/material"; +import { Grid, Paper, Typography } from "@mui/material"; import PolarChart from "./PolarChart"; import Pie from "./PieChart"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import Filter from "@/components/dashboard/old-reports/Filter"; import useChart from "@/lib/app/hooks/useChart"; -import {GET_LOAN_DISTRIBUTION} from "@/core/data/apiRoutes"; +import { GET_LOAN_DISTRIBUTION } from "@/core/data/apiRoutes"; import LoadingHardPage from "@/core/components/LoadingHardPage"; import AnalyticsIcon from "@mui/icons-material/Analytics"; const LoanDistribution = () => { const t = useTranslations(); - const {errorReportList, isLoadingReportList, reportList, setFilterOption, mutate} = useChart(GET_LOAN_DISTRIBUTION); + const { errorReportList, isLoadingReportList, reportList, setFilterOption, mutate } = + useChart(GET_LOAN_DISTRIBUTION); return ( - - + - + {isLoadingReportList ? ( - + } + icon={} loading={isLoadingReportList} label={t("reports.loading_fetching_reports")} width={100} height={100} - sx={{position: "absolute", bgcolor: "#f7f7f7e6"}} + sx={{ position: "absolute", bgcolor: "#f7f7f7e6" }} /> ) : errorReportList ? ( - - {t("reports.error_fetching_reports")} + + + {t("reports.error_fetching_reports")} + ) : ( <> - - + + - - + + )} - ) + ); }; -export default LoanDistribution; \ No newline at end of file +export default LoanDistribution; diff --git a/src/components/dashboard/old-reports/LoanProgress/BarChart.jsx b/src/components/dashboard/old-reports/LoanProgress/BarChart.jsx index 745257c..c0896c3 100644 --- a/src/components/dashboard/old-reports/LoanProgress/BarChart.jsx +++ b/src/components/dashboard/old-reports/LoanProgress/BarChart.jsx @@ -1,8 +1,8 @@ -import {calculateGradientColor} from "@/core/utils/gradientColorHandler"; +import { calculateGradientColor } from "@/core/utils/gradientColorHandler"; import Chart from "@/core/components/Chart"; -const BarChart = ({data}) => { - const usableArray = data.map(({province_name, percentage, ...rest}) => ({ +const BarChart = ({ data }) => { + const usableArray = data.map(({ province_name, percentage, ...rest }) => ({ x: province_name, y: +percentage, ...rest, @@ -29,8 +29,8 @@ const BarChart = ({data}) => { trim: false, style: { fontWeight: 600, - fontSize: '11px', - colors: '#7e7e7e', + fontSize: "11px", + colors: "#7e7e7e", }, }, }, @@ -39,26 +39,26 @@ const BarChart = ({data}) => { max: 100, labels: { formatter: function (val) { - return val + '%'; + return val + "%"; }, }, }, dataLabels: { enabled: true, style: { - fontSize: '14px', + fontSize: "14px", fontWeight: 400, }, }, }; const series = [ { - name: 'درصد پیشرفت', + name: "درصد پیشرفت", data: usableArray, }, ]; - return ; + return ; }; -export default BarChart; \ No newline at end of file +export default BarChart; diff --git a/src/components/dashboard/old-reports/LoanProgress/index.jsx b/src/components/dashboard/old-reports/LoanProgress/index.jsx index dadac1e..65c240b 100644 --- a/src/components/dashboard/old-reports/LoanProgress/index.jsx +++ b/src/components/dashboard/old-reports/LoanProgress/index.jsx @@ -1,67 +1,81 @@ -import {Grid, Paper, Typography} from "@mui/material"; +import { Grid, Paper, Typography } from "@mui/material"; import BarChart from "./BarChart"; import Filter from "../Filter"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import useChart from "@/lib/app/hooks/useChart"; -import {GET_PROVINCE_PROGRESS} from "@/core/data/apiRoutes"; +import { GET_PROVINCE_PROGRESS } from "@/core/data/apiRoutes"; import LoadingHardPage from "@/core/components/LoadingHardPage"; -import AnalyticsIcon from '@mui/icons-material/Analytics'; +import AnalyticsIcon from "@mui/icons-material/Analytics"; const LoanProgress = () => { const t = useTranslations(); - const {errorReportList, isLoadingReportList, reportList, setFilterOption, mutate} = useChart(GET_PROVINCE_PROGRESS); + const { errorReportList, isLoadingReportList, reportList, setFilterOption, mutate } = + useChart(GET_PROVINCE_PROGRESS); return ( - - + {isLoadingReportList ? ( - + } + icon={} loading={isLoadingReportList} label={t("reports.loading_fetching_reports")} width={100} height={100} - sx={{position: "absolute", bgcolor: "#f7f7f7e6"}} + sx={{ position: "absolute", bgcolor: "#f7f7f7e6" }} /> ) : errorReportList ? ( - - {t("reports.error_fetching_reports")} + + + {t("reports.error_fetching_reports")} + ) : ( - - + + )} - ) + ); }; -export default LoanProgress; \ No newline at end of file +export default LoanProgress; diff --git a/src/components/dashboard/old-reports/index.jsx b/src/components/dashboard/old-reports/index.jsx index aa590b5..6c5db05 100644 --- a/src/components/dashboard/old-reports/index.jsx +++ b/src/components/dashboard/old-reports/index.jsx @@ -5,12 +5,12 @@ import ExcelExport from "@/components/dashboard/old-reports/ExcelExport"; const DashboardReportsComponent = (props) => { return ( <> - - - + + + {/**/} - ) + ); }; -export default DashboardReportsComponent; \ No newline at end of file +export default DashboardReportsComponent; diff --git a/src/components/dashboard/passenger-boss/Buttons/printExcel.jsx b/src/components/dashboard/passenger-boss/Buttons/printExcel.jsx index 1f34df8..35ade38 100644 --- a/src/components/dashboard/passenger-boss/Buttons/printExcel.jsx +++ b/src/components/dashboard/passenger-boss/Buttons/printExcel.jsx @@ -1,18 +1,18 @@ -import {Button, CircularProgress} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useMemo, useState} from "react"; +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_PASSENGER_BOSS} from "@/core/data/apiRoutes"; +import { EXPORT_PASSENGER_BOSS } from "@/core/data/apiRoutes"; import moment from "jalali-moment"; -import FileSaver from 'file-saver'; -import DescriptionIcon from '@mui/icons-material/Description'; +import FileSaver from "file-saver"; +import DescriptionIcon from "@mui/icons-material/Description"; -const PrintExcel = ({table}) => { +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 [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(); @@ -24,30 +24,32 @@ const PrintExcel = ({table}) => { } } return { - ...filter, fn: columnFilterFns[filter.id], datatype: datatype, + ...filter, + fn: columnFilterFns[filter.id], + datatype: datatype, }; }); - params.set("start", '0'); + params.set("start", "0"); params.set("filters", JSON.stringify(filters ?? [])); params.set("sorting", JSON.stringify(sorting ?? [])); return params; - }, [columnFilters, columnFilterFns, sorting, columns,]); - + }, [columnFilters, columnFilterFns, sorting, columns]); const clickHandler = () => { - setLoading(true) - requestServer(`${EXPORT_PASSENGER_BOSS}?${filterParams}`, 'get', { + setLoading(true); + requestServer(`${EXPORT_PASSENGER_BOSS}?${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) + 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 \ No newline at end of file +export default PrintExcel; diff --git a/src/components/dashboard/passenger-boss/Buttons/printFinalCreditAmount.jsx b/src/components/dashboard/passenger-boss/Buttons/printFinalCreditAmount.jsx index 58a97af..10cc05a 100644 --- a/src/components/dashboard/passenger-boss/Buttons/printFinalCreditAmount.jsx +++ b/src/components/dashboard/passenger-boss/Buttons/printFinalCreditAmount.jsx @@ -1,34 +1,36 @@ import PrintIcon from "@mui/icons-material/Print"; -import {Button, CircularProgress} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useRouter} from "next/router"; -import {useState} from "react"; +import { Button, CircularProgress } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useRouter } from "next/router"; +import { useState } from "react"; import useRequest from "@/lib/app/hooks/useRequest"; -import {GET_PASSENGER_BOSS} from "@/core/data/apiRoutes"; +import { GET_PASSENGER_BOSS } from "@/core/data/apiRoutes"; import usePrint from "@/lib/app/hooks/usePrint"; const PrintFinalCreditAmount = () => { const t = useTranslations(); - const router = useRouter() - const [loading, setLoading] = useState(false) - const requestServer = useRequest({auth: true, pending: false, success: {notification: {show: false}}}) - const {setPrintPage, setPrintTitle} = usePrint() + const router = useRouter(); + const [loading, setLoading] = useState(false); + const requestServer = useRequest({ auth: true, pending: false, success: { notification: { show: false } } }); + const { setPrintPage, setPrintTitle } = usePrint(); const clickHandler = () => { - setLoading(true) + setLoading(true); const params = new URLSearchParams(); - params.set("start", '0'); - params.set("filters", '[]'); - params.set("sorting", '[]'); - requestServer(`${GET_PASSENGER_BOSS}?${params}`, 'get').then((response) => { - const _data = response.data.data - setPrintPage(_data.length) - setPrintTitle(t('PassengerBoss.print_final_credit_amount')) - sessionStorage.setItem('final-credit-amount-print', JSON.stringify(_data)) - router.push('/dashboard/passenger-boss/prints/final-credit-amount') - }).catch(() => { - setLoading(false) - }) - } + params.set("start", "0"); + params.set("filters", "[]"); + params.set("sorting", "[]"); + requestServer(`${GET_PASSENGER_BOSS}?${params}`, "get") + .then((response) => { + const _data = response.data.data; + setPrintPage(_data.length); + setPrintTitle(t("PassengerBoss.print_final_credit_amount")); + sessionStorage.setItem("final-credit-amount-print", JSON.stringify(_data)); + router.push("/dashboard/passenger-boss/prints/final-credit-amount"); + }) + .catch(() => { + setLoading(false); + }); + }; return ( - ) -} + ); +}; -export default PrintFinalCreditAmount \ No newline at end of file +export default PrintFinalCreditAmount; diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx index 79ccc03..81eb134 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx @@ -11,8 +11,8 @@ import { useState } from "react"; import * as Yup from "yup"; const vehicle_amount = { - اتوبوس: 7000, - "مینی بوس": 2000, + "اتوبوس": parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT), + "مینی بوس": parseInt(process.env.NEXT_PUBLIC_MINIBUS_AMOUNT), }; const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog, vehicle_type, row }) => { @@ -27,13 +27,29 @@ const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog, vehicle_type, row const validationSchema = Yup.object().shape({ approved_amount: Yup.mixed() .test("is-number", `${t("ConfirmDialog.approved_amount_number")}`, (value) => !isNaN(value)) - .test( - "max-amount", - `${t("PassengerBoss.max_amount", { - value: parseInt(vehicle_amount[vehicle_type]).toLocaleString("en"), - })}`, - (value) => value <= vehicle_amount[vehicle_type] - ) + .test("max-amount", function (value) { + const maxAmount = + vehicle_type === "اتوبوس" + ? value > parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT) + ? parseInt(vehicle_amount[vehicle_type]) / 1000 + : parseInt(vehicle_amount[vehicle_type]) + : parseInt(vehicle_amount[vehicle_type]); + // Check the condition to set the message dynamically + const message = + vehicle_type === "اتوبوس" + ? value > parseInt(process.env.NEXT_PUBLIC_BUS_AMOUNT) && + `${t("PassengerBoss.max_amount", { + value: maxAmount.toLocaleString("en"), + amount: "میلیارد", + })}` + : value > parseInt(process.env.NEXT_PUBLIC_MINIBUS_AMOUNT) && + `${t("PassengerBoss.max_amount", { + value: maxAmount.toLocaleString("en"), + amount: "میلیارد", + })}`; + // Return either `true` (pass the validation) or `this.createError` with the message + return value <= maxAmount || this.createError({ message }); + }) .test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.approved_amount_error")), repayment_period: Yup.mixed() @@ -119,7 +135,7 @@ const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog, vehicle_type, row mutate(); update_notification(); }) - .catch(() => { }) + .catch(() => {}) .finally(() => { setSubmitting(false); }); diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx index 104922c..8611500 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx @@ -1,17 +1,17 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useEffect, useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useEffect, useState } from "react"; import ConfirmContent from "./ConfirmContent"; -import CallMadeIcon from '@mui/icons-material/CallMade'; +import CallMadeIcon from "@mui/icons-material/CallMade"; -const Confirm = ({rowId, mutate, vehicle_type, row}) => { +const Confirm = ({ rowId, mutate, vehicle_type, row }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const [dialogSize, setDialogSize] = useState('sm'); + const [dialogSize, setDialogSize] = useState("sm"); useEffect(() => { if (!openConfirmDialog) { - setDialogSize('sm'); + setDialogSize("sm"); } }, [openConfirmDialog]); @@ -25,20 +25,34 @@ const Confirm = ({rowId, mutate, vehicle_type, row}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("PassengerBoss.confirm")} - + - ) - -} -export default Confirm; \ No newline at end of file + ); +}; +export default Confirm; diff --git a/src/components/dashboard/passenger-boss/Form/ReferReason/HistoryContent.jsx b/src/components/dashboard/passenger-boss/Form/ReferReason/HistoryContent.jsx index 4628461..bd8c5ef 100644 --- a/src/components/dashboard/passenger-boss/Form/ReferReason/HistoryContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/ReferReason/HistoryContent.jsx @@ -1,12 +1,12 @@ -import {Button, DialogActions, DialogContent,} from "@mui/material" -import {useTranslations} from "next-intl"; +import { Button, DialogActions, DialogContent } from "@mui/material"; +import { useTranslations } from "next-intl"; import TableContent from "./TableContent"; -const HistoryContent = ({setOpenReferReasonDialog, row}) => { +const HistoryContent = ({ setOpenReferReasonDialog, row }) => { const t = useTranslations(); return ( <> - + - ) -} -export default HistoryContent \ No newline at end of file + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/passenger-boss/Form/ReferReason/TableContent.jsx b/src/components/dashboard/passenger-boss/Form/ReferReason/TableContent.jsx index 9dbcf5d..3da4401 100644 --- a/src/components/dashboard/passenger-boss/Form/ReferReason/TableContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/ReferReason/TableContent.jsx @@ -1,20 +1,13 @@ -import { - Box, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, -} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material"; +import { useTranslations } from "next-intl"; import moment from "jalali-moment"; -const TableContent = ({row}) => { +const TableContent = ({ row }) => { const t = useTranslations(); - return ( - - + return ( + + +
{t("LoanHistory.Table_head_date")} @@ -23,8 +16,12 @@ const TableContent = ({row}) => { - - {moment(row.original.latest_history.created_at).locale("fa").format("HH:mm | yyyy/MM/DD")} + + + {moment(row.original.latest_history.created_at) + .locale("fa") + .format("HH:mm | yyyy/MM/DD")} + {row.original.latest_history.previous_state_name} {row.original.latest_history.expert_description} @@ -32,7 +29,6 @@ const TableContent = ({row}) => {
- - ) -} -export default TableContent \ No newline at end of file + ); +}; +export default TableContent; diff --git a/src/components/dashboard/passenger-boss/Form/ReferReason/index.jsx b/src/components/dashboard/passenger-boss/Form/ReferReason/index.jsx index 40f48e1..5b46003 100644 --- a/src/components/dashboard/passenger-boss/Form/ReferReason/index.jsx +++ b/src/components/dashboard/passenger-boss/Form/ReferReason/index.jsx @@ -1,30 +1,33 @@ -import { - Dialog, - DialogTitle, - IconButton, - Tooltip, -} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import RestorePageIcon from '@mui/icons-material/RestorePage'; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RestorePageIcon from "@mui/icons-material/RestorePage"; import HistoryContent from "./HistoryContent"; -const ReferReason = ({row}) => { +const ReferReason = ({ row }) => { const t = useTranslations(); const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); return ( <> setOpenReferReasonDialog(true)}> - + - + {t("ReferReasonDialog.refer_reason")} - + - ) -} -export default ReferReason \ No newline at end of file + ); +}; +export default ReferReason; diff --git a/src/components/dashboard/passenger-boss/Form/ReferUser/ReferUserContent.jsx b/src/components/dashboard/passenger-boss/Form/ReferUser/ReferUserContent.jsx index f55c4b2..438c19a 100644 --- a/src/components/dashboard/passenger-boss/Form/ReferUser/ReferUserContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/ReferUser/ReferUserContent.jsx @@ -1,15 +1,15 @@ 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 { 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"; +import { REFER_LOAN_FOLLOWUP_USER } from "@/core/data/apiRoutes"; -const ReferUserContent = ({rowId, mutate, setOpenReferDialog}) => { +const ReferUserContent = ({ rowId, mutate, setOpenReferDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("ReferDialog.description_error")), @@ -20,19 +20,21 @@ const ReferUserContent = ({rowId, mutate, setOpenReferDialog}) => { description: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("expert_description", values.description); - requestServer(`${REFER_LOAN_FOLLOWUP_USER}/${rowId}`, 'post', { + requestServer(`${REFER_LOAN_FOLLOWUP_USER}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenReferDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenReferDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -53,28 +55,35 @@ const ReferUserContent = ({rowId, mutate, setOpenReferDialog}) => { value={formik.values.description} onChange={formik.handleChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} />
- - - ) -} -export default ReferUserContent \ No newline at end of file + ); +}; +export default ReferUserContent; diff --git a/src/components/dashboard/passenger-boss/Form/ReferUser/index.jsx b/src/components/dashboard/passenger-boss/Form/ReferUser/index.jsx index 243140d..b61f2f4 100644 --- a/src/components/dashboard/passenger-boss/Form/ReferUser/index.jsx +++ b/src/components/dashboard/passenger-boss/Form/ReferUser/index.jsx @@ -1,24 +1,31 @@ -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 { 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 ReferUser = ({ rowId, mutate }) => { const t = useTranslations(); const [openReferDialog, setOpenReferDialog] = useState(false); return ( <> setOpenReferDialog(true)}> - + - + {t("ReferDialog.refer-user")} - ) -} -export default ReferUser \ No newline at end of file + ); +}; +export default ReferUser; diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx index 6851197..7cca345 100644 --- a/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx @@ -1,34 +1,44 @@ -import UploadSystem from "@/core/components/UploadSystem" +import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, FormHelperText, Grid, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { + Button, + DialogActions, + DialogContent, + FormHelperText, + Grid, + Stack, + TextField, + Typography, +} from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import * as Yup from "yup"; -import {REJECT_PASSENGER_BOSS} from "@/core/data/apiRoutes"; +import { REJECT_PASSENGER_BOSS } from "@/core/data/apiRoutes"; -const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { +const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { const [selectedImage, setSelectedImage] = useState(""); const [fileType, setFileType] = useState(null); const [fileName, setFileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), - confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error")) - .test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => { - if (!value) return true + confirm_img: Yup.mixed() + .notRequired(t("ConfirmDialog.approved_amount_error")) + .test("fileSize", `${t("PassengerBoss.upload_file_unit")}`, (value) => { + if (!value) return true; return value.size <= 5 * 1024 * 1024; }) - .test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => { - if (!value) return true - const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; + .test("fileType", `${t("PassengerBoss.upload_file_format")}`, (value) => { + if (!value) return true; + const allowedTypes = ["image/jpg", "image/jpeg", "image/png", "application/pdf"]; return allowedTypes.includes(value.type); - }) + }), }); const formik = useFormik({ @@ -37,15 +47,15 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { confirm_img: null, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("expert_description", values.description); if (values.confirm_img != null) { const attachments = [ { title: "فایل ضمیمه کارتابل کارگروه", - file: values.confirm_img - } + file: values.confirm_img, + }, ]; attachments.forEach((attachment, index) => { formData.append(`attachment[${index}][title]`, attachment.title); @@ -53,16 +63,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { }); } - requestServer(`${REJECT_PASSENGER_BOSS}/${rowId}`, 'post', { + requestServer(`${REJECT_PASSENGER_BOSS}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenRejectDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenRejectDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -80,7 +92,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { setFileName(fileName); formik.setFieldValue("confirm_img", uploadedFile).then(() => { formik.setFieldTouched("confirm_img", true); - }) + }); setShowAddIcon(false); } }; @@ -97,13 +109,11 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} />
@@ -119,32 +129,36 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { imageAlt={t("app_name")} imageSize={[250, 150]} onBlur={formik.handleBlur("confirm_img")} - error={ - formik.touched.confirm_img && - Boolean(formik.errors.confirm_img) - } + error={formik.touched.confirm_img && Boolean(formik.errors.confirm_img)} setShowAddIcon={setShowAddIcon} showAddIcon={showAddIcon} /> - + {formik.touched.confirm_img && formik.errors.confirm_img}
- - - ) -} -export default RejectContent \ No newline at end of file + ); +}; +export default RejectContent; diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx index 06608f5..a04d0e1 100644 --- a/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx +++ b/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import RejectContent from "./RejectContent"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -const Reject = ({rowId, mutate}) => { +const Reject = ({ rowId, mutate }) => { const t = useTranslations(); const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> setOpenRejectDialog(true)}> - + - + {t("RejectDialog.reject")} - + - ) -} -export default Reject \ No newline at end of file + ); +}; +export default Reject; diff --git a/src/components/dashboard/passenger-boss/Form/ReserveForm/index.jsx b/src/components/dashboard/passenger-boss/Form/ReserveForm/index.jsx index a1316b8..6e1f02a 100644 --- a/src/components/dashboard/passenger-boss/Form/ReserveForm/index.jsx +++ b/src/components/dashboard/passenger-boss/Form/ReserveForm/index.jsx @@ -5,33 +5,36 @@ import { DialogContent, DialogTitle, IconButton, - Tooltip, Typography + Tooltip, + Typography, } from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import RepartitionIcon from '@mui/icons-material/Repartition'; +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_PASSENGER_BOSS} from "@/core/data/apiRoutes"; +import { RESERVE_PASSENGER_BOSS } from "@/core/data/apiRoutes"; -const ReserveForm = ({rowId, mutate}) => { +const ReserveForm = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true, notification: true}); + const requestServer = useRequest({ auth: true, notification: true }); const [isSubmitting, setIsSubmitting] = useState(false); - const {update_notification} = useNotification() + const { update_notification } = useNotification(); const handleSubmit = () => { - setIsSubmitting(true) - requestServer(`${RESERVE_PASSENGER_BOSS}/${rowId}`, 'post').then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setIsSubmitting(false) - }); - } + setIsSubmitting(true); + requestServer(`${RESERVE_PASSENGER_BOSS}/${rowId}`, "post") + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setIsSubmitting(false); + }); + }; return ( <> @@ -39,37 +42,45 @@ const ReserveForm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - - {t("PassengerBoss.reserve-loan-title")} - + {t("PassengerBoss.reserve-loan-title")} - {t("PassengerBoss.description-reserve-loan-first")} {rowId} {t("PassengerBoss.description-reserve-loan-second")} + + {" "} + {t("PassengerBoss.description-reserve-loan-first")} {rowId}{" "} + {t("PassengerBoss.description-reserve-loan-second")} + - + - ) - -} -export default ReserveForm; \ No newline at end of file + ); +}; +export default ReserveForm; diff --git a/src/components/dashboard/passenger-boss/Form/UserInfoForm/LegalTableContent.jsx b/src/components/dashboard/passenger-boss/Form/UserInfoForm/LegalTableContent.jsx new file mode 100644 index 0000000..c087459 --- /dev/null +++ b/src/components/dashboard/passenger-boss/Form/UserInfoForm/LegalTableContent.jsx @@ -0,0 +1,397 @@ +import { Chip, DialogContent, DialogTitle, Divider, Grid, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import moment from "jalali-moment"; + +const LegalTableContent = ({ rowId, row }) => { + const t = useTranslations(); + return ( + <> + {t("UserInfoDialog.user_info")} + + + + + + + {t("UserInfoDialog.legal_person")} + + + + + + + {row.original.id || t("UserInfoDialog.no_info")} + + + + + + + + + + {row.original.project_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.activity_category_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.first_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.last_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.father_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.gender ? t("UserInfoDialog.female") : t("UserInfoDialog.male")} + + + + + + + + + + + {row.original.national_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.national_serial_number || + row.original.national_tracking_code || + t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.education_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.occupation_title || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.phone_number || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.birthday + ? moment(row.original.birthday).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.province_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.city_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.shenase_meli || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.postal_code || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.company_register_date + ? moment(row.original.company_register_date).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.register_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.navgan_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.navgan_type || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.company_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.telephone_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.vehicle_type || t("UserInfoDialog.no_info")} + + + + + + + + + { + (row.original.investment_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", { value: (row.original.investment_amount / 1000000000) }) + : t("UserInfoDialog.toman", { value: (row.original.investment_amount / 1000000) }) + } + + + + + + + + + + + { + (row.original.requested_facility_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.requested_facility_amount / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.requested_facility_amount / 1000000)}) + } + + + + + + + + + { + (row.original.person_share / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.person_share / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.person_share / 1000000)}) + } + + + + + + + + + + + {row.original.user_committed_employment || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.user_existing_employment || t("UserInfoDialog.no_info")} + + + + + + + + + + + + {row.original.plate_number.split("-")[3] || t("UserInfoDialog.no_info")} + + + + {row.original.plate_number.split("-")[2] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[1] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[0] || t("UserInfoDialog.no_info")} + + + + + + + + + + + + + {row.original.address || t("UserInfoDialog.no_info")} + + + + + + + ); +}; +export default LegalTableContent; diff --git a/src/components/dashboard/passenger-boss/Form/UserInfoForm/RealTableContent.jsx b/src/components/dashboard/passenger-boss/Form/UserInfoForm/RealTableContent.jsx new file mode 100644 index 0000000..727d5aa --- /dev/null +++ b/src/components/dashboard/passenger-boss/Form/UserInfoForm/RealTableContent.jsx @@ -0,0 +1,353 @@ +import { Chip, DialogContent, DialogTitle, Divider, Grid, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import moment from "jalali-moment"; + +const RealTableContent = ({ rowId, row }) => { + const t = useTranslations(); + return ( + <> + {t("UserInfoDialog.user_info")} + + + + + + + {t("UserInfoDialog.real_person")} + + + + + + + {row.original.id || t("UserInfoDialog.no_info")} + + + + + + + + + + {row.original.project_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.activity_category_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.first_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.last_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.national_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.national_serial_number || + row.original.national_tracking_code || + t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.education_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.occupation_title || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.phone_number || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.telephone_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.birthday + ? moment(row.original.birthday).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.postal_code || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.father_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.gender ? t("UserInfoDialog.female") : t("UserInfoDialog.male")} + + + + + + + + + + + {row.original.province_name || t("UserInfoDialog.no_info")} + + + + + + + + {row.original.city_name} + + + + + + + + + + {row.original.navgan_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.navgan_type || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.user_committed_employment || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.user_existing_employment || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.vehicle_type || t("UserInfoDialog.no_info")} + + + + + + + + + { + (row.original.investment_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", { value: (row.original.investment_amount / 1000000000) }) + : t("UserInfoDialog.toman", { value: (row.original.investment_amount / 1000000) }) + } + + + + + + + + + + + { + (row.original.requested_facility_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.requested_facility_amount / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.requested_facility_amount / 1000000)}) + } + + + + + + + + + { + (row.original.person_share / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.person_share / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.person_share / 1000000)}) + } + + + + + + + + + + + + {row.original.plate_number.split("-")[3] || t("UserInfoDialog.no_info")} + + + + {row.original.plate_number.split("-")[2] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[1] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[0] || t("UserInfoDialog.no_info")} + + + + + + + + + + + + + {row.original.address || t("UserInfoDialog.no_info")} + + + + + + + ); +}; +export default RealTableContent; diff --git a/src/components/dashboard/passenger-boss/Form/UserInfoForm/index.jsx b/src/components/dashboard/passenger-boss/Form/UserInfoForm/index.jsx new file mode 100644 index 0000000..aa67e15 --- /dev/null +++ b/src/components/dashboard/passenger-boss/Form/UserInfoForm/index.jsx @@ -0,0 +1,47 @@ +import { Button, Dialog, DialogActions, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import ContactPageIcon from "@mui/icons-material/ContactPage"; +import LegalTableContent from "./LegalTableContent"; +import RealTableContent from "./RealTableContent"; +const UserInfoForm = ({ rowId, row }) => { + const t = useTranslations(); + const [openUserInfoDialog, setOpenUserInfoDialog] = useState(false); + return ( + <> + + { + setOpenUserInfoDialog(true); + }} + > + + + + + {row.original.is_legal_person === 1 ? ( + + ) : ( + + )} + + + + + + ); +}; +export default UserInfoForm; diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx index cac1ec1..f57d6e4 100644 --- a/src/components/dashboard/passenger-boss/TableRowActions.jsx +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -1,32 +1,22 @@ -import {Box} from "@mui/material"; -import Reject from "./Form/RejectForm" +import { Box } from "@mui/material"; +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"; +import UserInfoForm from "./Form/UserInfoForm"; -const TableRow = ({row, mutate}) => { +const TableRow = ({ row, mutate }) => { return ( - - {row.original.latest_history?.action === "refer" ? : null} - - - - + + {row.original.latest_history?.action === "refer" || row.original.latest_history?.action === "user-edit" ? ( + + ) : null} + + + + + ); }; diff --git a/src/components/dashboard/passenger-boss/TableToolbar.jsx b/src/components/dashboard/passenger-boss/TableToolbar.jsx index d050624..3433640 100644 --- a/src/components/dashboard/passenger-boss/TableToolbar.jsx +++ b/src/components/dashboard/passenger-boss/TableToolbar.jsx @@ -1,12 +1,12 @@ -import {Stack} from "@mui/material"; +import { Stack } from "@mui/material"; import PrintExcel from "@/components/dashboard/passenger-boss/Buttons/printExcel"; -const TableToolbar = ({table}) => { +const TableToolbar = ({ table }) => { return ( - + - ) -} + ); +}; -export default TableToolbar \ No newline at end of file +export default TableToolbar; diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx index d1fc966..2835f6c 100644 --- a/src/components/dashboard/passenger-boss/index.jsx +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -1,7 +1,7 @@ -import {Box, Stack, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_PASSENGER_BOSS} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Stack, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_PASSENGER_BOSS } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import moment from "jalali-moment"; import DataTable from "@/core/components/DataTable"; @@ -20,17 +20,8 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.is_legal_person, @@ -40,9 +31,10 @@ function DashboardPassengerOfficeComponent() { datatype: "numeric", filterFn: "equals", columnFilterModeOptions: ["equals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue === 1 ? `${t("PassengerBoss.hoghoghi")}` : `${t("PassengerBoss.haghighi")}`} + Cell: ({ renderedCellValue }) => ( + + {renderedCellValue === 1 ? `${t("PassengerBoss.hoghoghi")}` : `${t("PassengerBoss.haghighi")}`} + ), }, { @@ -52,17 +44,8 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -72,9 +55,7 @@ function DashboardPassengerOfficeComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -83,17 +64,8 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.shenase_meli, @@ -102,17 +74,8 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.province_name, @@ -122,9 +85,7 @@ function DashboardPassengerOfficeComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.city_name, @@ -134,27 +95,22 @@ function DashboardPassengerOfficeComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("PassengerBoss.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { @@ -164,17 +120,8 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.statement_count, @@ -183,12 +130,8 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.navgan_capacity, @@ -197,17 +140,8 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.manufacture_date, @@ -216,17 +150,8 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.vehicle_type, @@ -236,9 +161,7 @@ function DashboardPassengerOfficeComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.plate_number, @@ -248,24 +171,36 @@ function DashboardPassengerOfficeComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - - - {renderedCellValue.split('-')[3]} + Cell: ({ renderedCellValue }) => ( + + + {renderedCellValue.split("-")[3]} - - {renderedCellValue.split('-')[2]} - {renderedCellValue.split('-')[1]} - {renderedCellValue.split('-')[0]} + + + {renderedCellValue.split("-")[2]} + + + {renderedCellValue.split("-")[1]} + + + {renderedCellValue.split("-")[0]} + ), @@ -276,15 +211,13 @@ function DashboardPassengerOfficeComponent() { header: t("PassengerBoss.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const formik = useFormik({ initialValues: { description: "", - confirm_img: null + confirm_img: null, }, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); if (values.description != "") formData.append("description", values.description); if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - requestServer(`${CONFIRM_PROVINCE_HEAD_EXPERT}/${rowId}`, 'post', { + requestServer(`${CONFIRM_PROVINCE_HEAD_EXPERT}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) + formik.setFieldValue("description", event.target.value); }; const handleUploadChange = (event) => { @@ -73,17 +75,24 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { name="description" multiline rows={8} - label={<> - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} + label={ + <> + {t("ConfirmDialog.description")} + {t("ConfirmDialog.optional")} + + } value={formik.values.description} onChange={handleDescriptionChange} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) - -} -export default ConfirmContent \ No newline at end of file + ); +}; +export default ConfirmContent; diff --git a/src/components/dashboard/province-head-expert/Form/ConfirmForm/index.jsx b/src/components/dashboard/province-head-expert/Form/ConfirmForm/index.jsx index 95a6367..e849196 100644 --- a/src/components/dashboard/province-head-expert/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/province-head-expert/Form/ConfirmForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import {useState} from "react"; +import { useState } from "react"; import ConfirmContent from "./ConfirmContent"; -const Confirm = ({rowId, mutate}) => { +const Confirm = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,19 +13,25 @@ const Confirm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("ConfirmDialog.confirm")} - + - ) - -} -export default Confirm; \ No newline at end of file + ); +}; +export default Confirm; diff --git a/src/components/dashboard/province-head-expert/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/province-head-expert/Form/RejectForm/RejectContent.jsx index b24ba91..a04de07 100644 --- a/src/components/dashboard/province-head-expert/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/province-head-expert/Form/RejectForm/RejectContent.jsx @@ -1,21 +1,21 @@ -import UploadSystem from "@/core/components/UploadSystem" +import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import * as Yup from "yup"; -import {REJECT_PROVINCE_HEAD_EXPERT} from "@/core/data/apiRoutes"; +import { REJECT_PROVINCE_HEAD_EXPERT } from "@/core/data/apiRoutes"; -const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { +const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), @@ -24,24 +24,26 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const formik = useFormik({ initialValues: { description: "", - reject_img: null + reject_img: null, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("description", values.description); if (values.reject_img != null) formData.append("attachment", values.reject_img); - requestServer(`${REJECT_PROVINCE_HEAD_EXPERT}/${rowId}`, 'post', { + requestServer(`${REJECT_PROVINCE_HEAD_EXPERT}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenRejectDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenRejectDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -80,17 +82,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) -} -export default RejectContent \ No newline at end of file + ); +}; +export default RejectContent; diff --git a/src/components/dashboard/province-head-expert/Form/RejectForm/index.jsx b/src/components/dashboard/province-head-expert/Form/RejectForm/index.jsx index 06608f5..a04d0e1 100644 --- a/src/components/dashboard/province-head-expert/Form/RejectForm/index.jsx +++ b/src/components/dashboard/province-head-expert/Form/RejectForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import RejectContent from "./RejectContent"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -const Reject = ({rowId, mutate}) => { +const Reject = ({ rowId, mutate }) => { const t = useTranslations(); const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> setOpenRejectDialog(true)}> - + - + {t("RejectDialog.reject")} - + - ) -} -export default Reject \ No newline at end of file + ); +}; +export default Reject; diff --git a/src/components/dashboard/province-head-expert/Form/ReviseForm/ReviseContent.jsx b/src/components/dashboard/province-head-expert/Form/ReviseForm/ReviseContent.jsx index 056524e..b64ebf4 100644 --- a/src/components/dashboard/province-head-expert/Form/ReviseForm/ReviseContent.jsx +++ b/src/components/dashboard/province-head-expert/Form/ReviseForm/ReviseContent.jsx @@ -1,15 +1,15 @@ 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 { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -import {REVISE_PROVINCE_HEAD_EXPERT} from "@/core/data/apiRoutes"; +import { REVISE_PROVINCE_HEAD_EXPERT } from "@/core/data/apiRoutes"; -const ReviseContent = ({rowId, mutate, setOpenReviseDialog}) => { +const ReviseContent = ({ rowId, mutate, setOpenReviseDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("ReviseDialog.description_error")), @@ -20,20 +20,22 @@ const ReviseContent = ({rowId, mutate, setOpenReviseDialog}) => { description: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("description", values.description); - requestServer(`${REVISE_PROVINCE_HEAD_EXPERT}/${rowId}`, 'post', { + requestServer(`${REVISE_PROVINCE_HEAD_EXPERT}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenReviseDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenReviseDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -54,28 +56,35 @@ const ReviseContent = ({rowId, mutate, setOpenReviseDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} />
- - - ) -} -export default ReviseContent \ No newline at end of file + ); +}; +export default ReviseContent; diff --git a/src/components/dashboard/province-head-expert/Form/ReviseForm/index.jsx b/src/components/dashboard/province-head-expert/Form/ReviseForm/index.jsx index 6b6691b..4fad1cd 100644 --- a/src/components/dashboard/province-head-expert/Form/ReviseForm/index.jsx +++ b/src/components/dashboard/province-head-expert/Form/ReviseForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; -import ReplyIcon from '@mui/icons-material/Reply'; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ReplyIcon from "@mui/icons-material/Reply"; +import { useState } from "react"; import ReviseContent from "./ReviseContent"; -const Revise = ({rowId, mutate}) => { +const Revise = ({ rowId, mutate }) => { const t = useTranslations(); const [openReviseDialog, setOpenReviseDialog] = useState(false); return ( @@ -13,19 +13,25 @@ const Revise = ({rowId, mutate}) => { { - setOpenReviseDialog(true) + setOpenReviseDialog(true); }} > - + - + {t("ReviseDialog.revise")} - + - ) - -} -export default Revise; \ No newline at end of file + ); +}; +export default Revise; diff --git a/src/components/dashboard/province-head-expert/TableRowActions.jsx b/src/components/dashboard/province-head-expert/TableRowActions.jsx index e631ffc..524963d 100644 --- a/src/components/dashboard/province-head-expert/TableRowActions.jsx +++ b/src/components/dashboard/province-head-expert/TableRowActions.jsx @@ -1,24 +1,14 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import Confirm from "./Form/ConfirmForm"; import Reject from "./Form/RejectForm"; import Revise from "./Form/ReviseForm"; -const TableRowActions = ({row, mutate}) => { - +const TableRowActions = ({ row, mutate }) => { return ( - - - - + + + + ); }; diff --git a/src/components/dashboard/province-head-expert/index.jsx b/src/components/dashboard/province-head-expert/index.jsx index 56bf5f8..bba30b4 100644 --- a/src/components/dashboard/province-head-expert/index.jsx +++ b/src/components/dashboard/province-head-expert/index.jsx @@ -1,10 +1,10 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_PROVINCE_HEAD_EXPERT} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_PROVINCE_HEAD_EXPERT } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import moment from "jalali-moment"; import DataTable from "@/core/components/DataTable"; -import TableRowActions from "./TableRowActions" +import TableRowActions from "./TableRowActions"; import MuiDatePicker from "@/core/components/MuiDatePicker"; function DashboardProvinceHeadExpertComponent() { @@ -19,17 +19,8 @@ function DashboardProvinceHeadExpertComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -39,9 +30,7 @@ function DashboardProvinceHeadExpertComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -50,17 +39,8 @@ function DashboardProvinceHeadExpertComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.phone_number, @@ -69,47 +49,32 @@ function DashboardProvinceHeadExpertComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("ProvinceHeadExpert.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "updated_at", header: t("ProvinceHeadExpert.updated_at"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -117,27 +82,28 @@ function DashboardProvinceHeadExpertComponent() { header: t("ProvinceHeadExpert.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +const UpdateContent = ({ rowId, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); - const {loan_state_refahi} = useLoanStateRefahi() - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const { loan_state_refahi } = useLoanStateRefahi(); + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("UpdateDialog.description_error")), - next_state_id: Yup.number().required(t("UpdateDialog.next-state-id-error")) + next_state_id: Yup.number().required(t("UpdateDialog.next-state-id-error")), }); const formik = useFormik({ initialValues: { description: "", - next_state_id: "" + next_state_id: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("expert_description", values.description); formData.append("next_state_id", values.next_state_id); - requestServer(`${UPDATE_LOAN_MANAGEMENT_REFAHI}/${rowId}`, 'post', { + requestServer(`${UPDATE_LOAN_MANAGEMENT_REFAHI}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) + formik.setFieldValue("description", event.target.value); }; const handleNextStateIDChange = (event) => { - formik.setFieldValue("next_state_id", event.target.value) + formik.setFieldValue("next_state_id", event.target.value); }; return ( <> @@ -73,20 +75,17 @@ const UpdateContent = ({rowId, mutate, setOpenConfirmDialog}) => { onChange={handleDescriptionChange} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} /> + error={formik.touched.next_state_id && Boolean(formik.errors.next_state_id)} + fullWidth + > {t("UpdateDialog.next-state-id")} {formik.touched.next_state_id && formik.errors.next_state_id} @@ -110,16 +113,25 @@ const UpdateContent = ({rowId, mutate, setOpenConfirmDialog}) => { - - - ) -} -export default UpdateContent \ No newline at end of file + ); +}; +export default UpdateContent; diff --git a/src/components/dashboard/refahi-loan-management/Form/UpdateForm/index.jsx b/src/components/dashboard/refahi-loan-management/Form/UpdateForm/index.jsx index 321a709..e4cebb1 100644 --- a/src/components/dashboard/refahi-loan-management/Form/UpdateForm/index.jsx +++ b/src/components/dashboard/refahi-loan-management/Form/UpdateForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; -import ChangeCircleIcon from '@mui/icons-material/ChangeCircle'; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ChangeCircleIcon from "@mui/icons-material/ChangeCircle"; +import { useState } from "react"; import UpdateContent from "./UpdateContent"; -const Update = ({rowId, mutate}) => { +const Update = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,18 +13,25 @@ const Update = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("UpdateDialog.update")} - + - ) -} -export default Update \ No newline at end of file + ); +}; +export default Update; diff --git a/src/components/dashboard/refahi-loan-management/TableRowActions.jsx b/src/components/dashboard/refahi-loan-management/TableRowActions.jsx index 478cbb3..efb3fc6 100644 --- a/src/components/dashboard/refahi-loan-management/TableRowActions.jsx +++ b/src/components/dashboard/refahi-loan-management/TableRowActions.jsx @@ -1,14 +1,10 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import Update from "./Form/UpdateForm"; -const TableRowActions = ({row, mutate}) => { - +const TableRowActions = ({ row, mutate }) => { return ( - - + + ); }; diff --git a/src/components/dashboard/refahi-loan-management/index.jsx b/src/components/dashboard/refahi-loan-management/index.jsx index 11cd469..6a50654 100644 --- a/src/components/dashboard/refahi-loan-management/index.jsx +++ b/src/components/dashboard/refahi-loan-management/index.jsx @@ -1,7 +1,7 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_LOAN_MANAGEMENT_REFAHI} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_LOAN_MANAGEMENT_REFAHI } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import DataTable from "@/core/components/DataTable"; import moment from "jalali-moment"; @@ -19,17 +19,8 @@ function DashboardRefahiLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -39,9 +30,7 @@ function DashboardRefahiLoanManagementComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -50,17 +39,8 @@ function DashboardRefahiLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.phone_number, @@ -69,56 +49,39 @@ function DashboardRefahiLoanManagementComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.province_name, id: "province_name", header: t("RefahiLoanManagement.province_name"), enableColumnFilter: false, - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("RefahiLoanManagement.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "updated_at", header: t("RefahiLoanManagement.updated_at"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -126,28 +89,29 @@ function DashboardRefahiLoanManagementComponent() { header: t("RefahiLoanManagement.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const formik = useFormik({ initialValues: { description: "", - confirm_img: null + confirm_img: null, }, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); if (values.description != "") formData.append("description", values.description); if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - requestServer(`${CONFIRM_REFAHI_PROVINCE_MANAGER}/${rowId}`, 'post', { + requestServer(`${CONFIRM_REFAHI_PROVINCE_MANAGER}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) + formik.setFieldValue("description", event.target.value); }; const handleUploadChange = (event) => { @@ -73,17 +75,24 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { name="description" multiline rows={8} - label={<> - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} + label={ + <> + {t("ConfirmDialog.description")} + {t("ConfirmDialog.optional")} + + } value={formik.values.description} onChange={handleDescriptionChange} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) - -} -export default ConfirmContent \ No newline at end of file + ); +}; +export default ConfirmContent; diff --git a/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/index.jsx b/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/index.jsx index 95a6367..e849196 100644 --- a/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import {useState} from "react"; +import { useState } from "react"; import ConfirmContent from "./ConfirmContent"; -const Confirm = ({rowId, mutate}) => { +const Confirm = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,19 +13,25 @@ const Confirm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("ConfirmDialog.confirm")} - + - ) - -} -export default Confirm; \ No newline at end of file + ); +}; +export default Confirm; diff --git a/src/components/dashboard/refahi-province-manager/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/refahi-province-manager/Form/RejectForm/RejectContent.jsx index bbc116f..16ac531 100644 --- a/src/components/dashboard/refahi-province-manager/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/refahi-province-manager/Form/RejectForm/RejectContent.jsx @@ -1,21 +1,21 @@ -import UploadSystem from "@/core/components/UploadSystem" +import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import * as Yup from "yup"; -import {REJECT_REFAHI_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; +import { REJECT_REFAHI_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; -const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { +const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), @@ -24,24 +24,26 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const formik = useFormik({ initialValues: { description: "", - reject_img: null + reject_img: null, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("description", values.description); if (values.reject_img != null) formData.append("attachment", values.reject_img); - requestServer(`${REJECT_REFAHI_PROVINCE_MANAGER}/${rowId}`, 'post', { + requestServer(`${REJECT_REFAHI_PROVINCE_MANAGER}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenRejectDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenRejectDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -80,17 +82,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { - - - ) -} -export default RejectContent \ No newline at end of file + ); +}; +export default RejectContent; diff --git a/src/components/dashboard/refahi-province-manager/Form/RejectForm/index.jsx b/src/components/dashboard/refahi-province-manager/Form/RejectForm/index.jsx index 06608f5..a04d0e1 100644 --- a/src/components/dashboard/refahi-province-manager/Form/RejectForm/index.jsx +++ b/src/components/dashboard/refahi-province-manager/Form/RejectForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import RejectContent from "./RejectContent"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -const Reject = ({rowId, mutate}) => { +const Reject = ({ rowId, mutate }) => { const t = useTranslations(); const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> setOpenRejectDialog(true)}> - + - + {t("RejectDialog.reject")} - + - ) -} -export default Reject \ No newline at end of file + ); +}; +export default Reject; diff --git a/src/components/dashboard/refahi-province-manager/TableRowActions.jsx b/src/components/dashboard/refahi-province-manager/TableRowActions.jsx index 69f9d6f..fa9e1ef 100644 --- a/src/components/dashboard/refahi-province-manager/TableRowActions.jsx +++ b/src/components/dashboard/refahi-province-manager/TableRowActions.jsx @@ -1,19 +1,12 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import Confirm from "./Form/ConfirmForm"; import Reject from "./Form/RejectForm"; -const TableRow = ({row, mutate}) => { - +const TableRow = ({ row, mutate }) => { return ( - - - + + + ); }; diff --git a/src/components/dashboard/refahi-province-manager/index.jsx b/src/components/dashboard/refahi-province-manager/index.jsx index 88be38d..f49b26a 100644 --- a/src/components/dashboard/refahi-province-manager/index.jsx +++ b/src/components/dashboard/refahi-province-manager/index.jsx @@ -1,7 +1,7 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_REFAHI_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_REFAHI_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import moment from "jalali-moment"; import DataTable from "@/core/components/DataTable"; @@ -19,17 +19,8 @@ function DashboardRefahiProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -39,9 +30,7 @@ function DashboardRefahiProvinceManagerComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -50,17 +39,8 @@ function DashboardRefahiProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.phone_number, @@ -69,47 +49,32 @@ function DashboardRefahiProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("RefahiProvinceManager.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | YYYY/MM/DD"), + accessorFn: (row) => moment(row.updated_at).locale("fa").format("HH:mm | YYYY/MM/DD"), id: "updated_at", header: t("RefahiProvinceManager.updated_at"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -117,28 +82,29 @@ function DashboardRefahiProvinceManagerComponent() { header: t("RefahiProvinceManager.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +const ExcelExport = ({ filenameStr, url, title }) => { const t = useTranslations(); const requestServer = useRequest(); const [loading, setLoading] = useState(false); const clickHandler = () => { - setLoading(true) - requestServer(url, 'get', { + setLoading(true); + requestServer(url, "get", { auth: true, - requestOptions: {responseType: 'blob'} - }).then((response) => { - const filename = `${filenameStr}_${moment().format('jDD_jMM_jYYYY')}.xlsx`; - FileSaver.saveAs(response.data, filename); - }).catch(() => { - }).finally(() => { - setLoading(false) + requestOptions: { responseType: "blob" }, }) - } + .then((response) => { + const filename = `${filenameStr}_${moment().format("jDD_jMM_jYYYY")}.xlsx`; + FileSaver.saveAs(response.data, filename); + }) + .catch(() => {}) + .finally(() => { + setLoading(false); + }); + }; return ( - - - - - - - - {title} - + + + + + + + {title} - @@ -56,7 +60,7 @@ const ExcelExport = ({filenameStr, url, title}) => { - ) + ); }; -export default ExcelExport; \ No newline at end of file +export default ExcelExport; diff --git a/src/components/dashboard/reports/Filter/ProvinceFilter.jsx b/src/components/dashboard/reports/Filter/ProvinceFilter.jsx index f96cc84..a9e2733 100644 --- a/src/components/dashboard/reports/Filter/ProvinceFilter.jsx +++ b/src/components/dashboard/reports/Filter/ProvinceFilter.jsx @@ -7,46 +7,46 @@ import { MenuItem, OutlinedInput, Select, - Typography + Typography, } from "@mui/material"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import useProvince from "@/lib/app/hooks/useProvince"; -import ClearIcon from '@mui/icons-material/Clear'; +import ClearIcon from "@mui/icons-material/Clear"; const provinceList = [ - {name: "قزوین", id: 1}, - {name: "تبریز", id: 2}, - {name: "مشهد", id: 3} -] + { name: "قزوین", id: 1 }, + { name: "تبریز", id: 2 }, + { name: "مشهد", id: 3 }, +]; -const ProvinceFilter = ({formik, multiple, setFilteredText}) => { - const {errorProvinceList, isLoadingProvinceList, provinceList} = useProvince(); +const ProvinceFilter = ({ formik, multiple, setFilteredText }) => { + const { errorProvinceList, isLoadingProvinceList, provinceList } = useProvince(); const t = useTranslations(); const provinceChange = (event) => { - const {target: {value}} = event; - formik.setFieldValue('province_id', value); + const { + target: { value }, + } = event; + formik.setFieldValue("province_id", value); if (Array.isArray(value)) { const province_names = []; value.map((item) => { - province_names.push(provinceList.find(province => province.id === item).name) - }) - setFilteredText(prevState => ({ + province_names.push(provinceList.find((province) => province.id === item).name); + }); + setFilteredText((prevState) => ({ ...prevState, - province: province_names.length !== 0 ? `${t("filters.provinces")}: ${province_names.join(' , ')}` : "" + province: province_names.length !== 0 ? `${t("filters.provinces")}: ${province_names.join(" , ")}` : "", })); } else { - const selectedProvince = provinceList.find(province => province.id === value); - setFilteredText(prevState => ({ + const selectedProvince = provinceList.find((province) => province.id === value); + setFilteredText((prevState) => ({ ...prevState, - province: `${t("filters.province")}: ${selectedProvince.name}` + province: `${t("filters.province")}: ${selectedProvince.name}`, })); } }; - const needAdorment = multiple - ? formik.values.province_id.length === 0 : - formik.values.province_id === ""; + const needAdorment = multiple ? formik.values.province_id.length === 0 : formik.values.province_id === ""; return ( - + {t("filters.choose_province")} - ) + ); }; -export default ProvinceFilter; \ No newline at end of file +export default ProvinceFilter; diff --git a/src/components/dashboard/reports/Filter/YearFilter.jsx b/src/components/dashboard/reports/Filter/YearFilter.jsx index a18e9db..72cda4c 100644 --- a/src/components/dashboard/reports/Filter/YearFilter.jsx +++ b/src/components/dashboard/reports/Filter/YearFilter.jsx @@ -1,34 +1,38 @@ -import {Box, Chip, FormControl, InputLabel, MenuItem, OutlinedInput, Select} from "@mui/material"; +import { Box, Chip, FormControl, InputLabel, MenuItem, OutlinedInput, Select } from "@mui/material"; import moment from "jalali-moment"; -import {useTranslations} from "next-intl"; -import {periodOfYear} from "@/core/utils/yearPeriodFinder"; +import { useTranslations } from "next-intl"; +import { periodOfYear } from "@/core/utils/yearPeriodFinder"; -const currentShamsiYear = moment().format('jYYYY'); -const shamsiYearList = Array.from({length: currentShamsiYear - 1399}, (_, index) => (currentShamsiYear - index).toString()); +const currentShamsiYear = moment().format("jYYYY"); +const shamsiYearList = Array.from({ length: currentShamsiYear - 1399 }, (_, index) => + (currentShamsiYear - index).toString() +); -const YearFilter = ({formik, multiple, setFilteredText}) => { +const YearFilter = ({ formik, multiple, setFilteredText }) => { const t = useTranslations(); const yearChange = (event) => { - const {target: {value}} = event; + const { + target: { value }, + } = event; formik.handleChange(event); - formik.setFieldValue('date', value); - const {from, to} = periodOfYear(value); - formik.setFieldValue('from_date', from); - formik.setFieldValue('to_date', to); + formik.setFieldValue("date", value); + const { from, to } = periodOfYear(value); + formik.setFieldValue("from_date", from); + formik.setFieldValue("to_date", to); if (Array.isArray(value)) { - setFilteredText(prevState => ({ + setFilteredText((prevState) => ({ ...prevState, - year: `| ${t("filters.years")}: ${value.join(' , ')}` + year: `| ${t("filters.years")}: ${value.join(" , ")}`, })); } else { - setFilteredText(prevState => ({ + setFilteredText((prevState) => ({ ...prevState, - year: `| ${t("filters.year")}: ${value}` + year: `| ${t("filters.year")}: ${value}`, })); } }; return ( - + {t("filters.choose_year")} - ) + ); }; -export default YearFilter; \ No newline at end of file +export default YearFilter; diff --git a/src/components/dashboard/reports/Filter/index.jsx b/src/components/dashboard/reports/Filter/index.jsx index 2486533..b2f74f0 100644 --- a/src/components/dashboard/reports/Filter/index.jsx +++ b/src/components/dashboard/reports/Filter/index.jsx @@ -8,143 +8,160 @@ import { IconButton, Stack, Tooltip, - Typography + Typography, } from "@mui/material"; -import {useFormik} from "formik"; +import { useFormik } from "formik"; import ProvinceFilter from "../Filter/ProvinceFilter"; import YearFilter from "../Filter/YearFilter"; -import FilterAltIcon from '@mui/icons-material/FilterAlt'; -import EqualizerIcon from '@mui/icons-material/Equalizer'; -import {useTranslations} from "next-intl"; -import TroubleshootIcon from '@mui/icons-material/Troubleshoot'; -import CachedIcon from '@mui/icons-material/Cached'; -import {useEffect, useState} from "react"; +import FilterAltIcon from "@mui/icons-material/FilterAlt"; +import EqualizerIcon from "@mui/icons-material/Equalizer"; +import { useTranslations } from "next-intl"; +import TroubleshootIcon from "@mui/icons-material/Troubleshoot"; +import CachedIcon from "@mui/icons-material/Cached"; +import { useEffect, useState } from "react"; import moment from "jalali-moment"; -const Filter = ({title, filterItem, setFilterOption, isLoadingReportList, mutate}) => { +const Filter = ({ title, filterItem, setFilterOption, isLoadingReportList, mutate }) => { const t = useTranslations(); const filter_by_province = filterItem.find((item) => item.type === "province"); const filter_by_year = filterItem.find((item) => item.type === "year"); const [expanded, setExpanded] = useState(true); const [filteredText, setFilteredText] = useState({ - ...(filter_by_province ? {province: t("filters.all_provinces")} : {}), - ...(filter_by_year ? {year: ""} : {}) + ...(filter_by_province ? { province: t("filters.all_provinces") } : {}), + ...(filter_by_year ? { year: "" } : {}), }); - const [textFilter, setTextFilter] = useState() + const [textFilter, setTextFilter] = useState(); const [stepValue, setStepValue] = useState({ ...(filter_by_year && { - date: filter_by_year.multiple ? [] : `${moment().format('jYYYY')}` + date: filter_by_year.multiple ? [] : `${moment().format("jYYYY")}`, }), ...(filter_by_province && { - province_id: filter_by_province.multiple ? [] : "" + province_id: filter_by_province.multiple ? [] : "", }), from_date: "", - to_date: "" - }) + to_date: "", + }); const formik = useFormik({ enableReinitialize: true, - initialValues: stepValue, onSubmit: (values, {setSubmitting}) => { - setStepValue(values) + initialValues: stepValue, + onSubmit: (values, { setSubmitting }) => { + setStepValue(values); const province = values.province_id; const fields = [ - values.from_date ? {key: "from_date", value: values.from_date} : null, - values.to_date ? {key: "to_date", value: values.to_date} : null, + values.from_date ? { key: "from_date", value: values.from_date } : null, + values.to_date ? { key: "to_date", value: values.to_date } : null, ...(Array.isArray(province) - ? province.length !== 0 - ? province.map((item, index) => ({key: `province_id[${index}]`, value: item})) - : [] - : province - ? [{key: "province_id", value: province}] - : [] - ), + ? province.length !== 0 + ? province.map((item, index) => ({ key: `province_id[${index}]`, value: item })) + : [] + : province + ? [{ key: "province_id", value: province }] + : []), ].filter(Boolean); setFilterOption(fields); textMaker(); }, }); - const textMaker = (() => { - setTextFilter(`| ${Object.values(filteredText).join(", ")}`) - }); + const textMaker = () => { + setTextFilter(`| ${Object.values(filteredText).join(", ")}`); + }; useEffect(() => { const province = formik.values.province_id; const fields = [ - formik.values.from_date ? {key: "from_date", value: formik.values.from_date} : null, - formik.values.to_date ? {key: "to_date", value: formik.values.to_date} : null, + formik.values.from_date ? { key: "from_date", value: formik.values.from_date } : null, + formik.values.to_date ? { key: "to_date", value: formik.values.to_date } : null, ...(Array.isArray(province) - ? province.length !== 0 - ? province.map((item, index) => ({key: `province_id[${index}]`, value: item})) - : [] - : province - ? [{key: "province_id", value: province}] - : [] - ), + ? province.length !== 0 + ? province.map((item, index) => ({ key: `province_id[${index}]`, value: item })) + : [] + : province + ? [{ key: "province_id", value: province }] + : []), ].filter(Boolean); - setTextFilter(`| ${Object.values(filteredText).join(", ")}`) + setTextFilter(`| ${Object.values(filteredText).join(", ")}`); }, []); return ( - { - }} sx={{ - mb: 2, - borderBottom: 2, - borderBottomColor: "divider", - backgroundColor: "#f1f1f1", - }}> - - - - - {title} - + {}} + sx={{ + mb: 2, + borderBottom: 2, + borderBottomColor: "divider", + backgroundColor: "#f1f1f1", + }} + > + + + + + {title} + {textFilter} - mutate()} - size="small"> - + mutate()} size="small"> + - setExpanded((prevExpanded) => !prevExpanded)} - size="small"> - + setExpanded((prevExpanded) => !prevExpanded)} size="small"> + - - - {filter_by_province ? - : "" - } - {filter_by_year ? - : "" - } + + + {filter_by_province ? ( + + ) : ( + "" + )} + {filter_by_year ? ( + + ) : ( + "" + )} - + - ) + ); }; -export default Filter; \ No newline at end of file +export default Filter; diff --git a/src/components/dashboard/reports/LoanDetails/FunctionalityCharts.jsx b/src/components/dashboard/reports/LoanDetails/FunctionalityCharts.jsx index b161a42..80c7ed6 100644 --- a/src/components/dashboard/reports/LoanDetails/FunctionalityCharts.jsx +++ b/src/components/dashboard/reports/LoanDetails/FunctionalityCharts.jsx @@ -1,41 +1,47 @@ -import {Grid, Typography} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Grid, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; import RadialBarSemiCircularChart from "@/components/dashboard/reports/LoanDetails/RadialBarSemiCircularChart"; -const FunctionalityCharts = ({reportList}) => { +const FunctionalityCharts = ({ reportList }) => { const t = useTranslations(); const DataItemsName = [ - {id: "expert", name: t("reports.expert")}, - {id: "transportation_assistant", name: t("reports.transportation_assistant")}, - {id: "province_manager", name: t("reports.province_manager")}, - {id: "bank", name: t("reports.bank")} - ] + { id: "expert", name: t("reports.expert") }, + { id: "transportation_assistant", name: t("reports.transportation_assistant") }, + { id: "province_manager", name: t("reports.province_manager") }, + { id: "bank", name: t("reports.bank") }, + ]; return ( - - { - Object.entries(reportList).map(([entryKey, innerObject]) => { - let percentage = innerObject.total !== 0 && innerObject.pending !== 64 ? (innerObject.total - innerObject.pending) / innerObject.total * 100 : 0; - const ItemName = DataItemsName.find(item => item.id === entryKey).name; - return ( - - + {Object.entries(reportList).map(([entryKey, innerObject]) => { + let percentage = + innerObject.total !== 0 && innerObject.pending !== 64 + ? ((innerObject.total - innerObject.pending) / innerObject.total) * 100 + : 0; + const ItemName = DataItemsName.find((item) => item.id === entryKey).name; + return ( + + {ItemName} - `${val}%`} - label={t("reports.dynamic_label_functionality", { - total: (innerObject.total).toLocaleString("en"), - done: (innerObject.total - innerObject.pending).toLocaleString("en") - })}/> - - ) - }) - } + color: "primary.main", + }} + > + {ItemName} + + `${val}%`} + label={t("reports.dynamic_label_functionality", { + total: innerObject.total.toLocaleString("en"), + done: (innerObject.total - innerObject.pending).toLocaleString("en"), + })} + /> + + ); + })} - ) + ); }; export default FunctionalityCharts; diff --git a/src/components/dashboard/reports/LoanDetails/RadialBarSemiCircularChart.jsx b/src/components/dashboard/reports/LoanDetails/RadialBarSemiCircularChart.jsx index c37f3b9..6cf42b9 100644 --- a/src/components/dashboard/reports/LoanDetails/RadialBarSemiCircularChart.jsx +++ b/src/components/dashboard/reports/LoanDetails/RadialBarSemiCircularChart.jsx @@ -1,7 +1,7 @@ import Chart from "@/core/components/Chart"; -import {calculateGradientColor} from "@/core/utils/gradientColorHandler"; +import { calculateGradientColor } from "@/core/utils/gradientColorHandler"; -const RadialBarSemiCircularChart = ({data, label, formatter}) => { +const RadialBarSemiCircularChart = ({ data, label, formatter }) => { const specialOption = { title: { text: undefined, @@ -12,33 +12,31 @@ const RadialBarSemiCircularChart = ({data, label, formatter}) => { endAngle: 90, track: { background: "#e7e7e7", - strokeWidth: '80%', + strokeWidth: "80%", }, dataLabels: { name: { - fontSize: '1rem', + fontSize: "1rem", offsetY: 30, - color: "#8c8c8c" + color: "#8c8c8c", }, value: { offsetY: -30, - fontSize: '30px', + fontSize: "30px", fontWeight: 500, color: "#8c8c8c", - formatter: formatter - } - } - } + formatter: formatter, + }, + }, + }, }, fill: { - colors: calculateGradientColor(data) + colors: calculateGradientColor(data), }, labels: [label], }; - const series = [data] - return ( - - ) + const series = [data]; + return ; }; -export default RadialBarSemiCircularChart; \ No newline at end of file +export default RadialBarSemiCircularChart; diff --git a/src/components/dashboard/reports/LoanDetails/ReferredCharts.jsx b/src/components/dashboard/reports/LoanDetails/ReferredCharts.jsx index 6653d74..113f2be 100644 --- a/src/components/dashboard/reports/LoanDetails/ReferredCharts.jsx +++ b/src/components/dashboard/reports/LoanDetails/ReferredCharts.jsx @@ -1,39 +1,53 @@ -import {Box, Grid, Typography} from "@mui/material"; +import { Box, Grid, Typography } from "@mui/material"; import RadialBarSemiCircularChart from "@/components/dashboard/reports/LoanDetails/RadialBarSemiCircularChart"; -import {useTranslations} from "next-intl"; // Make sure to import React if it's not already imported +import { useTranslations } from "next-intl"; // Make sure to import React if it's not already imported -const ReferredCharts = ({reportList}) => { +const ReferredCharts = ({ reportList }) => { const t = useTranslations(); const DataItemsName = [ - {id: "referred_loans_to_bank", name: t("reports.referred_loans_to_bank")}, - {id: "paid_loans", name: t("reports.paid_loans")} + { id: "referred_loans_to_bank", name: t("reports.referred_loans_to_bank") }, + { id: "paid_loans", name: t("reports.paid_loans") }, ]; return ( - + {Object.entries(reportList).map(([entryKey, innerObject]) => { - const ItemName = DataItemsName.find(item => item.id === entryKey).name; + const ItemName = DataItemsName.find((item) => item.id === entryKey).name; return ( - - - {ItemName} + + + + {ItemName} + - + {innerObject.map((item, index) => { - let percentage = item.total_budget !== 0 ? item.total_amount / (item.total_budget) * 100 : 0; + let percentage = + item.total_budget !== 0 ? (item.total_amount / item.total_budget) * 100 : 0; return ( - + - {item.vehicle_type} + + {item.vehicle_type} + {t("reports.dynamic_total_budget", { total_budget: (item.total_budget / 1000000).toLocaleString("en"), @@ -44,9 +58,10 @@ const ReferredCharts = ({reportList}) => { data={Math.round(percentage > 100 ? 100 : percentage)} formatter={(val) => `${Math.round(percentage)}%`} label={t("reports.dynamic_label_referred", { - count: (item.count).toLocaleString("en"), - total_amount: (item.total_amount / 1000000).toLocaleString("en") - })}/> + count: item.count.toLocaleString("en"), + total_amount: (item.total_amount / 1000000).toLocaleString("en"), + })} + /> ); })} @@ -58,4 +73,4 @@ const ReferredCharts = ({reportList}) => { ); }; -export default ReferredCharts; \ No newline at end of file +export default ReferredCharts; diff --git a/src/components/dashboard/reports/LoanDetails/index.jsx b/src/components/dashboard/reports/LoanDetails/index.jsx index 1178246..5c16ccf 100644 --- a/src/components/dashboard/reports/LoanDetails/index.jsx +++ b/src/components/dashboard/reports/LoanDetails/index.jsx @@ -1,8 +1,8 @@ -import {Divider, Grid, Paper, Stack, Typography} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Divider, Grid, Paper, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; import Filter from "@/components/dashboard/reports/Filter"; import useChart from "@/lib/app/hooks/useChart"; -import {GET_LOAN_EXPERTPROGRESS, GET_LOAN_REFERREDLOANS} from "@/core/data/apiRoutes"; +import { GET_LOAN_EXPERTPROGRESS, GET_LOAN_REFERREDLOANS } from "@/core/data/apiRoutes"; import LoadingHardPage from "@/core/components/LoadingHardPage"; import AnalyticsIcon from "@mui/icons-material/Analytics"; import FunctionalityCharts from "@/components/dashboard/reports/LoanDetails/FunctionalityCharts"; @@ -16,7 +16,7 @@ const LoanDetails = () => { isLoadingReportList: isLoadingReportList1, reportList: reportList1, setFilterOption: setFilterOption1, - mutate: mutate1 + mutate: mutate1, } = useChart(GET_LOAN_EXPERTPROGRESS); // Use the useChart hook for the second API route @@ -25,54 +25,62 @@ const LoanDetails = () => { isLoadingReportList: isLoadingReportList2, reportList: reportList2, setFilterOption: setFilterOption2, - mutate: mutate2 + mutate: mutate2, } = useChart(GET_LOAN_REFERREDLOANS); return ( - - { - setFilterOption1(fields); - setFilterOption2(fields) - }} - isLoadingReportList={isLoadingReportList1 || isLoadingReportList2} - mutate={() => { - mutate1(); - mutate2() - }} + + { + setFilterOption1(fields); + setFilterOption2(fields); + }} + isLoadingReportList={isLoadingReportList1 || isLoadingReportList2} + mutate={() => { + mutate1(); + mutate2(); + }} /> - + {isLoadingReportList1 || isLoadingReportList2 ? ( - + } + icon={} loading={isLoadingReportList1 || isLoadingReportList2} label={t("reports.loading_fetching_reports")} width={100} height={100} - sx={{position: "absolute", bgcolor: "#f7f7f7e6"}} + sx={{ position: "absolute", bgcolor: "#f7f7f7e6" }} /> ) : errorReportList1 || errorReportList2 ? ( - - {t("reports.error_fetching_reports")} + + + {t("reports.error_fetching_reports")} + ) : ( - - - - + + + + - ) - } + )} - ) + ); }; export default LoanDetails; diff --git a/src/components/dashboard/reports/index.jsx b/src/components/dashboard/reports/index.jsx index faf9c99..944c39b 100644 --- a/src/components/dashboard/reports/index.jsx +++ b/src/components/dashboard/reports/index.jsx @@ -1,19 +1,26 @@ import LoanDetails from "@/components/dashboard/reports/LoanDetails"; import ExcelExport from "@/components/dashboard/reports/ExcelExport"; -import {GET_EXCEL_EXPORT, GET_EXCEL_EXPORT_status} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { GET_EXCEL_EXPORT, GET_EXCEL_EXPORT_status } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; const DashboardReportsComponent = (props) => { const t = useTranslations(); return ( <> - - - + + + - ) + ); }; -export default DashboardReportsComponent; \ No newline at end of file +export default DashboardReportsComponent; diff --git a/src/components/dashboard/reserve-loan/Form/CanselReserve/index.jsx b/src/components/dashboard/reserve-loan/Form/CanselReserve/index.jsx index 0af4f2a..ad415b0 100644 --- a/src/components/dashboard/reserve-loan/Form/CanselReserve/index.jsx +++ b/src/components/dashboard/reserve-loan/Form/CanselReserve/index.jsx @@ -5,33 +5,36 @@ import { DialogContent, DialogTitle, IconButton, - Tooltip, Typography + Tooltip, + Typography, } from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import KeyboardReturnSharpIcon from '@mui/icons-material/KeyboardReturnSharp'; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import KeyboardReturnSharpIcon from "@mui/icons-material/KeyboardReturnSharp"; import useRequest from "@/lib/app/hooks/useRequest"; -import {CANSEL_RESERVE_MACHINARY_LOAN} from "@/core/data/apiRoutes"; +import { CANSEL_RESERVE_MACHINARY_LOAN } from "@/core/data/apiRoutes"; import useNotification from "@/lib/app/hooks/useNotification"; -const CanselReserve = ({rowId, mutate}) => { +const CanselReserve = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true, notification: true}); + const requestServer = useRequest({ auth: true, notification: true }); const [isSubmitting, setIsSubmitting] = useState(false); - const {update_notification} = useNotification() + const { update_notification } = useNotification(); const handleSubmit = () => { - setIsSubmitting(true) - requestServer(`${CANSEL_RESERVE_MACHINARY_LOAN}/${rowId}`, 'post').then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setIsSubmitting(false) - }); - } + setIsSubmitting(true); + requestServer(`${CANSEL_RESERVE_MACHINARY_LOAN}/${rowId}`, "post") + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setIsSubmitting(false); + }); + }; return ( <> @@ -39,37 +42,43 @@ const CanselReserve = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - - {t("ReserveLoan.title")} - + {t("ReserveLoan.title")} - {t("ReserveLoan.description-loan-first")} {rowId} {t("ReserveLoan.description-loan-second")} + + {t("ReserveLoan.description-loan-first")} {rowId} {t("ReserveLoan.description-loan-second")} + - - + - ) - -} -export default CanselReserve; \ No newline at end of file + ); +}; +export default CanselReserve; diff --git a/src/components/dashboard/reserve-loan/TableRowActions.jsx b/src/components/dashboard/reserve-loan/TableRowActions.jsx index 207138d..69e97e5 100644 --- a/src/components/dashboard/reserve-loan/TableRowActions.jsx +++ b/src/components/dashboard/reserve-loan/TableRowActions.jsx @@ -1,13 +1,10 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import CanselReserve from "./Form/CanselReserve"; -const TableRow = ({row, mutate}) => { +const TableRow = ({ row, mutate }) => { return ( - - + + ); }; diff --git a/src/components/dashboard/reserve-loan/TableToolbar.jsx b/src/components/dashboard/reserve-loan/TableToolbar.jsx index bd5e9e8..7be1e50 100644 --- a/src/components/dashboard/reserve-loan/TableToolbar.jsx +++ b/src/components/dashboard/reserve-loan/TableToolbar.jsx @@ -1,12 +1,7 @@ -import {Stack} from "@mui/material"; +import { Stack } from "@mui/material"; +const TableToolbar = ({ table }) => { + return ; +}; -const TableToolbar = ({table}) => { - return ( - - - - ) -} - -export default TableToolbar \ No newline at end of file +export default TableToolbar; diff --git a/src/components/dashboard/reserve-loan/index.jsx b/src/components/dashboard/reserve-loan/index.jsx index 5fcf3b5..d36d185 100644 --- a/src/components/dashboard/reserve-loan/index.jsx +++ b/src/components/dashboard/reserve-loan/index.jsx @@ -1,7 +1,7 @@ -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 { 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"; @@ -19,17 +19,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.is_legal_person, @@ -39,9 +30,10 @@ function DashboardReserveLoan() { datatype: "numeric", filterFn: "equals", columnFilterModeOptions: ["equals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue === 1 ? `${t("ReserveLoan.hoghoghi")}` : `${t("ReserveLoan.haghighi")}`} + Cell: ({ renderedCellValue }) => ( + + {renderedCellValue === 1 ? `${t("ReserveLoan.hoghoghi")}` : `${t("ReserveLoan.haghighi")}`} + ), }, { @@ -51,17 +43,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -71,9 +54,7 @@ function DashboardReserveLoan() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.national_id, @@ -82,17 +63,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.shenase_meli, @@ -101,17 +73,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.province_name, @@ -121,9 +84,7 @@ function DashboardReserveLoan() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.city_name, @@ -133,27 +94,22 @@ function DashboardReserveLoan() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("ReserveLoan.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { + Cell: ({ renderedCellValue }) => { return {renderedCellValue}; }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { @@ -163,17 +119,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.statement_count, @@ -182,12 +129,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.navgan_capacity, @@ -196,17 +139,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.manufacture_date, @@ -215,17 +149,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.vehicle_type, @@ -235,9 +160,7 @@ function DashboardReserveLoan() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.plate_number, @@ -247,24 +170,36 @@ function DashboardReserveLoan() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - - - {renderedCellValue.split('-')[3]} + Cell: ({ renderedCellValue }) => ( + + + {renderedCellValue.split("-")[3]} - - {renderedCellValue.split('-')[2]} - {renderedCellValue.split('-')[1]} - {renderedCellValue.split('-')[0]} + + + {renderedCellValue.split("-")[2]} + + + {renderedCellValue.split("-")[1]} + + + {renderedCellValue.split("-")[0]} + ), @@ -276,17 +211,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_bank, @@ -295,17 +221,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_gov, @@ -314,17 +231,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_person, @@ -333,17 +241,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.physical_progress, @@ -352,17 +251,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.repayment_period, @@ -371,17 +261,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.sakht_period, @@ -390,12 +271,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.tanafos_period, @@ -404,12 +281,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.committed_employment, @@ -418,17 +291,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.existing_employment, @@ -437,17 +301,8 @@ function DashboardReserveLoan() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -455,15 +310,13 @@ function DashboardReserveLoan() { header: t("ReserveLoan.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +const CreateContent = ({ mutate, setOpenConfirmDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {permissions_list, isLoading} = usePermissions() + const requestServer = useRequest({ auth: true }); + const { permissions_list, isLoading } = usePermissions(); const validationSchema = Yup.object().shape({ name: Yup.string().required(t("AddDialog.name_error")), name_fa: Yup.string().required(t("AddDialog.name_fa_error")), @@ -32,7 +34,9 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { name: "", name_fa: "", permissions: [], - }, validationSchema, onSubmit: (values, {setSubmitting}) => { + }, + validationSchema, + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("name", values.name); formData.append("name_fa", values.name_fa); @@ -40,16 +44,18 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { formData.append(`permissions[${i}]`, values.permissions[i]); } - requestServer(ADD_ROLE_MANAGEMENT, 'post', { + requestServer(ADD_ROLE_MANAGEMENT, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -57,7 +63,7 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { <> - + { onBlur={formik.handleBlur("name")} error={formik.touched.name && Boolean(formik.errors.name)} helperText={formik.touched.name && formik.errors.name} - /> { onBlur={formik.handleBlur("name_fa")} error={formik.touched.name_fa && Boolean(formik.errors.name_fa)} helperText={formik.touched.name_fa && formik.errors.name_fa} - /> - {t("AddDialog.permission")}
+ + {t("AddDialog.permission")} +
- {formik.touched.permissions && formik.errors.permissions} - {isLoading ? - - - {t("AddDialog.loading_permissions_list")} + + {formik.touched.permissions && formik.errors.permissions} + + {isLoading ? ( + + + + {t("AddDialog.loading_permissions_list")} + - : ( - - <> - {permissions_list.map((permission, index) => ( - - { - if (e.target.checked) { - formik.setFieldValue("permissions", [...formik.values.permissions, permission.id]) - } else { - formik.setFieldValue("permissions", formik.values.permissions.filter((id) => id !== permission.id)) - } - }} - /> - } - label={permission.name_fa} - /> - - ))} - - - ) - } + ) : ( + + <> + {permissions_list.map((permission, index) => ( + + { + if (e.target.checked) { + formik.setFieldValue("permissions", [ + ...formik.values.permissions, + permission.id, + ]); + } else { + formik.setFieldValue( + "permissions", + formik.values.permissions.filter( + (id) => id !== permission.id + ) + ); + } + }} + /> + } + label={permission.name_fa} + /> + + ))} + + + )}
- - - ) -} -export default CreateContent \ No newline at end of file + ); +}; +export default CreateContent; diff --git a/src/components/dashboard/role-management/Form/CreateForm/index.jsx b/src/components/dashboard/role-management/Form/CreateForm/index.jsx index a6b9974..6b1ee7c 100644 --- a/src/components/dashboard/role-management/Form/CreateForm/index.jsx +++ b/src/components/dashboard/role-management/Form/CreateForm/index.jsx @@ -1,10 +1,10 @@ -import {Button, Dialog, DialogTitle, Stack, Tooltip} from "@mui/material"; +import { Button, Dialog, DialogTitle, Stack, Tooltip } from "@mui/material"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import CreateContent from "./CreateContent"; -const CreateForm = ({mutate}) => { +const CreateForm = ({ mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); @@ -15,21 +15,28 @@ const CreateForm = ({mutate}) => { color="primary" variant="contained" size="small" - sx={{textTransform: "unset", alignSelf: "center"}} - startIcon={} + sx={{ textTransform: "unset", alignSelf: "center" }} + startIcon={} onClick={() => { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > {t("AddDialog.add")} - + {t("AddDialog.add")} - +
- ) -} -export default CreateForm \ No newline at end of file + ); +}; +export default CreateForm; diff --git a/src/components/dashboard/role-management/Form/DeleteForm.jsx b/src/components/dashboard/role-management/Form/DeleteForm.jsx index 5f2d169..a8632a8 100644 --- a/src/components/dashboard/role-management/Form/DeleteForm.jsx +++ b/src/components/dashboard/role-management/Form/DeleteForm.jsx @@ -1,5 +1,5 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import { Button, Dialog, @@ -8,30 +8,32 @@ import { DialogTitle, IconButton, Tooltip, - Typography + Typography, } from "@mui/material"; -import DeleteIcon from '@mui/icons-material/Delete'; +import DeleteIcon from "@mui/icons-material/Delete"; import useRequest from "@/lib/app/hooks/useRequest"; import useNotification from "@/lib/app/hooks/useNotification"; -import {DELETE_ROLE_MANAGEMENT} from "@/core/data/apiRoutes"; +import { DELETE_ROLE_MANAGEMENT } from "@/core/data/apiRoutes"; -const DeleteForm = ({rowId, mutate}) => { +const DeleteForm = ({ 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 [isSubmitting, setIsSubmitting] = useState(false); + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const handleSubmit = () => { - setIsSubmitting(true) - requestServer(`${DELETE_ROLE_MANAGEMENT}/${rowId}`, 'delete').then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setIsSubmitting(false) - }); - } + setIsSubmitting(true); + requestServer(`${DELETE_ROLE_MANAGEMENT}/${rowId}`, "delete") + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setIsSubmitting(false); + }); + }; return ( <> @@ -39,25 +41,36 @@ const DeleteForm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("DeleteDialog.delete")} {t("DeleteDialog.typography")} - - @@ -65,4 +78,4 @@ const DeleteForm = ({rowId, mutate}) => { ); }; -export default DeleteForm; \ No newline at end of file +export default DeleteForm; diff --git a/src/components/dashboard/role-management/Form/UpdateForm/UpdateContent.jsx b/src/components/dashboard/role-management/Form/UpdateForm/UpdateContent.jsx index 037ed99..0496243 100644 --- a/src/components/dashboard/role-management/Form/UpdateForm/UpdateContent.jsx +++ b/src/components/dashboard/role-management/Form/UpdateForm/UpdateContent.jsx @@ -1,10 +1,11 @@ -import {UPDATE_ROLE_MANAGEMENT} from "@/core/data/apiRoutes"; +import { UPDATE_ROLE_MANAGEMENT } from "@/core/data/apiRoutes"; import useNotification from "@/lib/app/hooks/useNotification"; import usePermissions from "@/lib/app/hooks/usePermissions"; import useRequest from "@/lib/app/hooks/useRequest"; import { Button, - Checkbox, CircularProgress, + Checkbox, + CircularProgress, DialogActions, DialogContent, FormControl, @@ -13,17 +14,18 @@ import { FormLabel, Grid, Stack, - TextField, Typography -} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; + TextField, + Typography, +} from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { +const UpdateContent = ({ row, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - const {permissions_list, isLoading} = usePermissions() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); + const { permissions_list, isLoading } = usePermissions(); const validationSchema = Yup.object().shape({ name: Yup.string().required(t("UpdateDialog.name_error")), @@ -36,7 +38,9 @@ const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { name: row.getValue("name"), name_fa: row.getValue("name_fa"), permissions: row.original.permissions.map((obj) => obj.id), - }, validationSchema, onSubmit: (values, {setSubmitting}) => { + }, + validationSchema, + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("name", values.name); formData.append("name_fa", values.name_fa); @@ -44,23 +48,25 @@ const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { formData.append(`permissions[${i}]`, values.permissions[i]); } - requestServer(`${UPDATE_ROLE_MANAGEMENT}/${row.getValue("id")}`, 'post', { + requestServer(`${UPDATE_ROLE_MANAGEMENT}/${row.getValue("id")}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); return ( <> - + { /> - {t("UpdateDialog.permission")}
+ + {t("UpdateDialog.permission")} +
- {formik.touched.permissions && formik.errors.permissions} - {isLoading ? - - - {t("UpdateDialog.loading_permissions_list")} + + {formik.touched.permissions && formik.errors.permissions} + + {isLoading ? ( + + + + {t("UpdateDialog.loading_permissions_list")} + - : ( - - <> - {permissions_list.map((permission) => ( - - { - if (e.target.checked) { - formik.setFieldValue("permissions", [...formik.values.permissions, permission.id]) - } else { - formik.setFieldValue("permissions", formik.values.permissions.filter((id) => id !== permission.id)) - } - }} - /> - } - label={permission.name_fa} - /> - - ))} - - - ) - } + ) : ( + + <> + {permissions_list.map((permission) => ( + + { + if (e.target.checked) { + formik.setFieldValue("permissions", [ + ...formik.values.permissions, + permission.id, + ]); + } else { + formik.setFieldValue( + "permissions", + formik.values.permissions.filter( + (id) => id !== permission.id + ) + ); + } + }} + /> + } + label={permission.name_fa} + /> + + ))} + + + )}
- - - ) -} -export default UpdateContent \ No newline at end of file + ); +}; +export default UpdateContent; diff --git a/src/components/dashboard/role-management/Form/UpdateForm/index.jsx b/src/components/dashboard/role-management/Form/UpdateForm/index.jsx index fa3403a..f109639 100644 --- a/src/components/dashboard/role-management/Form/UpdateForm/index.jsx +++ b/src/components/dashboard/role-management/Form/UpdateForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import EditIcon from '@mui/icons-material/Edit'; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import EditIcon from "@mui/icons-material/Edit"; import UpdateContent from "./UpdateContent"; -const Update = ({row, mutate}) => { +const Update = ({ row, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); @@ -14,18 +14,25 @@ const Update = ({row, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("UpdateDialog.update")} - + - ) -} -export default Update \ No newline at end of file + ); +}; +export default Update; diff --git a/src/components/dashboard/role-management/TableRowActions.jsx b/src/components/dashboard/role-management/TableRowActions.jsx index dfa1e34..b78b75b 100644 --- a/src/components/dashboard/role-management/TableRowActions.jsx +++ b/src/components/dashboard/role-management/TableRowActions.jsx @@ -1,19 +1,12 @@ -import {Box} from "@mui/material"; -import DeleteForm from "./Form/DeleteForm" +import { Box } from "@mui/material"; +import DeleteForm from "./Form/DeleteForm"; import Update from "./Form/UpdateForm"; -const TableRowActions = ({row, mutate}) => { - +const TableRowActions = ({ row, mutate }) => { return ( - - - + + + ); }; diff --git a/src/components/dashboard/role-management/TableToolbar.jsx b/src/components/dashboard/role-management/TableToolbar.jsx index 734cb4a..afd8b7b 100644 --- a/src/components/dashboard/role-management/TableToolbar.jsx +++ b/src/components/dashboard/role-management/TableToolbar.jsx @@ -1,11 +1,10 @@ -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import CreateForm from "./Form/CreateForm/index"; -function TableToolbar({mutate}) { +function TableToolbar({ mutate }) { const t = useTranslations(); - return - + return ; } export default TableToolbar; diff --git a/src/components/dashboard/role-management/index.jsx b/src/components/dashboard/role-management/index.jsx index 335d741..87695ae 100644 --- a/src/components/dashboard/role-management/index.jsx +++ b/src/components/dashboard/role-management/index.jsx @@ -1,72 +1,78 @@ -import {Box, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_ROLE_MANAGEMENT} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_ROLE_MANAGEMENT } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import DataTable from "@/core/components/DataTable"; import moment from "jalali-moment"; import MuiDatePicker from "@/core/components/MuiDatePicker"; import TableToolbar from "@/components/dashboard/role-management/TableToolbar"; -import TableRowActions from "./TableRowActions" +import TableRowActions from "./TableRowActions"; function DashboardRoleManagementComponent() { const t = useTranslations(); - const columns = useMemo(() => [{ - accessorFn: (row) => row.id, - id: "id", - sortDescFirst: true, - header: t("RoleManagement.id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between",], - Cell: ({renderedCellValue}) => ({renderedCellValue}), - }, - { - accessorFn: (row) => row.name_fa, - id: "name_fa", - header: t("RoleManagement.name_fa"), - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ({renderedCellValue}), - }, - { - accessorFn: (row) => row.name, - id: "name", - header: t("RoleManagement.name"), - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains"], - Cell: ({renderedCellValue}) => ({renderedCellValue}), - }, - { - accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "created_at", - header: t("RoleManagement.created_at"), - enableColumnFilter: true, - datatype: "date", - filterFn: "lessThan", - columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => { - return {renderedCellValue}; + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + sortDescFirst: true, + header: t("RoleManagement.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return (); + { + accessorFn: (row) => row.name_fa, + id: "name_fa", + header: t("RoleManagement.name_fa"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, - }, { - accessorFn: (row) => moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "updated_at", - header: t("RoleManagement.updated_at"), - enableColumnFilter: false, - datatype: "numeric", - Cell: ({renderedCellValue}) => ({renderedCellValue}), - }], []); + { + accessorFn: (row) => row.name, + id: "name", + header: t("RoleManagement.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "created_at", + header: t("RoleManagement.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.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "updated_at", + header: t("RoleManagement.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + ], + [] + ); return ( - + { +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 [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(); @@ -24,30 +24,32 @@ const PrintExcel = ({table}) => { } } return { - ...filter, fn: columnFilterFns[filter.id], datatype: datatype, + ...filter, + fn: columnFilterFns[filter.id], + datatype: datatype, }; }); - params.set("start", '0'); + params.set("start", "0"); params.set("filters", JSON.stringify(filters ?? [])); params.set("sorting", JSON.stringify(sorting ?? [])); return params; - }, [columnFilters, columnFilterFns, sorting, columns,]); - + }, [columnFilters, columnFilterFns, sorting, columns]); const clickHandler = () => { - setLoading(true) - requestServer(`${EXPORT_TRANSPORTATION_ASSISTANCE}?${filterParams}`, 'get', { + setLoading(true); + requestServer(`${EXPORT_TRANSPORTATION_ASSISTANCE}?${filterParams}`, "get", { auth: true, - requestOptions: {responseType: 'blob'} - }).then((response) => { - const filename = `خروجی کارتابل بررسی وام های تبصره 18 تاریخ_${moment().format('jYYYY_jMM_jDD')}.xlsx`; - FileSaver.saveAs(response.data, filename); - }).catch(() => { - }).finally(() => { - setLoading(false) + requestOptions: { responseType: "blob" }, }) - } - + .then((response) => { + const filename = `خروجی کارتابل بررسی وام های تبصره 18 تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`; + FileSaver.saveAs(response.data, filename); + }) + .catch(() => {}) + .finally(() => { + setLoading(false); + }); + }; return ( - ) -} + ); +}; -export default PrintExcel \ No newline at end of file +export default PrintExcel; diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx index 22f9f1f..848cd60 100644 --- a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx @@ -12,28 +12,28 @@ import { LinearProgress, Stack, TextField, - Typography -} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {CONFIRM_TRANSPORTATION_ASSISTANCE, GET_TRANSPORTATION_ASSISTANCE_DETAILS} from "@/core/data/apiRoutes"; -import {useEffect, useState} from "react"; + Typography, +} from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { CONFIRM_TRANSPORTATION_ASSISTANCE, GET_TRANSPORTATION_ASSISTANCE_DETAILS } from "@/core/data/apiRoutes"; +import { useEffect, useState } from "react"; import * as Yup from "yup"; import CustomAccordion from "@/core/components/CustomAccordion"; import ImageContent from "@/core/components/ImageContent"; import NumberShowBox from "@/core/components/NumberShowBox"; -const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeClick}) => { +const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog, handleSizeChangeClick }) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - const requestServer = useRequest({auth: true, notification: false}); + const requestServer = useRequest({ auth: true, notification: false }); const [attachmentsData, setAttachmentsData] = useState([]); const [accordionStates, setAccordionStates] = useState([]); const [hasAccordionOpened, setHasAccordionOpened] = useState([]); - const {update_notification} = useNotification(); + const { update_notification } = useNotification(); const [hasImageShown, setHasImageShown] = useState(false); const [imageLink, setImageLink] = useState(null); const [detailsList, setDetailsData] = useState(null); @@ -42,47 +42,46 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl const [checked, setChecked] = useState(false); useEffect(() => { - requestServer(`${GET_TRANSPORTATION_ASSISTANCE_DETAILS}/${rowId}`, 'get') + requestServer(`${GET_TRANSPORTATION_ASSISTANCE_DETAILS}/${rowId}`, "get") .then((response) => { if (response.data.data.latest_histories.length !== 0) { - let latest_attachments = [] - let attachments = [] + let latest_attachments = []; + let attachments = []; response.data.data.latest_histories.map((allAttachment) => { - if (allAttachment.previous_state_id !== 4) - return + if (allAttachment.previous_state_id !== 4) return; if (!latest_attachments.includes(allAttachment.previous_state_id)) { - attachments = [...attachments, ...allAttachment.attachments] - latest_attachments.push(allAttachment.previous_state_id) + attachments = [...attachments, ...allAttachment.attachments]; + latest_attachments.push(allAttachment.previous_state_id); } - }) + }); setDetailsData(response.data); setAttachmentsData(attachments); } }) - .catch(() => { - }).finally(() => { - setLoading(false); - }); + .catch(() => {}) + .finally(() => { + setLoading(false); + }); }, []); useEffect(() => { if (attachmentsData.length !== 0) { - const booleanData = Array.from({length: attachmentsData.length}, () => false); + const booleanData = Array.from({ length: attachmentsData.length }, () => false); setAccordionStates(booleanData); setHasAccordionOpened(booleanData); } }, [attachmentsData]); const handleAccordionChange = (index) => { - const newAccordionStates = accordionStates.map((state, i) => i === index ? !state : false); + const newAccordionStates = accordionStates.map((state, i) => (i === index ? !state : false)); setAccordionStates(newAccordionStates); if (!newAccordionStates[index]) { - handleSizeChangeClick('sm'); + handleSizeChangeClick("sm"); setHasImageShown(false); setIsSkeleton(false); } else { - handleSizeChangeClick('xl'); + handleSizeChangeClick("xl"); setHasImageShown(true); setImageLink(attachmentsData[index]); setIsSkeleton(true); @@ -92,56 +91,59 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl } }; - const validationSchema = Yup.object().shape({ - confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error")) - .test('fileSize', `${t("TransportationAssistance.upload_file_unit")}`, (value) => { - if (!value) return true + confirm_img: Yup.mixed() + .notRequired(t("ConfirmDialog.approved_amount_error")) + .test("fileSize", `${t("TransportationAssistance.upload_file_unit")}`, (value) => { + if (!value) return true; return value.size <= 5 * 1024 * 1024; }) - .test('fileType', `${t("TransportationAssistance.upload_file_format")}`, (value) => { - if (!value) return true - const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; + .test("fileType", `${t("TransportationAssistance.upload_file_format")}`, (value) => { + if (!value) return true; + const allowedTypes = ["image/jpg", "image/jpeg", "image/png", "application/pdf"]; return allowedTypes.includes(value.type); - }) - }) + }), + }); const formik = useFormik({ initialValues: { description: "", - confirm_img: null - }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + confirm_img: null, + }, + validationSchema, + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); if (values.description !== "") formData.append("expert_description", values.description); if (values.confirm_img != null) { const attachments = [ { title: "فایل ضمیمه کارتابل بررسی وام های تبصره 18", - file: values.confirm_img - } + file: values.confirm_img, + }, ]; attachments.forEach((attachment, index) => { formData.append(`attachment[${index}][title]`, attachment.title); formData.append(`attachment[${index}][file]`, attachment.file); }); } - requestServer(`${CONFIRM_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { + requestServer(`${CONFIRM_TRANSPORTATION_ASSISTANCE}/${rowId}`, "post", { data: formData, - notification: true - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + notification: true, + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) + formik.setFieldValue("description", event.target.value); }; const handleUploadChange = (event) => { @@ -154,7 +156,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl setfileName(fileName); formik.setFieldValue("confirm_img", uploadedFile).then(() => { formik.setFieldTouched("confirm_img", true); - }) + }); setShowAddIcon(false); } }; @@ -183,25 +185,27 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl - {loading ? : + {loading ? ( + + ) : ( <> @@ -222,26 +226,31 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl /> {renderCustomAccordions()} - } + )} - {t("ConfirmDialog.description")} - {t("ConfirmDialog.optional")} - } + label={ + <> + {t("ConfirmDialog.description")} + {t("ConfirmDialog.optional")} + + } value={formik.values.description} onChange={handleDescriptionChange} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} /> - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + formik.handleBlur("confirm_img")} - error={ - formik.touched.confirm_img && - Boolean(formik.errors.confirm_img) - } + error={formik.touched.confirm_img && Boolean(formik.errors.confirm_img)} /> {formik.touched.confirm_img && formik.errors.confirm_img} @@ -267,11 +273,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl + } label={t("TransportationAssistance.confirm_text")} /> @@ -279,31 +281,44 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl - - + + - - - ) - -} -export default ConfirmContent \ No newline at end of file + ); +}; +export default ConfirmContent; diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/index.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/index.jsx index 9747618..775a884 100644 --- a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/index.jsx @@ -1,16 +1,16 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useState , useEffect} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState, useEffect } from "react"; import ConfirmContent from "./ConfirmContent"; -import CallMadeIcon from '@mui/icons-material/CallMade'; -const Confirm = ({rowId, mutate}) => { +import CallMadeIcon from "@mui/icons-material/CallMade"; +const Confirm = ({ rowId, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const [dialogSize, setDialogSize] = useState('sm'); + const [dialogSize, setDialogSize] = useState("sm"); useEffect(() => { if (!openConfirmDialog) { - setDialogSize('sm'); + setDialogSize("sm"); } }, [openConfirmDialog]); @@ -27,16 +27,29 @@ const Confirm = ({rowId, mutate}) => { setOpenConfirmDialog(true); }} > - + - + {t("TransportationAssistance.confirm")} - + - ) - -} -export default Confirm; \ No newline at end of file + ); +}; +export default Confirm; diff --git a/src/components/dashboard/transportation-assistance/Form/ReferReason/HistoryContent.jsx b/src/components/dashboard/transportation-assistance/Form/ReferReason/HistoryContent.jsx index 4628461..bd8c5ef 100644 --- a/src/components/dashboard/transportation-assistance/Form/ReferReason/HistoryContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ReferReason/HistoryContent.jsx @@ -1,12 +1,12 @@ -import {Button, DialogActions, DialogContent,} from "@mui/material" -import {useTranslations} from "next-intl"; +import { Button, DialogActions, DialogContent } from "@mui/material"; +import { useTranslations } from "next-intl"; import TableContent from "./TableContent"; -const HistoryContent = ({setOpenReferReasonDialog, row}) => { +const HistoryContent = ({ setOpenReferReasonDialog, row }) => { const t = useTranslations(); return ( <> - + - ) -} -export default HistoryContent \ No newline at end of file + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/transportation-assistance/Form/ReferReason/TableContent.jsx b/src/components/dashboard/transportation-assistance/Form/ReferReason/TableContent.jsx index 9dbcf5d..3da4401 100644 --- a/src/components/dashboard/transportation-assistance/Form/ReferReason/TableContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ReferReason/TableContent.jsx @@ -1,20 +1,13 @@ -import { - Box, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, -} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material"; +import { useTranslations } from "next-intl"; import moment from "jalali-moment"; -const TableContent = ({row}) => { +const TableContent = ({ row }) => { const t = useTranslations(); - return ( - - + return ( + + +
{t("LoanHistory.Table_head_date")} @@ -23,8 +16,12 @@ const TableContent = ({row}) => { - - {moment(row.original.latest_history.created_at).locale("fa").format("HH:mm | yyyy/MM/DD")} + + + {moment(row.original.latest_history.created_at) + .locale("fa") + .format("HH:mm | yyyy/MM/DD")} + {row.original.latest_history.previous_state_name} {row.original.latest_history.expert_description} @@ -32,7 +29,6 @@ const TableContent = ({row}) => {
- - ) -} -export default TableContent \ No newline at end of file + ); +}; +export default TableContent; diff --git a/src/components/dashboard/transportation-assistance/Form/ReferReason/index.jsx b/src/components/dashboard/transportation-assistance/Form/ReferReason/index.jsx index 40f48e1..5b46003 100644 --- a/src/components/dashboard/transportation-assistance/Form/ReferReason/index.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ReferReason/index.jsx @@ -1,30 +1,33 @@ -import { - Dialog, - DialogTitle, - IconButton, - Tooltip, -} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import RestorePageIcon from '@mui/icons-material/RestorePage'; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RestorePageIcon from "@mui/icons-material/RestorePage"; import HistoryContent from "./HistoryContent"; -const ReferReason = ({row}) => { +const ReferReason = ({ row }) => { const t = useTranslations(); const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); return ( <> setOpenReferReasonDialog(true)}> - + - + {t("ReferReasonDialog.refer_reason")} - + - ) -} -export default ReferReason \ No newline at end of file + ); +}; +export default ReferReason; diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx index 54ad696..d872a9f 100644 --- a/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx @@ -1,30 +1,31 @@ -import UploadSystem from "@/core/components/UploadSystem" +import UploadSystem from "@/core/components/UploadSystem"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; -import {Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import * as Yup from "yup"; -import {REJECT_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; +import { REJECT_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; -const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { +const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), - reject_img: Yup.mixed().notRequired(t("RejectDialog.choose_file")) - .test('fileSize', `${t("TransportationAssistance.upload_file_unit")}`, (value) => { + reject_img: Yup.mixed() + .notRequired(t("RejectDialog.choose_file")) + .test("fileSize", `${t("TransportationAssistance.upload_file_unit")}`, (value) => { return !value || (value.size && value.size <= 5 * 1024 * 1024); }) - .test('fileType', `${t("TransportationAssistance.upload_file_format")}`, (value) => { - const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types + .test("fileType", `${t("TransportationAssistance.upload_file_format")}`, (value) => { + const allowedTypes = ["image/jpg", "image/jpeg", "image/png", "application/pdf"]; // Define your allowed file types return !value || (value.type && allowedTypes.includes(value.type)); }), }); @@ -32,34 +33,36 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const formik = useFormik({ initialValues: { description: "", - reject_img: null + reject_img: null, }, validationSchema, - onSubmit: (values, {setSubmitting}) => { + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("expert_description", values.description); if (values.reject_img != null) { const attachments = [ { title: "فایل ضمیمه کارتابل بررسی وام های تبصره 18", - file: values.reject_img - } + file: values.reject_img, + }, ]; attachments.forEach((attachment, index) => { formData.append(`attachment[${index}][title]`, attachment.title); formData.append(`attachment[${index}][file]`, attachment.file); }); } - requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { + requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, "post", { data: formData, - }).then((response) => { - setOpenRejectDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenRejectDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -77,7 +80,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { setfileName(fileName); formik.setFieldValue("reject_img", uploadedFile).then(() => { formik.setFieldTouched("reject_img", true); - }) + }); setShowAddIcon(false); } }; @@ -94,17 +97,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} />
- {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + {t("UploadSystem.upload_file")} + {t("UploadSystem.optional")} + { setShowAddIcon={setShowAddIcon} showAddIcon={showAddIcon} onBlur={() => formik.handleBlur("reject_img")} - error={ - formik.touched.reject_img && - Boolean(formik.errors.reject_img) - } + error={formik.touched.reject_img && Boolean(formik.errors.reject_img)} /> - + {formik.touched.reject_img && formik.errors.reject_img}
- - - ) -} -export default RejectContent \ No newline at end of file + ); +}; +export default RejectContent; diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm/index.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm/index.jsx index 06608f5..a04d0e1 100644 --- a/src/components/dashboard/transportation-assistance/Form/RejectForm/index.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import RejectContent from "./RejectContent"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -const Reject = ({rowId, mutate}) => { +const Reject = ({ rowId, mutate }) => { const t = useTranslations(); const [openRejectDialog, setOpenRejectDialog] = useState(false); return ( <> setOpenRejectDialog(true)}> - + - + {t("RejectDialog.reject")} - + - ) -} -export default Reject \ No newline at end of file + ); +}; +export default Reject; diff --git a/src/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent.jsx b/src/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent.jsx index 0528e80..733d6cc 100644 --- a/src/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent.jsx @@ -1,15 +1,15 @@ 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 { Button, DialogActions, DialogContent, Stack, TextField } from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -import {REFER_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; +import { REFER_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; -const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { +const RevertContent = ({ rowId, mutate, setOpenRevertDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RevertDialog.description_error")), @@ -20,19 +20,21 @@ const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { description: "", }, validationSchema, - onSubmit: (values, {setSubmitting}) => { - requestServer(`${REFER_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { + onSubmit: (values, { setSubmitting }) => { + requestServer(`${REFER_TRANSPORTATION_ASSISTANCE}/${rowId}`, "post", { data: { - expert_description : values.description + expert_description: values.description, }, - }).then(() => { - setOpenRevertDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then(() => { + setOpenRevertDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -53,28 +55,35 @@ const RevertContent = ({rowId, mutate, setOpenRevertDialog}) => { value={formik.values.description} onChange={handleDescriptionChange} onBlur={formik.handleBlur("description")} - error={ - formik.touched.description && Boolean(formik.errors.description) - } + error={formik.touched.description && Boolean(formik.errors.description)} helperText={formik.touched.description && formik.errors.description} fullWidth variant="outlined" - sx={{mt: 1}} + sx={{ mt: 1 }} />
- - - ) -} -export default RevertContent \ No newline at end of file + ); +}; +export default RevertContent; diff --git a/src/components/dashboard/transportation-assistance/Form/RevertForm/index.jsx b/src/components/dashboard/transportation-assistance/Form/RevertForm/index.jsx index 316ce8b..2983cca 100644 --- a/src/components/dashboard/transportation-assistance/Form/RevertForm/index.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RevertForm/index.jsx @@ -1,25 +1,32 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import CallReceivedIcon from '@mui/icons-material/CallReceived'; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import CallReceivedIcon from "@mui/icons-material/CallReceived"; import RevertContent from "@/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent"; -const Revert = ({rowId, mutate}) => { +const Revert = ({ rowId, mutate }) => { const t = useTranslations(); const [openRevertDialog, setOpenRevertDialog] = useState(false); return ( <> setOpenRevertDialog(true)}> - + - + {t("TransportationAssistance.revert")} - + - ) -} -export default Revert \ No newline at end of file + ); +}; +export default Revert; diff --git a/src/components/dashboard/transportation-assistance/Form/UserInfoForm/LegalTableContent.jsx b/src/components/dashboard/transportation-assistance/Form/UserInfoForm/LegalTableContent.jsx new file mode 100644 index 0000000..dbabcc4 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/UserInfoForm/LegalTableContent.jsx @@ -0,0 +1,397 @@ +import { Chip, DialogContent, DialogTitle, Divider, Grid, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import moment from "jalali-moment"; + +const LegalTableContent = ({ rowId, row }) => { + const t = useTranslations(); + return ( + <> + {t("UserInfoDialog.user_info")} + + + + + + + {t("UserInfoDialog.legal_person")} + + + + + + + {row.original.id || t("UserInfoDialog.no_info")} + + + + + + + + + + {row.original.project_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.activity_category_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.first_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.last_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.father_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.gender ? t("UserInfoDialog.female") : t("UserInfoDialog.male")} + + + + + + + + + + + {row.original.national_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.national_serial_number || + row.original.national_tracking_code || + t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.education_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.occupation_title || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.phone_number || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.birthday + ? moment(row.original.birthday).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.province_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.city_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.shenase_meli || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.postal_code || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.company_register_date + ? moment(row.original.company_register_date).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.register_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.navgan_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.navgan_type || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.company_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.telephone_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.vehicle_type || t("UserInfoDialog.no_info")} + + + + + + + + + { + (row.original.investment_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", { value: (row.original.investment_amount / 1000000000) }) + : t("UserInfoDialog.toman", { value: (row.original.investment_amount / 1000000) }) + } + + + + + + + + + + + { + (row.original.requested_facility_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.requested_facility_amount / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.requested_facility_amount / 1000000)}) + } + + + + + + + + + { + (row.original.person_share / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.person_share / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.person_share / 1000000)}) + } + + + + + + + + + + + {row.original.user_committed_employment || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.user_existing_employment || t("UserInfoDialog.no_info")} + + + + + + + + + + + + {row.original.plate_number.split("-")[3] || t("UserInfoDialog.no_info")} + + + + {row.original.plate_number.split("-")[2] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[1] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[0] || t("UserInfoDialog.no_info")} + + + + + + + + + + + + + {row.original.address || t("UserInfoDialog.no_info")} + + + + + + + ); +}; +export default LegalTableContent; diff --git a/src/components/dashboard/transportation-assistance/Form/UserInfoForm/RealTableContent.jsx b/src/components/dashboard/transportation-assistance/Form/UserInfoForm/RealTableContent.jsx new file mode 100644 index 0000000..cd6e622 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/UserInfoForm/RealTableContent.jsx @@ -0,0 +1,353 @@ +import { Chip, DialogContent, DialogTitle, Divider, Grid, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; +import moment from "jalali-moment"; + +const RealTableContent = ({ rowId, row }) => { + const t = useTranslations(); + return ( + <> + {t("UserInfoDialog.user_info")} + + + + + + + {t("UserInfoDialog.real_person")} + + + + + + + {row.original.id || t("UserInfoDialog.no_info")} + + + + + + + + + + {row.original.project_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.activity_category_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.first_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.last_name || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.national_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.national_serial_number || + row.original.national_tracking_code || + t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.education_title || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.occupation_title || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.phone_number || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.telephone_number || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.birthday + ? moment(row.original.birthday).locale("fa").format("YYYY/MM/DD") + : t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.postal_code || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.father_name || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.gender ? t("UserInfoDialog.female") : t("UserInfoDialog.male")} + + + + + + + + + + + {row.original.province_name || t("UserInfoDialog.no_info")} + + + + + + + + {row.original.city_name} + + + + + + + + + + {row.original.navgan_id || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.navgan_type || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.user_committed_employment || t("UserInfoDialog.no_info")} + + + + + + + + + {row.original.user_existing_employment || t("UserInfoDialog.no_info")} + + + + + + + + + + + {row.original.vehicle_type || t("UserInfoDialog.no_info")} + + + + + + + + + { + (row.original.investment_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", { value: (row.original.investment_amount / 1000000000) }) + : t("UserInfoDialog.toman", { value: (row.original.investment_amount / 1000000) }) + } + + + + + + + + + + + { + (row.original.requested_facility_amount / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.requested_facility_amount / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.requested_facility_amount / 1000000)}) + } + + + + + + + + + { + (row.original.person_share / 1000000) >= 1000 + ? t("UserInfoDialog.milyard", {value : (row.original.person_share / 1000000000)}) + :t("UserInfoDialog.toman", {value : (row.original.person_share / 1000000)}) + } + + + + + + + + + + + + {row.original.plate_number.split("-")[3] || t("UserInfoDialog.no_info")} + + + + {row.original.plate_number.split("-")[2] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[1] || t("UserInfoDialog.no_info")} + + + {row.original.plate_number.split("-")[0] || t("UserInfoDialog.no_info")} + + + + + + + + + + + + + {row.original.address || t("UserInfoDialog.no_info")} + + + + + + + ); +}; +export default RealTableContent; diff --git a/src/components/dashboard/transportation-assistance/Form/UserInfoForm/index.jsx b/src/components/dashboard/transportation-assistance/Form/UserInfoForm/index.jsx new file mode 100644 index 0000000..aa67e15 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/UserInfoForm/index.jsx @@ -0,0 +1,47 @@ +import { Button, Dialog, DialogActions, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import ContactPageIcon from "@mui/icons-material/ContactPage"; +import LegalTableContent from "./LegalTableContent"; +import RealTableContent from "./RealTableContent"; +const UserInfoForm = ({ rowId, row }) => { + const t = useTranslations(); + const [openUserInfoDialog, setOpenUserInfoDialog] = useState(false); + return ( + <> + + { + setOpenUserInfoDialog(true); + }} + > + + + + + {row.original.is_legal_person === 1 ? ( + + ) : ( + + )} + + + + + + ); +}; +export default UserInfoForm; diff --git a/src/components/dashboard/transportation-assistance/TableRowActions.jsx b/src/components/dashboard/transportation-assistance/TableRowActions.jsx index 70cef2c..2ece96d 100644 --- a/src/components/dashboard/transportation-assistance/TableRowActions.jsx +++ b/src/components/dashboard/transportation-assistance/TableRowActions.jsx @@ -1,26 +1,18 @@ -import {Box} from "@mui/material"; +import { Box } from "@mui/material"; import Confirm from "./Form/ConfirmForm"; import Reject from "./Form/RejectForm"; import Revert from "@/components/dashboard/transportation-assistance/Form/RevertForm"; import ReferReason from "@/components/dashboard/transportation-assistance/Form/ReferReason"; +import UserInfoForm from "./Form/UserInfoForm"; -const TableRow = ({row, mutate}) => { - +const TableRow = ({ row, mutate }) => { return ( - - {row.original.latest_history?.action === "refer" ? : null} - - - + + {row.original.latest_history?.action === "refer" ? : null} + + + + ); }; diff --git a/src/components/dashboard/transportation-assistance/TableToolbar.jsx b/src/components/dashboard/transportation-assistance/TableToolbar.jsx index 1f7c2d2..11fb04d 100644 --- a/src/components/dashboard/transportation-assistance/TableToolbar.jsx +++ b/src/components/dashboard/transportation-assistance/TableToolbar.jsx @@ -1,13 +1,12 @@ -import {Stack} from "@mui/material"; +import { Stack } from "@mui/material"; import PrintExcel from "@/components/dashboard/transportation-assistance/Buttons/printExcel"; -const TableToolbar = ({table}) => { - +const TableToolbar = ({ table }) => { return ( - + - ) -} + ); +}; -export default TableToolbar \ No newline at end of file +export default TableToolbar; diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx index b44404c..c1e0899 100644 --- a/src/components/dashboard/transportation-assistance/index.jsx +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -1,7 +1,7 @@ -import {Box, Stack, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, Stack, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; import moment from "jalali-moment"; import DataTable from "@/core/components/DataTable"; @@ -19,17 +19,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.is_legal_person, @@ -39,9 +30,12 @@ function DashboardTransportationAssistanceComponent() { datatype: "numeric", filterFn: "equals", columnFilterModeOptions: ["equals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue === 1 ? `${t("TransportationAssistance.hoghoghi")}` : `${t("TransportationAssistance.haghighi")}`} + Cell: ({ renderedCellValue }) => ( + + {renderedCellValue === 1 + ? `${t("TransportationAssistance.hoghoghi")}` + : `${t("TransportationAssistance.haghighi")}`} + ), }, { @@ -51,17 +45,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.name, @@ -71,9 +56,7 @@ function DashboardTransportationAssistanceComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { @@ -83,17 +66,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.shenase_meli, @@ -102,17 +76,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.province_name, @@ -122,9 +87,7 @@ function DashboardTransportationAssistanceComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.city_name, @@ -134,27 +97,20 @@ function DashboardTransportationAssistanceComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), id: "created_at", header: t("TransportationAssistance.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - ); + Cell: ({ renderedCellValue }) => {renderedCellValue}, + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ; }, }, { @@ -164,17 +120,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.statement_count, @@ -183,12 +130,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.vehicle_type, @@ -198,9 +141,7 @@ function DashboardTransportationAssistanceComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.plate_number, @@ -210,24 +151,36 @@ function DashboardTransportationAssistanceComponent() { datatype: "text", filterFn: "contains", columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ( - - - {renderedCellValue.split('-')[3]} + Cell: ({ renderedCellValue }) => ( + + + {renderedCellValue.split("-")[3]} - - {renderedCellValue.split('-')[2]} - {renderedCellValue.split('-')[1]} - {renderedCellValue.split('-')[0]} + + + {renderedCellValue.split("-")[2]} + + + {renderedCellValue.split("-")[1]} + + + {renderedCellValue.split("-")[0]} + ), @@ -239,17 +192,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_bank, @@ -258,17 +202,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_gov, @@ -277,17 +212,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.facility_person, @@ -296,17 +222,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue / 1000000}, }, { accessorFn: (row) => row.physical_progress, @@ -315,17 +232,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.repayment_period, @@ -334,17 +242,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.sakht_period, @@ -353,12 +252,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.tanafos_period, @@ -367,12 +262,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.committed_employment, @@ -381,17 +272,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.existing_employment, @@ -400,17 +282,8 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, { accessorFn: (row) => row.state_name, @@ -418,15 +291,13 @@ function DashboardTransportationAssistanceComponent() { header: t("TransportationAssistance.state_name"), enableColumnFilter: false, datatype: "numeric", - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), + Cell: ({ renderedCellValue }) => {renderedCellValue}, }, ], [] ); return ( - + { +const CreateContent = ({ mutate, setOpenConfirmDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) + const requestServer = useRequest({ auth: true }); const validationSchema = Yup.object().shape({ - phone_number: Yup.mixed().test("is-number", `${t("AddDialog.phone_number_number")}`, (value) => !isNaN(value)).test("positive", `${t("AddDialog.phone_number_positive")}`, (value) => value >= 0) + phone_number: Yup.mixed() + .test("is-number", `${t("AddDialog.phone_number_number")}`, (value) => !isNaN(value)) + .test("positive", `${t("AddDialog.phone_number_positive")}`, (value) => value >= 0) .test("max", `${t("AddDialog.phone_number_max")}`, (value) => value.length <= 11) .required(t("AddDialog.phone_number_error")), - national_id: Yup.mixed().test("is-number", `${t("AddDialog.national_id_number")}`, (value) => !isNaN(value)).test("positive", `${t("AddDialog.national_id_positive")}`, (value) => value >= 0) + national_id: Yup.mixed() + .test("is-number", `${t("AddDialog.national_id_number")}`, (value) => !isNaN(value)) + .test("positive", `${t("AddDialog.national_id_positive")}`, (value) => value >= 0) .test("max", `${t("AddDialog.national_id_max")}`, (value) => value.length <= 10) .required(t("AddDialog.national_id_error")), type_id: Yup.number().required(t("AddDialog.type_id_error")), - navgan_id: Yup.number().when('type_id', { + navgan_id: Yup.number().when("type_id", { is: 1, // Condition: Check if type_id is equal to 1 then: (schema) => schema.required(t("AddDialog.navgan_id_error")), otherwise: (schema) => schema, // No validation for navgan_id when type_id is not 1 - }) + }), }); const formik = useFormik({ @@ -40,23 +44,27 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { national_id: "", type_id: "", navgan_id: "", - }, validationSchema, onSubmit: (values, {setSubmitting}) => { + }, + validationSchema, + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("phone_number", values.phone_number); formData.append("national_id", values.national_id); formData.append("type_id", values.type_id); if (formik.values.type_id === 1) formData.append("navgan_id", values.navgan_id); - requestServer(ADD_USER_MANAGEMENT, 'post', { + requestServer(ADD_USER_MANAGEMENT, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); @@ -71,18 +79,20 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { label={t("AddDialog.phone_number")} type="text" inputProps={{ - inputMode: "number", min: 0, pattern: "[0-9]*", + inputMode: "number", + min: 0, + pattern: "[0-9]*", }} value={formik.values.phone_number} onChange={(event) => { - if (event.target.value.length <= 11) return formik.handleChange(event) + if (event.target.value.length <= 11) return formik.handleChange(event); }} fullWidth variant="outlined" onBlur={formik.handleBlur("phone_number")} error={formik.touched.phone_number && Boolean(formik.errors.phone_number)} helperText={formik.touched.phone_number && formik.errors.phone_number} - sx={{mt: 1}} + sx={{ mt: 1 }} /> @@ -92,20 +102,18 @@ const CreateContent = ({mutate, setOpenConfirmDialog}) => { label={t("AddDialog.national_id")} value={formik.values.national_id} onChange={(event) => { - if (event.target.value.length <= 10) return formik.handleChange(event) + if (event.target.value.length <= 10) return formik.handleChange(event); }} fullWidth variant="outlined" onBlur={formik.handleBlur("national_id")} error={formik.touched.national_id && Boolean(formik.errors.national_id)} helperText={formik.touched.national_id && formik.errors.national_id} - sx={{mt: 1}} + sx={{ mt: 1 }} /> - + {t("AddDialog.type_id")} - - {formik.touched.type_id && formik.errors.type_id} - + {formik.touched.type_id && formik.errors.type_id} - {formik.values.type_id === 1 ? () : null} + {formik.values.type_id === 1 ? ( + + ) : null} - - - ) -} -export default CreateContent \ No newline at end of file + ); +}; +export default CreateContent; diff --git a/src/components/dashboard/user-management/Form/CreateForm/index.jsx b/src/components/dashboard/user-management/Form/CreateForm/index.jsx index 3eef755..98ab942 100644 --- a/src/components/dashboard/user-management/Form/CreateForm/index.jsx +++ b/src/components/dashboard/user-management/Form/CreateForm/index.jsx @@ -1,10 +1,10 @@ -import {Button, Dialog, DialogTitle, Stack, Tooltip} from "@mui/material"; +import { Button, Dialog, DialogTitle, Stack, Tooltip } from "@mui/material"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import CreateContent from "@/components/dashboard/user-management/Form/CreateForm/CreateContent"; -const CreateForm = ({mutate}) => { +const CreateForm = ({ mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); @@ -15,21 +15,28 @@ const CreateForm = ({mutate}) => { color="primary" variant="contained" size="small" - sx={{textTransform: "unset", alignSelf: "center"}} - startIcon={} + sx={{ textTransform: "unset", alignSelf: "center" }} + startIcon={} onClick={() => { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > {t("AddDialog.add")} - + {t("AddDialog.add")} - + - ) -} -export default CreateForm \ No newline at end of file + ); +}; +export default CreateForm; diff --git a/src/components/dashboard/user-management/Form/DeleteForm.jsx b/src/components/dashboard/user-management/Form/DeleteForm.jsx index 40aa5e7..c10a03e 100644 --- a/src/components/dashboard/user-management/Form/DeleteForm.jsx +++ b/src/components/dashboard/user-management/Form/DeleteForm.jsx @@ -1,5 +1,5 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import { Button, Dialog, @@ -8,29 +8,31 @@ import { DialogTitle, IconButton, Tooltip, - Typography + Typography, } from "@mui/material"; -import DeleteIcon from '@mui/icons-material/Delete'; -import {DELETE_USER_MANAGEMENT} from "@/core/data/apiRoutes"; +import DeleteIcon from "@mui/icons-material/Delete"; +import { DELETE_USER_MANAGEMENT } from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; import useNotification from "@/lib/app/hooks/useNotification"; -const DeleteForm = ({rowId, mutate}) => { +const DeleteForm = ({ 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 [isSubmitting, setIsSubmitting] = useState(false); + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const handleSubmit = () => { - setIsSubmitting(true) - requestServer(`${DELETE_USER_MANAGEMENT}/${rowId}`, 'delete').then((response) => { - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setIsSubmitting(false) - }); - } + setIsSubmitting(true); + requestServer(`${DELETE_USER_MANAGEMENT}/${rowId}`, "delete") + .then((response) => { + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setIsSubmitting(false); + }); + }; return ( <> @@ -38,25 +40,36 @@ const DeleteForm = ({rowId, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("DeleteDialog.delete")} {t("DeleteDialog.typography")} - - @@ -64,4 +77,4 @@ const DeleteForm = ({rowId, mutate}) => { ); }; -export default DeleteForm; \ No newline at end of file +export default DeleteForm; diff --git a/src/components/dashboard/user-management/Form/UpdateForm/UpdateContent.jsx b/src/components/dashboard/user-management/Form/UpdateForm/UpdateContent.jsx index 75f529a..a143e1e 100644 --- a/src/components/dashboard/user-management/Form/UpdateForm/UpdateContent.jsx +++ b/src/components/dashboard/user-management/Form/UpdateForm/UpdateContent.jsx @@ -1,4 +1,4 @@ -import {UPDATE_USER_MANAGEMENT} from "@/core/data/apiRoutes"; +import { UPDATE_USER_MANAGEMENT } from "@/core/data/apiRoutes"; import useNotification from "@/lib/app/hooks/useNotification"; import useRequest from "@/lib/app/hooks/useRequest"; import { @@ -11,30 +11,34 @@ import { MenuItem, Select, Stack, - TextField -} from "@mui/material" -import {useFormik} from "formik"; -import {useTranslations} from "next-intl"; + TextField, +} from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { +const UpdateContent = ({ row, mutate, setOpenConfirmDialog }) => { const t = useTranslations(); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() + const requestServer = useRequest({ auth: true }); + const { update_notification } = useNotification(); const validationSchema = Yup.object().shape({ - phone_number: Yup.mixed().test("is-number", `${t("AddDialog.phone_number_number")}`, (value) => !isNaN(value)).test("positive", `${t("AddDialog.phone_number_positive")}`, (value) => value >= 0) + phone_number: Yup.mixed() + .test("is-number", `${t("AddDialog.phone_number_number")}`, (value) => !isNaN(value)) + .test("positive", `${t("AddDialog.phone_number_positive")}`, (value) => value >= 0) .test("max", `${t("AddDialog.phone_number_max")}`, (value) => value.length == 11) .required(t("AddDialog.phone_number_error")), - national_id: Yup.mixed().test("is-number", `${t("AddDialog.national_id_number")}`, (value) => !isNaN(value)).test("positive", `${t("AddDialog.national_id_positive")}`, (value) => value >= 0) + national_id: Yup.mixed() + .test("is-number", `${t("AddDialog.national_id_number")}`, (value) => !isNaN(value)) + .test("positive", `${t("AddDialog.national_id_positive")}`, (value) => value >= 0) .test("max", `${t("AddDialog.national_id_max")}`, (value) => value.length <= 10) .required(t("AddDialog.national_id_error")), type_id: Yup.number().required(t("AddDialog.type_id_error")), - navgan_id: Yup.number().when('type_id', { + navgan_id: Yup.number().when("type_id", { is: 1, // Condition: Check if type_id is equal to 1 then: (schema) => schema.required(t("AddDialog.navgan_id_error")), otherwise: (schema) => schema, // No validation for navgan_id when type_id is not 1 - }) + }), }); const formik = useFormik({ @@ -42,23 +46,27 @@ const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { phone_number: row.getValue("phone_number"), national_id: row.getValue("national_id"), type_id: row.original.type_id, - navgan_id: row.original.type_id === 1 ? row.getValue("navgan_id") : '', - }, validationSchema, onSubmit: (values, {setSubmitting}) => { + navgan_id: row.original.type_id === 1 ? row.getValue("navgan_id") : "", + }, + validationSchema, + onSubmit: (values, { setSubmitting }) => { const formData = new FormData(); formData.append("phone_number", values.phone_number); formData.append("national_id", values.national_id); formData.append("type_id", values.type_id); if (formik.values.type_id === 1) formData.append("navgan_id", values.navgan_id); - requestServer(`${UPDATE_USER_MANAGEMENT}/${row.getValue("id")}`, 'post', { + requestServer(`${UPDATE_USER_MANAGEMENT}/${row.getValue("id")}`, "post", { data: formData, - }).then((response) => { - setOpenConfirmDialog(false) - mutate() - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); + }) + .then((response) => { + setOpenConfirmDialog(false); + mutate(); + update_notification(); + }) + .catch(() => {}) + .finally(() => { + setSubmitting(false); + }); }, }); return ( @@ -72,14 +80,14 @@ const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { label={t("UpdateDialog.phone_number")} value={formik.values.phone_number} onChange={(event) => { - if (event.target.value.length <= 11) return formik.handleChange(event) + if (event.target.value.length <= 11) return formik.handleChange(event); }} fullWidth variant="outlined" onBlur={formik.handleBlur("phone_number")} error={formik.touched.phone_number && Boolean(formik.errors.phone_number)} helperText={formik.touched.phone_number && formik.errors.phone_number} - sx={{mt: 1}} + sx={{ mt: 1 }} /> @@ -89,20 +97,18 @@ const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => { label={t("UpdateDialog.national_id")} value={formik.values.national_id} onChange={(event) => { - if (event.target.value.length <= 10) return formik.handleChange(event) + if (event.target.value.length <= 10) return formik.handleChange(event); }} fullWidth variant="outlined" onBlur={formik.handleBlur("national_id")} error={formik.touched.national_id && Boolean(formik.errors.national_id)} helperText={formik.touched.national_id && formik.errors.national_id} - sx={{mt: 1}} + sx={{ mt: 1 }} /> - + {t("UpdateDialog.type_id")} - - {formik.touched.type_id && formik.errors.type_id} - + {formik.touched.type_id && formik.errors.type_id} - {formik.values.type_id === 1 ? () : null} + {formik.values.type_id === 1 ? ( + + ) : null} - - - ) -} -export default UpdateContent \ No newline at end of file + ); +}; +export default UpdateContent; diff --git a/src/components/dashboard/user-management/Form/UpdateForm/index.jsx b/src/components/dashboard/user-management/Form/UpdateForm/index.jsx index a00cd74..d85b573 100644 --- a/src/components/dashboard/user-management/Form/UpdateForm/index.jsx +++ b/src/components/dashboard/user-management/Form/UpdateForm/index.jsx @@ -1,10 +1,10 @@ -import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material" -import EditIcon from '@mui/icons-material/Edit'; -import {useTranslations} from "next-intl"; -import {useState} from "react"; +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import EditIcon from "@mui/icons-material/Edit"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; import UpdateContent from "./UpdateContent"; -const Update = ({row, mutate}) => { +const Update = ({ row, mutate }) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -13,18 +13,25 @@ const Update = ({row, mutate}) => { { - setOpenConfirmDialog(true) + setOpenConfirmDialog(true); }} > - + - + {t("UpdateDialog.update")} - + - ) -} -export default Update \ No newline at end of file + ); +}; +export default Update; diff --git a/src/components/dashboard/user-management/TableRowActions.jsx b/src/components/dashboard/user-management/TableRowActions.jsx index dfa1e34..b78b75b 100644 --- a/src/components/dashboard/user-management/TableRowActions.jsx +++ b/src/components/dashboard/user-management/TableRowActions.jsx @@ -1,19 +1,12 @@ -import {Box} from "@mui/material"; -import DeleteForm from "./Form/DeleteForm" +import { Box } from "@mui/material"; +import DeleteForm from "./Form/DeleteForm"; import Update from "./Form/UpdateForm"; -const TableRowActions = ({row, mutate}) => { - +const TableRowActions = ({ row, mutate }) => { return ( - - - + + + ); }; diff --git a/src/components/dashboard/user-management/TableToolbar.jsx b/src/components/dashboard/user-management/TableToolbar.jsx index 8653e08..81093a1 100644 --- a/src/components/dashboard/user-management/TableToolbar.jsx +++ b/src/components/dashboard/user-management/TableToolbar.jsx @@ -1,11 +1,10 @@ -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import CreateForm from "@/components/dashboard/user-management/Form/CreateForm"; -function TableToolbar({mutate}) { +function TableToolbar({ mutate }) { const t = useTranslations(); - return - + return ; } export default TableToolbar; diff --git a/src/components/dashboard/user-management/index.jsx b/src/components/dashboard/user-management/index.jsx index 6f06eed..6ecb78c 100644 --- a/src/components/dashboard/user-management/index.jsx +++ b/src/components/dashboard/user-management/index.jsx @@ -1,119 +1,134 @@ -import {Box, FormControl, FormHelperText, IconButton, MenuItem, Select, Stack, Typography} from "@mui/material"; -import {useMemo} from "react"; -import {GET_USER_MANAGEMENT} from "@/core/data/apiRoutes"; -import {useTranslations} from "next-intl"; +import { Box, FormControl, FormHelperText, IconButton, MenuItem, Select, Stack, Typography } from "@mui/material"; +import { useMemo } from "react"; +import { GET_USER_MANAGEMENT } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import DataTable from "@/core/components/DataTable"; import moment from "jalali-moment"; import MuiDatePicker from "@/core/components/MuiDatePicker"; import TableToolbar from "@/components/dashboard/user-management/TableToolbar"; -import TableRowActions from "./TableRowActions" +import TableRowActions from "./TableRowActions"; import ClearIcon from "@mui/icons-material/Clear"; function DashboardUserManagementComponent() { const t = useTranslations(); - const columns = useMemo(() => [{ - accessorFn: (row) => row.id, - id: "id", - sortDescFirst: true, - header: t("UserManagement.id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between",], - Cell: ({renderedCellValue}) => ({renderedCellValue}), - }, { - accessorFn: (row) => row.navgan_id, - id: "navgan_id", - header: t("UserManagement.navgan_id"), - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({renderedCellValue}) => ({renderedCellValue}), - }, { - accessorFn: (row) => row.national_id, - id: "national_id", - header: t("UserManagement.national_id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between",], - Cell: ({renderedCellValue}) => ({renderedCellValue}), - }, { - accessorFn: (row) => row.phone_number, - id: "phone_number", - header: t("UserManagement.phone_number"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between",], - Cell: ({renderedCellValue}) => ({renderedCellValue}), - }, { - accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "created_at", - header: t("UserManagement.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.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "updated_at", - header: t("UserManagement.updated_at"), - enableColumnFilter: false, - datatype: "numeric", - Cell: ({renderedCellValue}) => ({renderedCellValue}), - }, { - accessorFn: (row) => row.type_name, - id: "type_id", - header: t("UserManagement.type_name"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: ["equals"], - Cell: ({renderedCellValue}) => ({renderedCellValue}), - Header: ({column}) => <>{column.columnDef.header}, - Filter: ({column}) => { - return ( - - - {t("filter_mode")}: {t(column.columnDef._filterFn)} - - { - column.setFilterValue(null); - }} - sx={{ - color: column.getFilterValue() ? "rgba(0, 0, 0, 0.54)" : "#bfbfbf" - }} - > - - - ) - } - },], []); + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + sortDescFirst: true, + header: t("UserManagement.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("UserManagement.navgan_id"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("UserManagement.national_id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.phone_number, + id: "phone_number", + header: t("UserManagement.phone_number"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "created_at", + header: t("UserManagement.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.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "updated_at", + header: t("UserManagement.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({ renderedCellValue }) => {renderedCellValue}, + }, + { + accessorFn: (row) => row.type_name, + id: "type_id", + header: t("UserManagement.type_name"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: ["equals"], + Cell: ({ renderedCellValue }) => {renderedCellValue}, + Header: ({ column }) => <>{column.columnDef.header}, + Filter: ({ column }) => { + return ( + + + + + {t("filter_mode")}: {t(column.columnDef._filterFn)} + + + { + column.setFilterValue(null); + }} + sx={{ + color: column.getFilterValue() ? "rgba(0, 0, 0, 0.54)" : "#bfbfbf", + }} + > + + + + ); + }, + }, + ], + [] + ); return ( - + { return ( <> - - + + - + {t("ErrorPage.custom_403")} @@ -25,8 +25,7 @@ const UnAuthorizedComponent = () => { pathname: "/", }} > - {t("ErrorPage.link_routing_back_to")}{" "} - {t("ErrorPage.link_routing_main_page")} + {t("ErrorPage.link_routing_back_to")} {t("ErrorPage.link_routing_main_page")} diff --git a/src/components/errors/404.jsx b/src/components/errors/404.jsx index acfd418..68d74cd 100644 --- a/src/components/errors/404.jsx +++ b/src/components/errors/404.jsx @@ -1,8 +1,8 @@ import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; -import {Button, Typography} from "@mui/material"; -import {NextLinkComposed} from "@/core/components/LinkRouting"; -import {useTranslations} from "next-intl"; +import { Button, Typography } from "@mui/material"; +import { NextLinkComposed } from "@/core/components/LinkRouting"; +import { useTranslations } from "next-intl"; import TitlePage from "@/core/components/TitlePage"; import Svg404 from "@/core/components/svgs/Svg404"; @@ -11,10 +11,10 @@ const NotFoundComponent = () => { return ( <> - - + + - + {t("ErrorPage.custom_404")} @@ -25,8 +25,7 @@ const NotFoundComponent = () => { pathname: "/", }} > - {t("ErrorPage.link_routing_back_to")}{" "} - {t("ErrorPage.link_routing_main_page")} + {t("ErrorPage.link_routing_back_to")} {t("ErrorPage.link_routing_main_page")} diff --git a/src/components/errors/500.jsx b/src/components/errors/500.jsx index 10e9d12..5eba029 100644 --- a/src/components/errors/500.jsx +++ b/src/components/errors/500.jsx @@ -1,8 +1,8 @@ import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; -import {Box, Button, Container, Stack, Typography} from "@mui/material"; -import {NextLinkComposed} from "@/core/components/LinkRouting"; -import {useTranslations} from "next-intl"; +import { Box, Button, Container, Stack, Typography } from "@mui/material"; +import { NextLinkComposed } from "@/core/components/LinkRouting"; +import { useTranslations } from "next-intl"; import Image from "next/image"; import TitlePage from "@/core/components/TitlePage"; @@ -11,18 +11,13 @@ const ServerErrorComponent = () => { return ( <> - - + + - - - {t("app_name")} + + + {t("app_name")} {t("ErrorPage.custom_500")} @@ -34,8 +29,7 @@ const ServerErrorComponent = () => { pathname: "/", }} > - {t("ErrorPage.link_routing_back_to")}{" "} - {t("ErrorPage.link_routing_main_page")} + {t("ErrorPage.link_routing_back_to")} {t("ErrorPage.link_routing_main_page")} diff --git a/src/components/first/__tests__/index.test.js b/src/components/first/__tests__/index.test.js index 6bb7e1c..34370ec 100644 --- a/src/components/first/__tests__/index.test.js +++ b/src/components/first/__tests__/index.test.js @@ -1,5 +1,5 @@ describe("First Component From First Page", () => { it("App Name Text Rendered", () => { - expect(2 + 2).toBe(4) + expect(2 + 2).toBe(4); }); -}); \ No newline at end of file +}); diff --git a/src/components/first/index.jsx b/src/components/first/index.jsx index 2d144f1..aa986eb 100644 --- a/src/components/first/index.jsx +++ b/src/components/first/index.jsx @@ -1,20 +1,20 @@ -import LinkRouting, {NextLinkComposed} from "@/core/components/LinkRouting"; +import LinkRouting, { NextLinkComposed } from "@/core/components/LinkRouting"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useUser from "@/lib/app/hooks/useUser"; -import {Button, Stack, Typography} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Button, Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; import SvgDashboard from "@/core/components/svgs/SvgDashboard"; const FirstComponent = () => { const t = useTranslations(); - const {isAuth} = useUser(); + const { isAuth } = useUser(); return ( - + - - + + {t("app_name")} - v{process.env.NEXT_PUBLIC_API_VERSION} @@ -52,4 +53,4 @@ const FirstComponent = () => { ); }; -export default FirstComponent; \ No newline at end of file +export default FirstComponent; diff --git a/src/components/layouts/Dashboard/Breadcrumbs/BreadcrumbItem.jsx b/src/components/layouts/Dashboard/Breadcrumbs/BreadcrumbItem.jsx index c233be3..e173405 100644 --- a/src/components/layouts/Dashboard/Breadcrumbs/BreadcrumbItem.jsx +++ b/src/components/layouts/Dashboard/Breadcrumbs/BreadcrumbItem.jsx @@ -1,6 +1,6 @@ import LinkRouting from "@/core/components/LinkRouting"; -import {Typography} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; export default function BreadcrumbItem(props) { const t = useTranslations(); diff --git a/src/components/layouts/Dashboard/Breadcrumbs/index.jsx b/src/components/layouts/Dashboard/Breadcrumbs/index.jsx index 9ab234e..8b9bcde 100644 --- a/src/components/layouts/Dashboard/Breadcrumbs/index.jsx +++ b/src/components/layouts/Dashboard/Breadcrumbs/index.jsx @@ -1,11 +1,11 @@ -import {useRouter} from "next/router"; -import {Box, Breadcrumbs} from "@mui/material"; -import {useTheme} from "@mui/material/styles"; -import {NavigateBefore, NavigateNext} from "@mui/icons-material"; +import { useRouter } from "next/router"; +import { Box, Breadcrumbs } from "@mui/material"; +import { useTheme } from "@mui/material/styles"; +import { NavigateBefore, NavigateNext } from "@mui/icons-material"; import BreadcrumbItem from "./BreadcrumbItem"; const BreadCrumbs = (props) => { - const {isVisible} = props; + const { isVisible } = props; const theme = useTheme(); const router = useRouter(); @@ -13,7 +13,7 @@ const BreadCrumbs = (props) => { return null; } - const {pathname} = router; + const { pathname } = router; const RouterArray = pathname.split("/").filter((segment) => segment !== ""); if (RouterArray.length === 1) { @@ -25,21 +25,12 @@ const BreadCrumbs = (props) => { - ) : ( - - ) + theme.direction === "ltr" ? : } aria-label="breadcrumb" > {RouterArray.map((segment, index) => ( - + ))} diff --git a/src/components/layouts/Dashboard/Content/index.jsx b/src/components/layouts/Dashboard/Content/index.jsx index e3f39db..272f1fb 100644 --- a/src/components/layouts/Dashboard/Content/index.jsx +++ b/src/components/layouts/Dashboard/Content/index.jsx @@ -2,64 +2,68 @@ import LoadingHardPage from "@/core/components/LoadingHardPage"; import RolePermissionMiddleware from "@/middlewares/RolePermission"; import BreadCrumbs from "@/components/layouts/Dashboard/Breadcrumbs"; import FullPageLayout from "@/layouts/FullPageLayout"; -import {useEffect, useMemo, useState} from "react"; +import { useEffect, useMemo, useState } from "react"; import sidebarMenu from "@/core/data/sidebarMenu"; -import {useRouter} from "next/router"; -import {useTranslations} from "next-intl"; +import { useRouter } from "next/router"; +import { useTranslations } from "next-intl"; const Content = (props) => { - const t = useTranslations() - const router = useRouter() - const [routing, setRouting] = useState(false) - const [routingItem, setRoutingItem] = useState({}) + const t = useTranslations(); + const router = useRouter(); + const [routing, setRouting] = useState(false); + const [routingItem, setRoutingItem] = useState({}); const pageList = useMemo(() => { - const list = [] + const list = []; for (const menu of sidebarMenu) { for (const item of menu) { - if (item.type === 'menu') { + if (item.type === "menu") { for (const subItem of item.subItem) { - list.push(subItem) + list.push(subItem); } } else { - list.push(item) + list.push(item); } } } - return list - }, []) + return list; + }, []); useEffect(() => { const handlerStartRoute = (url) => { - setRoutingItem(pageList.find(page => page.route === url)) - setRouting(true) - } + setRoutingItem(pageList.find((page) => page.route === url)); + setRouting(true); + }; const handlerCompleteRoute = () => { - setRouting(false) - } + setRouting(false); + }; - router.events.on('routeChangeStart', handlerStartRoute) - router.events.on('routeChangeComplete', handlerCompleteRoute) + router.events.on("routeChangeStart", handlerStartRoute); + router.events.on("routeChangeComplete", handlerCompleteRoute); return () => { - router.events.off('routeChangeStart', handlerStartRoute) - router.events.off('routeChangeComplete', handlerCompleteRoute) - } + router.events.off("routeChangeStart", handlerStartRoute); + router.events.off("routeChangeComplete", handlerCompleteRoute); + }; }, [router]); return ( - - + + - + {props.children} - ) -} + ); +}; -export default Content \ No newline at end of file +export default Content; diff --git a/src/components/layouts/Dashboard/Header/ProfileData.jsx b/src/components/layouts/Dashboard/Header/ProfileData.jsx index 548378b..8691aef 100644 --- a/src/components/layouts/Dashboard/Header/ProfileData.jsx +++ b/src/components/layouts/Dashboard/Header/ProfileData.jsx @@ -1,16 +1,12 @@ -import {Avatar, Stack, Typography} from "@mui/material"; +import { Avatar, Stack, Typography } from "@mui/material"; import useUser from "@/lib/app/hooks/useUser"; export default function ProfileData() { - const {user} = useUser(); + const { user } = useUser(); return ( - - - + + + {user.username} diff --git a/src/components/layouts/Dashboard/Header/ProfileMenu.jsx b/src/components/layouts/Dashboard/Header/ProfileMenu.jsx index 415d501..1f43f46 100644 --- a/src/components/layouts/Dashboard/Header/ProfileMenu.jsx +++ b/src/components/layouts/Dashboard/Header/ProfileMenu.jsx @@ -1,14 +1,14 @@ -import {Avatar, IconButton, Menu, Tooltip} from "@mui/material"; -import {useState} from "react"; +import { Avatar, IconButton, Menu, Tooltip } from "@mui/material"; +import { useState } from "react"; import ProfileData from "./ProfileData"; import ProfileOptions from "./ProfileOptions"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import useUser from "@/lib/app/hooks/useUser"; function ProfileMenu() { const t = useTranslations(); const [anchorElUser, setAnchorElUser] = useState(null); - const {user} = useUser(); + const { user } = useUser(); const handleOpenUserMenu = (event) => { setAnchorElUser(event.currentTarget); @@ -20,7 +20,7 @@ function ProfileMenu() { return ( <> - + - - + + ); diff --git a/src/components/layouts/Dashboard/Header/ProfileOptionLogOut.jsx b/src/components/layouts/Dashboard/Header/ProfileOptionLogOut.jsx index 2a6cf85..3411357 100644 --- a/src/components/layouts/Dashboard/Header/ProfileOptionLogOut.jsx +++ b/src/components/layouts/Dashboard/Header/ProfileOptionLogOut.jsx @@ -1,11 +1,11 @@ -import {Box, Button, MenuItem, Typography} from "@mui/material"; +import { Box, Button, MenuItem, Typography } from "@mui/material"; import MeetingRoomIcon from "@mui/icons-material/MeetingRoom"; import useUser from "@/lib/app/hooks/useUser"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; -export default function ProfileOptionLogOut({handleCloseUserMenu}) { +export default function ProfileOptionLogOut({ handleCloseUserMenu }) { const t = useTranslations(); - const {clearToken} = useUser(); + const { clearToken } = useUser(); const handleClickLogOut = () => { handleCloseUserMenu(); clearToken(); @@ -28,7 +28,7 @@ export default function ProfileOptionLogOut({handleCloseUserMenu}) { }} onClick={handleClickLogOut} > - + - + - + {t("header.logout")} diff --git a/src/components/layouts/Dashboard/Header/ProfileOptions.jsx b/src/components/layouts/Dashboard/Header/ProfileOptions.jsx index 6e7bdba..3f75cc0 100644 --- a/src/components/layouts/Dashboard/Header/ProfileOptions.jsx +++ b/src/components/layouts/Dashboard/Header/ProfileOptions.jsx @@ -1,10 +1,10 @@ -import {Box, MenuItem, Typography} from "@mui/material"; -import {NextLinkComposed} from "@/core/components/LinkRouting"; -import {useTranslations} from "next-intl"; +import { Box, MenuItem, Typography } from "@mui/material"; +import { NextLinkComposed } from "@/core/components/LinkRouting"; +import { useTranslations } from "next-intl"; import headerProfileItems from "@/core/data/headerProfileItems"; import ProfileOptionLogOut from "./ProfileOptionLogOut"; -export default function ProfileOptions({handleCloseUserMenu}) { +export default function ProfileOptions({ handleCloseUserMenu }) { const t = useTranslations(); return ( @@ -26,7 +26,7 @@ export default function ProfileOptions({handleCloseUserMenu}) { key={profile_item.key} onClick={handleCloseUserMenu} > - + {profile_item.icon} - + {t(profile_item.name)} ))} - + ); } diff --git a/src/components/layouts/Dashboard/Header/index.jsx b/src/components/layouts/Dashboard/Header/index.jsx index 8050806..8d4df35 100644 --- a/src/components/layouts/Dashboard/Header/index.jsx +++ b/src/components/layouts/Dashboard/Header/index.jsx @@ -1,8 +1,8 @@ import MenuIcon from "@mui/icons-material/Menu"; -import {AppBar, Box, Container, IconButton, Stack, Toolbar, useTheme} from "@mui/material"; +import { AppBar, Box, Container, IconButton, Stack, Toolbar, useTheme } from "@mui/material"; import ProfileMenu from "./ProfileMenu"; -function Header({drawerWidth, handleDrawerToggle}) { +function Header({ drawerWidth, handleDrawerToggle }) { const theme = useTheme(); return ( @@ -10,8 +10,8 @@ function Header({drawerWidth, handleDrawerToggle}) { @@ -21,15 +21,15 @@ function Header({drawerWidth, handleDrawerToggle}) { display: "flex", }} > - + - + - + > - - + + diff --git a/src/components/layouts/Dashboard/Sidebar/SidebarDrawer.jsx b/src/components/layouts/Dashboard/Sidebar/SidebarDrawer.jsx index f155dce..29bd7fb 100644 --- a/src/components/layouts/Dashboard/Sidebar/SidebarDrawer.jsx +++ b/src/components/layouts/Dashboard/Sidebar/SidebarDrawer.jsx @@ -1,16 +1,16 @@ -import {Divider, Stack, Toolbar, Typography} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Divider, Stack, Toolbar, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; import SidebarList from "./SidebarList"; import useUser from "@/lib/app/hooks/useUser"; -const SidebarDrawer = ({handleDrawerToggle}) => { - const {user} = useUser() +const SidebarDrawer = ({ handleDrawerToggle }) => { + const { user } = useUser(); const t = useTranslations(); return ( <> - + {t("app_short_name")} @@ -18,8 +18,8 @@ const SidebarDrawer = ({handleDrawerToggle}) => { - - + + ); }; diff --git a/src/components/layouts/Dashboard/Sidebar/SidebarList.jsx b/src/components/layouts/Dashboard/Sidebar/SidebarList.jsx index f21b69a..74913d2 100644 --- a/src/components/layouts/Dashboard/Sidebar/SidebarList.jsx +++ b/src/components/layouts/Dashboard/Sidebar/SidebarList.jsx @@ -1,84 +1,125 @@ -import {Divider, List} from "@mui/material"; -import {Fragment, useEffect, useReducer, useState} from "react"; +import { Divider, List } from "@mui/material"; +import { Fragment, useEffect, useReducer, useState } from "react"; import SidebarListItem from "./SidebarListItem"; import sidebarMenu from "@/core/data/sidebarMenu"; -import {useRouter} from "next/router"; +import { useRouter } from "next/router"; import useUser from "@/lib/app/hooks/useUser"; function reducer(state, action) { switch (action.type) { case "COLLAPSE_MENU": - return state.map((itemsArr) => itemsArr.map((item) => action.key === item.key ? { - ...item, showSubItem: !item.showSubItem - } : item)); + return state.map((itemsArr) => + itemsArr.map((item) => + action.key === item.key + ? { + ...item, + showSubItem: !item.showSubItem, + } + : item + ) + ); case "SELECTED": - return state.map((itemsArr) => itemsArr.map((item) => { - return item.type === "page" ? { - ...item, selected: action.route === item.route, routing: false - } : item.subItem && Array.isArray(item.subItem) ? { - ...item, subItem: item.subItem.map((subitem) => ({ - ...subitem, selected: subitem.route === action.route, routing: false - })), showSubItem: item.subItem.some((subitem) => subitem.selected), - } : item; - })); + return state.map((itemsArr) => + itemsArr.map((item) => { + return item.type === "page" + ? { + ...item, + selected: action.route === item.route, + routing: false, + } + : item.subItem && Array.isArray(item.subItem) + ? { + ...item, + subItem: item.subItem.map((subitem) => ({ + ...subitem, + selected: subitem.route === action.route, + routing: false, + })), + showSubItem: item.subItem.some((subitem) => subitem.selected), + } + : item; + }) + ); case "SELECTING": - return state.map((itemsArr) => itemsArr.map((item) => { - return item.type === "page" ? { - ...item, selected: action.route === item.route, routing: action.route === item.route - } : item.subItem && Array.isArray(item.subItem) ? { - ...item, subItem: item.subItem.map((subitem) => ({ - ...subitem, selected: subitem.route === action.route, routing: subitem.route === action.route - })), showSubItem: item.subItem.some((subitem) => subitem.selected), - } : item; - })); + return state.map((itemsArr) => + itemsArr.map((item) => { + return item.type === "page" + ? { + ...item, + selected: action.route === item.route, + routing: action.route === item.route, + } + : item.subItem && Array.isArray(item.subItem) + ? { + ...item, + subItem: item.subItem.map((subitem) => ({ + ...subitem, + selected: subitem.route === action.route, + routing: subitem.route === action.route, + })), + showSubItem: item.subItem.some((subitem) => subitem.selected), + } + : item; + }) + ); default: throw new Error(); } } -export default function SidebarList({handleDrawerToggle}) { +export default function SidebarList({ handleDrawerToggle }) { const [itemMenu, dispatch] = useReducer(reducer, sidebarMenu); - const {user} = useUser(); + const { user } = useUser(); const router = useRouter(); const [selectedKey, setSelectedKey] = useState(null); useEffect(() => { - dispatch({type: "SELECTED", route: router.pathname}); + dispatch({ type: "SELECTED", route: router.pathname }); setSelectedKey(router.pathname); const handlerStartRoute = (url) => { - dispatch({type: "SELECTING", route: url}); - } + dispatch({ type: "SELECTING", route: url }); + }; - router.events.on('routeChangeStart', handlerStartRoute) + router.events.on("routeChangeStart", handlerStartRoute); return () => { - router.events.off('routeChangeStart', handlerStartRoute) - } + router.events.off("routeChangeStart", handlerStartRoute); + }; }, [router]); - useEffect(() => { - selectedKey && document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({ - behavior: "smooth", block: "center" - }); + selectedKey && + document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({ + behavior: "smooth", + block: "center", + }); }, [selectedKey]); - return ( - {itemMenu.map((itemArr, index) => { - let isDividerVisible = false; - return ( - {itemArr.map((item) => - {(item.permissions.some((permission) => user?.permissions?.includes(permission)) || item.permissions.includes('all')) && <> - - {isDividerVisible = true} - } - )} - {isDividerVisible && } - ) - })} - ); + return ( + + {itemMenu.map((itemArr, index) => { + let isDividerVisible = false; + return ( + + {itemArr.map((item) => ( + + {(item.permissions.some((permission) => user?.permissions?.includes(permission)) || + item.permissions.includes("all")) && ( + <> + + {(isDividerVisible = true)} + + )} + + ))} + {isDividerVisible && } + + ); + })} + + ); } diff --git a/src/components/layouts/Dashboard/Sidebar/SidebarListItem.jsx b/src/components/layouts/Dashboard/Sidebar/SidebarListItem.jsx index fffd570..40a5a38 100644 --- a/src/components/layouts/Dashboard/Sidebar/SidebarListItem.jsx +++ b/src/components/layouts/Dashboard/Sidebar/SidebarListItem.jsx @@ -1,4 +1,4 @@ -import {NextLinkComposed} from "@/core/components/LinkRouting"; +import { NextLinkComposed } from "@/core/components/LinkRouting"; import ExpandLess from "@mui/icons-material/ExpandLess"; import ExpandMore from "@mui/icons-material/ExpandMore"; import { @@ -11,14 +11,14 @@ import { ListItemText, Typography, } from "@mui/material"; -import {useTranslations} from "next-intl"; -import {Fragment} from "react"; +import { useTranslations } from "next-intl"; +import { Fragment } from "react"; import SidebarListSubItem from "./SidebarListSubItem"; import useNotification from "@/lib/app/hooks/useNotification"; -const SidebarListItem = ({item, dispatch, handleDrawerToggle}) => { +const SidebarListItem = ({ item, dispatch, handleDrawerToggle }) => { const t = useTranslations(); - const {notification_count} = useNotification(); + const { notification_count } = useNotification(); const hasSubItems = item.type === "menu" && item.subItem && item.subItem.length > 0; const renderBadge = () => { return !hasSubItems ? ( @@ -49,14 +49,13 @@ const SidebarListItem = ({item, dispatch, handleDrawerToggle}) => { })} onClick={() => { if (hasSubItems) { - dispatch({type: "COLLAPSE_MENU", key: item.key}); + dispatch({ type: "COLLAPSE_MENU", key: item.key }); } - handleDrawerToggle() + handleDrawerToggle(); }} sx={{ minHeight: 48, }} - > { pr: 2, }} > - {item.routing ? - : item.icon} + {item.routing ? : item.icon} { } /> - {hasSubItems && (item.showSubItem ? : )} + {hasSubItems && (item.showSubItem ? : )} - {item.subItem && ( - - )} + {item.subItem && } ); }; diff --git a/src/components/layouts/Dashboard/Sidebar/SidebarListSubItem.jsx b/src/components/layouts/Dashboard/Sidebar/SidebarListSubItem.jsx index 41bff6d..fb16025 100644 --- a/src/components/layouts/Dashboard/Sidebar/SidebarListSubItem.jsx +++ b/src/components/layouts/Dashboard/Sidebar/SidebarListSubItem.jsx @@ -1,4 +1,4 @@ -import {NextLinkComposed} from "@/core/components/LinkRouting"; +import { NextLinkComposed } from "@/core/components/LinkRouting"; import { Badge, CircularProgress, @@ -11,12 +11,12 @@ import { ListItemText, Typography, } from "@mui/material"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import useNotification from "@/lib/app/hooks/useNotification"; -const SidebarListSubItem = ({item, handleDrawerToggle}) => { +const SidebarListSubItem = ({ item, handleDrawerToggle }) => { const t = useTranslations(); - const {notification_count} = useNotification(); + const { notification_count } = useNotification(); const renderBadge = (subitem) => ( { ); return ( - - + {item.subItem.map((subitem) => ( { pathname: subitem.route, }} onClick={() => { - handleDrawerToggle() + handleDrawerToggle(); }} sx={{ minHeight: 48, @@ -59,22 +58,23 @@ const SidebarListSubItem = ({item, handleDrawerToggle}) => { pr: 2, }} > - {subitem.routing ? - : subitem.icon} + {subitem.routing ? : subitem.icon} - - {t(subitem.secondary)} - - ) : null - }/> + + {t(subitem.secondary)} + + ) : null + } + /> ))} - ); }; diff --git a/src/components/layouts/Dashboard/Sidebar/index.jsx b/src/components/layouts/Dashboard/Sidebar/index.jsx index 27f2d0d..1a2c3e2 100644 --- a/src/components/layouts/Dashboard/Sidebar/index.jsx +++ b/src/components/layouts/Dashboard/Sidebar/index.jsx @@ -1,51 +1,53 @@ -import {Box, Drawer, useMediaQuery} from "@mui/material"; +import { Box, Drawer, useMediaQuery } from "@mui/material"; import SidebarDrawer from "./SidebarDrawer"; -import {useTheme} from "@mui/material/styles"; +import { useTheme } from "@mui/material/styles"; const Sidebar = (props) => { const theme = useTheme(); - const isUpSm = useMediaQuery((theme.breakpoints.up('sm'))) + const isUpSm = useMediaQuery(theme.breakpoints.up("sm")); return ( {isUpSm ? ( - - - - ) : ( - - - - )} + > + {" "} + {isUpSm ? ( + + + + ) : ( + + + + )} ); }; diff --git a/src/components/layouts/Dashboard/index.jsx b/src/components/layouts/Dashboard/index.jsx index de85d31..e687f6f 100644 --- a/src/components/layouts/Dashboard/index.jsx +++ b/src/components/layouts/Dashboard/index.jsx @@ -1,5 +1,5 @@ -import {useState} from "react"; -import {Toolbar} from "@mui/material"; +import { useState } from "react"; +import { Toolbar } from "@mui/material"; import FullPageLayout from "@/layouts/FullPageLayout"; import Header from "@/components/layouts/Dashboard/Header"; import Sidebar from "@/components/layouts/Dashboard/Sidebar"; @@ -8,10 +8,9 @@ import Content from "@/components/layouts/Dashboard/Content"; const drawerWidth = 260; const DashboardLayouts = (props) => { - const {window} = props; + const { window } = props; const [mobileOpen, setMobileOpen] = useState(false); - const container = - window !== undefined ? () => window().document.body : undefined; + const container = window !== undefined ? () => window().document.body : undefined; const handleDrawerToggle = () => { setMobileOpen(!mobileOpen); @@ -19,22 +18,16 @@ const DashboardLayouts = (props) => { return ( -
+
- - - + + + ); diff --git a/src/components/layouts/Print/Header/ProfileData.jsx b/src/components/layouts/Print/Header/ProfileData.jsx index 548378b..8691aef 100644 --- a/src/components/layouts/Print/Header/ProfileData.jsx +++ b/src/components/layouts/Print/Header/ProfileData.jsx @@ -1,16 +1,12 @@ -import {Avatar, Stack, Typography} from "@mui/material"; +import { Avatar, Stack, Typography } from "@mui/material"; import useUser from "@/lib/app/hooks/useUser"; export default function ProfileData() { - const {user} = useUser(); + const { user } = useUser(); return ( - - - + + + {user.username} diff --git a/src/components/layouts/Print/Header/ProfileMenu.jsx b/src/components/layouts/Print/Header/ProfileMenu.jsx index 415d501..1f43f46 100644 --- a/src/components/layouts/Print/Header/ProfileMenu.jsx +++ b/src/components/layouts/Print/Header/ProfileMenu.jsx @@ -1,14 +1,14 @@ -import {Avatar, IconButton, Menu, Tooltip} from "@mui/material"; -import {useState} from "react"; +import { Avatar, IconButton, Menu, Tooltip } from "@mui/material"; +import { useState } from "react"; import ProfileData from "./ProfileData"; import ProfileOptions from "./ProfileOptions"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import useUser from "@/lib/app/hooks/useUser"; function ProfileMenu() { const t = useTranslations(); const [anchorElUser, setAnchorElUser] = useState(null); - const {user} = useUser(); + const { user } = useUser(); const handleOpenUserMenu = (event) => { setAnchorElUser(event.currentTarget); @@ -20,7 +20,7 @@ function ProfileMenu() { return ( <> - + - - + + ); diff --git a/src/components/layouts/Print/Header/ProfileOptionLogOut.jsx b/src/components/layouts/Print/Header/ProfileOptionLogOut.jsx index 2a6cf85..3411357 100644 --- a/src/components/layouts/Print/Header/ProfileOptionLogOut.jsx +++ b/src/components/layouts/Print/Header/ProfileOptionLogOut.jsx @@ -1,11 +1,11 @@ -import {Box, Button, MenuItem, Typography} from "@mui/material"; +import { Box, Button, MenuItem, Typography } from "@mui/material"; import MeetingRoomIcon from "@mui/icons-material/MeetingRoom"; import useUser from "@/lib/app/hooks/useUser"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; -export default function ProfileOptionLogOut({handleCloseUserMenu}) { +export default function ProfileOptionLogOut({ handleCloseUserMenu }) { const t = useTranslations(); - const {clearToken} = useUser(); + const { clearToken } = useUser(); const handleClickLogOut = () => { handleCloseUserMenu(); clearToken(); @@ -28,7 +28,7 @@ export default function ProfileOptionLogOut({handleCloseUserMenu}) { }} onClick={handleClickLogOut} > - + - + - + {t("header.logout")} diff --git a/src/components/layouts/Print/Header/ProfileOptions.jsx b/src/components/layouts/Print/Header/ProfileOptions.jsx index 6e7bdba..3f75cc0 100644 --- a/src/components/layouts/Print/Header/ProfileOptions.jsx +++ b/src/components/layouts/Print/Header/ProfileOptions.jsx @@ -1,10 +1,10 @@ -import {Box, MenuItem, Typography} from "@mui/material"; -import {NextLinkComposed} from "@/core/components/LinkRouting"; -import {useTranslations} from "next-intl"; +import { Box, MenuItem, Typography } from "@mui/material"; +import { NextLinkComposed } from "@/core/components/LinkRouting"; +import { useTranslations } from "next-intl"; import headerProfileItems from "@/core/data/headerProfileItems"; import ProfileOptionLogOut from "./ProfileOptionLogOut"; -export default function ProfileOptions({handleCloseUserMenu}) { +export default function ProfileOptions({ handleCloseUserMenu }) { const t = useTranslations(); return ( @@ -26,7 +26,7 @@ export default function ProfileOptions({handleCloseUserMenu}) { key={profile_item.key} onClick={handleCloseUserMenu} > - + {profile_item.icon} - + {t(profile_item.name)} ))} - + ); } diff --git a/src/components/layouts/Print/Header/index.jsx b/src/components/layouts/Print/Header/index.jsx index 7c0d990..38116a9 100644 --- a/src/components/layouts/Print/Header/index.jsx +++ b/src/components/layouts/Print/Header/index.jsx @@ -1,22 +1,22 @@ -import {AppBar, Button, Container, Stack, Toolbar, Typography, useTheme} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useRouter} from "next/router"; -import {useState} from "react"; +import { AppBar, Button, Container, Stack, Toolbar, Typography, useTheme } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useRouter } from "next/router"; +import { useState } from "react"; import usePrint from "@/lib/app/hooks/usePrint"; -function Header({drawerWidth, handleDrawerToggle}) { +function Header({ drawerWidth, handleDrawerToggle }) { const theme = useTheme(); - const t = useTranslations() - const router = useRouter() - const {printDetails} = usePrint() - const [disabled, setDisabled] = useState(false) + const t = useTranslations(); + const router = useRouter(); + const { printDetails } = usePrint(); + const [disabled, setDisabled] = useState(false); return ( @@ -34,18 +34,23 @@ function Header({drawerWidth, handleDrawerToggle}) { ...theme.mixins.toolbar, }} > - + {printDetails.title} - {'تعداد صفحه:'} {printDetails.count} + + {"تعداد صفحه:"} {printDetails.count} + - - + + @@ -69,4 +82,4 @@ function Header({drawerWidth, handleDrawerToggle}) { ); } -export default Header; \ No newline at end of file +export default Header; diff --git a/src/components/layouts/Print/index.jsx b/src/components/layouts/Print/index.jsx index afa6585..c599a3a 100644 --- a/src/components/layouts/Print/index.jsx +++ b/src/components/layouts/Print/index.jsx @@ -1,14 +1,14 @@ import Header from "@/components/layouts/Print/Header"; -import {Toolbar} from "@mui/material"; +import { Toolbar } from "@mui/material"; const Print = (props) => { return ( <> -
- +
+ {props.children} - ) -} + ); +}; -export default Print \ No newline at end of file +export default Print; diff --git a/src/components/login-expert/index.jsx b/src/components/login-expert/index.jsx index 23185df..8dc8efa 100644 --- a/src/components/login-expert/index.jsx +++ b/src/components/login-expert/index.jsx @@ -1,14 +1,14 @@ import LinkRouting from "@/core/components/LinkRouting"; import StyledForm from "@/core/components/StyledForm"; -import {GET_USER_TOKEN} from "@/core/data/apiRoutes"; +import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useUser from "@/lib/app/hooks/useUser"; import LoginIcon from "@mui/icons-material/Login"; -import {Box, Button, Container, Paper, Stack, TextField, Typography,} from "@mui/material"; -import {Field, Formik} from "formik"; -import {useTranslations} from "next-intl"; -import {useSearchParams} from "next/navigation"; +import { Box, Button, Container, Paper, Stack, TextField, Typography } from "@mui/material"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import { useSearchParams } from "next/navigation"; import * as Yup from "yup"; import useDirection from "@/lib/app/hooks/useDirection"; import SvgLogin from "@/core/components/svgs/SvgLogin"; @@ -17,9 +17,9 @@ import PasswordField from "@/core/components/PasswordField"; const LoginComponent = () => { const t = useTranslations(); - const {directionApp} = useDirection(); // should delete because we don't have direction anymore - const {setToken} = useUser(); // pass token to set token - const requestServer = useRequest() + const { directionApp } = useDirection(); // should delete because we don't have direction anymore + const { setToken } = useUser(); // pass token to set token + const requestServer = useRequest(); // getting url query const searchParams = useSearchParams(); @@ -27,19 +27,21 @@ const LoginComponent = () => { //formik properties const handleSubmit = (values, props) => { - requestServer(GET_USER_TOKEN, 'post', { + requestServer(GET_USER_TOKEN, "post", { data: { username: values.username, password: values.password, }, success: { - notification: {show: false} - } - }).then((response) => { - setToken(response.data.token) - }).catch(() => { - props.setSubmitting(false) + notification: { show: false }, + }, }) + .then((response) => { + setToken(response.data.token); + }) + .catch(() => { + props.setSubmitting(false); + }); }; const initialValues = { username: "", @@ -51,7 +53,7 @@ const LoginComponent = () => { }); return ( - + @@ -61,51 +63,32 @@ const LoginComponent = () => { validationSchema={validationSchema} > {(props) => ( - - - + + + {t("login_expert")} - - + + { variant="contained" fullWidth size="medium" - endIcon={} + endIcon={} disabled={props.isSubmitting || !props.dirty || !props.isValid} > {t("LoginPage.button_submit")} @@ -135,10 +118,8 @@ const LoginComponent = () => { {t("LoginPage.link_routing_back_to")}{" "} {backUrlDecodedPath diff --git a/src/core/components/AvatarUpload.jsx b/src/core/components/AvatarUpload.jsx index 03a9cba..3cffd0d 100644 --- a/src/core/components/AvatarUpload.jsx +++ b/src/core/components/AvatarUpload.jsx @@ -1,9 +1,9 @@ -import {Avatar, Box, TextField} from "@mui/material"; -import {useState} from "react"; +import { Avatar, Box, TextField } from "@mui/material"; +import { useState } from "react"; import DeleteIcon from "@mui/icons-material/Delete"; import AddIcon from "@mui/icons-material/Add"; -const AvatarUpload = ({user, setFieldValue, valueAvatar, changeFlag}) => { +const AvatarUpload = ({ user, setFieldValue, valueAvatar, changeFlag }) => { const [selectedImage, setSelectedImage] = useState(user.expert_avatar); const [isHovered, setIsHovered] = useState(false); @@ -118,7 +118,7 @@ const AvatarUpload = ({user, setFieldValue, valueAvatar, changeFlag}) => { id="avatar-upload" type="file" accept="image/*" - sx={{display: "none"}} + sx={{ display: "none" }} onChange={handleImageChange} /> diff --git a/src/core/components/Chart.jsx b/src/core/components/Chart.jsx index 31ae246..2faf935 100644 --- a/src/core/components/Chart.jsx +++ b/src/core/components/Chart.jsx @@ -1,15 +1,15 @@ import dynamic from "next/dynamic"; import useLanguage from "@/lib/app/hooks/useLanguage"; -import ReactDOMServer from 'react-dom/server'; -import WidgetsIcon from '@mui/icons-material/Widgets'; +import ReactDOMServer from "react-dom/server"; +import WidgetsIcon from "@mui/icons-material/Widgets"; -const widgetIconSvgString = ReactDOMServer.renderToString(); +const widgetIconSvgString = ReactDOMServer.renderToString(); -const ApexChart = dynamic(() => import("react-apexcharts"), {ssr: false}); +const ApexChart = dynamic(() => import("react-apexcharts"), { ssr: false }); -const Chart = ({chartId, type, series, specialOption}) => { - const {languageApp, languageList} = useLanguage(); - const chartLang = languageList.find((item) => item.key == languageApp).chartLocalization +const Chart = ({ chartId, type, series, specialOption }) => { + const { languageApp, languageList } = useLanguage(); + const chartLang = languageList.find((item) => item.key == languageApp).chartLocalization; const options = { chart: { id: chartId, @@ -22,12 +22,12 @@ const Chart = ({chartId, type, series, specialOption}) => { zoomIn: false, zoomOut: false, download: widgetIconSvgString, - } - } + }, + }, }, - ...(specialOption ? specialOption : {}) - } - return + ...(specialOption ? specialOption : {}), + }; + return ; }; -export default Chart; +export default Chart; diff --git a/src/core/components/Config.jsx b/src/core/components/Config.jsx index adbbefe..0c4910f 100644 --- a/src/core/components/Config.jsx +++ b/src/core/components/Config.jsx @@ -1,35 +1,35 @@ -import {useEffect, useState} from "react"; +import { useEffect, useState } from "react"; import axios from "axios"; -import {GET_CONFIG} from "@/core/data/apiRoutes"; -import {ConfigProvider} from "@/lib/app/contexts/config"; -import {isValidJson} from "@/core/utils/isValidJson"; -import {useRouter} from "next/router"; +import { GET_CONFIG } from "@/core/data/apiRoutes"; +import { ConfigProvider } from "@/lib/app/contexts/config"; +import { isValidJson } from "@/core/utils/isValidJson"; +import { useRouter } from "next/router"; -const ConfigApp = ({children}) => { - const router = useRouter() - const [error, setError] = useState(false) - const [config, setConfig] = useState() +const ConfigApp = ({ children }) => { + const router = useRouter(); + const [error, setError] = useState(false); + const [config, setConfig] = useState(); useEffect(() => { const fetchConfig = async () => { try { - const response = await axios(GET_CONFIG) - let _config = {} - response.data.data.forEach(item => { - _config[item.name] = isValidJson(item.value) ? JSON.parse(item.value) : item.value - }) - setConfig(_config) + const response = await axios(GET_CONFIG); + let _config = {}; + response.data.data.forEach((item) => { + _config[item.name] = isValidJson(item.value) ? JSON.parse(item.value) : item.value; + }); + setConfig(_config); } catch (error) { - setError(true) + setError(true); } - } - - fetchConfig() + }; + fetchConfig(); }, [router]); return ( - {error ? <>Error request config : config && children}) -} + {error ? <>Error request config : config && children} + ); +}; -export default ConfigApp \ No newline at end of file +export default ConfigApp; diff --git a/src/core/components/CustomAccordion.jsx b/src/core/components/CustomAccordion.jsx index de0c646..813ac86 100644 --- a/src/core/components/CustomAccordion.jsx +++ b/src/core/components/CustomAccordion.jsx @@ -7,59 +7,63 @@ import { ButtonGroup, CircularProgress, Grid, - Typography + Typography, } from "@mui/material"; -import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; -import VerifiedIcon from '@mui/icons-material/Verified'; +import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; +import VerifiedIcon from "@mui/icons-material/Verified"; import Check from "@mui/icons-material/Check"; import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined"; -import {useState} from "react"; +import { useState } from "react"; const CustomAccordion = ({ - title, - hasOpened, - hasAccordionOpened, - handleAccordionChange, - accordionIndex, - downloadFile - }) => { - const [downloadStatus, setDownloadStatus] = useState('initial'); + title, + hasOpened, + hasAccordionOpened, + handleAccordionChange, + accordionIndex, + downloadFile, +}) => { + const [downloadStatus, setDownloadStatus] = useState("initial"); const handleDownloadClick = (setStatus, url) => { - setStatus('downloading'); - window.open(url, '_blank'); + setStatus("downloading"); + window.open(url, "_blank"); setTimeout(() => { - setStatus('completed'); + setStatus("completed"); setTimeout(() => { - setStatus('initial'); + setStatus("initial"); }, 1200); }, 1000); }; return ( - handleAccordionChange(accordionIndex)} - sx={{ - mb: 2, - boxShadow: 1, - backgroundColor: "#f7f7f7" - }}> - }> - - - {title} - {hasAccordionOpened && } + handleAccordionChange(accordionIndex)} + sx={{ + mb: 2, + boxShadow: 1, + backgroundColor: "#f7f7f7", + }} + > + }> + + + {title} + {hasAccordionOpened && } - + @@ -68,6 +72,6 @@ const CustomAccordion = ({ ); -} +}; export default CustomAccordion; diff --git a/src/core/components/DataTable.jsx b/src/core/components/DataTable.jsx index e56d147..1dd7ef4 100644 --- a/src/core/components/DataTable.jsx +++ b/src/core/components/DataTable.jsx @@ -1,23 +1,25 @@ -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; import useLanguage from "@/lib/app/hooks/useLanguage"; -import {useEffect, useMemo, useState} from "react"; +import { useEffect, useMemo, useState } from "react"; import moment from "moment-jalaali"; import useSWR from "swr"; -import {IconButton, Tooltip, Typography} from "@mui/material"; +import { IconButton, Tooltip, Typography } from "@mui/material"; import MaterialReactTable from "material-react-table"; import useRequest from "@/lib/app/hooks/useRequest"; -import RefreshIcon from '@mui/icons-material/Refresh'; +import RefreshIcon from "@mui/icons-material/Refresh"; function DataTable(props) { - const requestServer = useRequest({auth: true}) + const requestServer = useRequest({ auth: true }); const t = useTranslations(); - const {languageApp, languageList} = useLanguage(); + const { languageApp, languageList } = useLanguage(); const [columnFilters, setColumnFilters] = useState([]); const [sorting, setSorting] = useState(props.sorting || []); - const [pagination, setPagination] = useState({pageIndex: 0, pageSize: 10}); + const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 }); const [columnFilterFns, setColumnFilterFns] = useState(() => { let output = {}; - const list = props.columns.map((item) => item.enableColumnFilter ? {[item.id]: item.filterFn} : {[item.id]: ""}); + const list = props.columns.map((item) => + item.enableColumnFilter ? { [item.id]: item.filterFn } : { [item.id]: "" } + ); for (var key in list) { var nestedObj = list[key]; for (var nestedKey in nestedObj) { @@ -27,18 +29,16 @@ function DataTable(props) { return output; }); - const [updateTime, setUpdateTime] = useState( - moment().format("HH:mm | jYYYY/jMM/jDD") - ); + const [updateTime, setUpdateTime] = useState(moment().format("HH:mm | jYYYY/jMM/jDD")); - const tableLocalization = useMemo(() => languageList.find((item) => item.key == languageApp).tableLocalization, [languageApp, languageList]); + const tableLocalization = useMemo( + () => languageList.find((item) => item.key == languageApp).tableLocalization, + [languageApp, languageList] + ); const fetchUrl = useMemo(() => { const params = new URLSearchParams(); - params.set( - "start", - `${pagination.pageIndex * pagination.pageSize}` - ); + params.set("start", `${pagination.pageIndex * pagination.pageSize}`); const filters = columnFilters.map((filter) => { let datatype; for (const i in props.columns) { @@ -47,108 +47,125 @@ function DataTable(props) { } } return { - ...filter, fn: columnFilterFns[filter.id], datatype: datatype, + ...filter, + fn: columnFilterFns[filter.id], + datatype: datatype, }; }); params.set("size", pagination.pageSize); params.set("filters", JSON.stringify(filters ?? [])); params.set("sorting", JSON.stringify(sorting ?? [])); return `${props.tableUrl}?${params}`; - }, [props.tableUrl, columnFilters, columnFilterFns, pagination, sorting, props.columns,]); + }, [props.tableUrl, columnFilters, columnFilterFns, pagination, sorting, props.columns]); - const {data, isValidating, mutate} = useSWR(fetchUrl, (...args) => - requestServer(args, 'get', { + const { data, isValidating, mutate } = useSWR( + fetchUrl, + (...args) => + requestServer(args, "get", { pending: false, - success: {notification: {show: false}} - }).then((response) => response.data).catch(() => { + success: { notification: { show: false } }, }) - , { + .then((response) => response.data) + .catch(() => {}), + { revalidateIfStale: true, revalidateOnFocus: false, revalidateOnReconnect: true, - keepPreviousData: true - }); + keepPreviousData: true, + } + ); useEffect(() => { setUpdateTime(moment().format("HH:mm | jYYYY/jMM/jDD")); }, [isValidating, languageApp]); - return ( (<> - {props.enableCustomToolbar /* send condition */ ? - /* send component */ : } - - mutate()}> - - - - )} - renderBottomToolbarCustomActions={({table}) => (<> - {props.enableLastUpdate /* send condition */ ? ( - {t("last_updated_at")}: {updateTime} - ) : ("")} - )} - state={{ - showProgressBars: isValidating, - columnFilters, - columnFilterFns, - pagination, - sorting, - }} - positionActionsColumn={"last"} - enableRowActions={props.enableRowActions} - renderRowActions={({row}) => } - {...props} - />); + borderLeft: "1px solid #e1e1e1", + "&:first-of-type": { + borderLeft: "unset", + }, + "& .Mui-TableHeadCell-Content": { justifyContent: "space-between" }, + }, + }} + muiTableBodyCellProps={{ + sx: { + borderLeft: "1px solid #e1e1e1", + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }} + enableColumnFilterModes + muiTablePaperProps={{ elevation: 0 }} + rowCount={data?.meta?.totalRowCount ?? 0} + onColumnFilterFnsChange={setColumnFilterFns} + onColumnFiltersChange={setColumnFilters} + onPaginationChange={setPagination} + onSortingChange={setSorting} + positionToolbarAlertBanner="bottom" + renderTopToolbarCustomActions={({ table }) => ( + <> + {props.enableCustomToolbar /* send condition */ ? ( + /* send component */ + ) : ( + + )} + + mutate()}> + + + + + )} + renderBottomToolbarCustomActions={({ table }) => ( + <> + {props.enableLastUpdate /* send condition */ ? ( + + {t("last_updated_at")}: {updateTime} + + ) : ( + "" + )} + + )} + state={{ + showProgressBars: isValidating, + columnFilters, + columnFilterFns, + pagination, + sorting, + }} + positionActionsColumn={"last"} + enableRowActions={props.enableRowActions} + renderRowActions={({ row }) => } + {...props} + /> + ); } -export default DataTable; \ No newline at end of file +export default DataTable; diff --git a/src/core/components/DownloadSection.jsx b/src/core/components/DownloadSection.jsx index fc20d9c..2344798 100644 --- a/src/core/components/DownloadSection.jsx +++ b/src/core/components/DownloadSection.jsx @@ -1,34 +1,34 @@ -import FileDownloadOutlinedIcon from '@mui/icons-material/FileDownloadOutlined'; -import Check from '@mui/icons-material/Check'; -import {CircularProgress} from "@mui/material" +import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined"; +import Check from "@mui/icons-material/Check"; +import { CircularProgress } from "@mui/material"; const DownloadSection = ({ downloadStatus, onDownloadClick }) => { return (
- {downloadStatus === 'completed' ? ( + {downloadStatus === "completed" ? ( <> - + - ) : downloadStatus === 'downloading' ? ( + ) : downloadStatus === "downloading" ? ( ) : ( <> - + )}
diff --git a/src/core/components/GlobalHead.jsx b/src/core/components/GlobalHead.jsx index 5d6186d..d16539c 100644 --- a/src/core/components/GlobalHead.jsx +++ b/src/core/components/GlobalHead.jsx @@ -3,56 +3,29 @@ import Head from "next/head"; const GlobalHead = () => { return ( - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - ) -} + ); +}; -export default GlobalHead \ No newline at end of file +export default GlobalHead; diff --git a/src/core/components/ImageContent.jsx b/src/core/components/ImageContent.jsx index bf96a4b..8e325b5 100644 --- a/src/core/components/ImageContent.jsx +++ b/src/core/components/ImageContent.jsx @@ -1,52 +1,66 @@ -import {Box, Skeleton, Stack} from "@mui/material"; -import {useEffect} from "react"; +import { Box, Skeleton, Stack } from "@mui/material"; +import { useEffect } from "react"; const ImageContent = (prop) => { - useEffect(() => { const timer = setTimeout(() => { prop.setIsSkeleton(false); }, 1500); return () => clearTimeout(timer); }, [prop.isSkeleton]); - const isPDF = prop.imageLink && prop.imageLink.file && prop.imageLink.file.endsWith('.pdf'); + const isPDF = prop.imageLink && prop.imageLink.file && prop.imageLink.file.endsWith(".pdf"); return ( <> - + {prop.isSkeleton && ( - - + + )} {isPDF ? ( - + ) : ( - prop.imageLink && prop.imageLink.file && ( - - + prop.imageLink && + prop.imageLink.file && ( + + ) )} - ) - -} -export default ImageContent; \ No newline at end of file + ); +}; +export default ImageContent; diff --git a/src/core/components/ImageConvertor.jsx b/src/core/components/ImageConvertor.jsx index 9f99bc1..42b38a8 100644 --- a/src/core/components/ImageConvertor.jsx +++ b/src/core/components/ImageConvertor.jsx @@ -12,9 +12,7 @@ const ImageResizer = async (image) => { const resize = await imageResize.resize(get).then(); const output = await imageResize.output(resize).then(); - const avatar = await (await import("image-to-file-converter")) - .base64ToFile(output) - .then(); + const avatar = await (await import("image-to-file-converter")).base64ToFile(output).then(); return avatar; }; diff --git a/src/core/components/LinkRouting.jsx b/src/core/components/LinkRouting.jsx index f8fac0a..e72ea7b 100644 --- a/src/core/components/LinkRouting.jsx +++ b/src/core/components/LinkRouting.jsx @@ -1,28 +1,15 @@ import MuiLink from "@mui/material/Link"; -import {styled} from "@mui/material/styles"; +import { styled } from "@mui/material/styles"; import clsx from "clsx"; import NextLink from "next/link"; -import {useRouter} from "next/router"; +import { useRouter } from "next/router"; import * as React from "react"; // Add support for the sx prop for consistency with the other branches. const Anchor = styled("a")({}); -export const NextLinkComposed = React.forwardRef(function NextLinkComposed( - props, - ref -) { - const { - to, - linkAs, - replace, - scroll, - shallow, - prefetch, - legacyBehavior = true, - locale, - ...other - } = props; +export const NextLinkComposed = React.forwardRef(function NextLinkComposed(props, ref) { + const { to, linkAs, replace, scroll, shallow, prefetch, legacyBehavior = true, locale, ...other } = props; return ( - ); + return ; } - return ( - - ); + return ; }); export default LinkRouting; diff --git a/src/core/components/LoadingHardPage.jsx b/src/core/components/LoadingHardPage.jsx index 59e4a02..6f4a1ed 100644 --- a/src/core/components/LoadingHardPage.jsx +++ b/src/core/components/LoadingHardPage.jsx @@ -1,4 +1,4 @@ -import {Backdrop, Box, Stack, styled, Typography} from "@mui/material"; +import { Backdrop, Box, Stack, styled, Typography } from "@mui/material"; import SvgLoading from "@/core/components/svgs/SvgLoading"; const LoadingImage = styled(Box)({ @@ -19,28 +19,21 @@ const LoadingImage = styled(Box)({ animation: "load 2s infinite", }); -const LoadingHardPage = ({children, loading, sx = {}, icon = null, width = 200, height = 200, label = ''}) => { +const LoadingHardPage = ({ children, loading, sx = {}, icon = null, width = 200, height = 200, label = "" }) => { return ( <> - theme.zIndex.drawer + 1, ...sx}} - open={loading} - > - - + theme.zIndex.drawer + 1, ...sx }} open={loading}> + + {icon ? ( - - {icon} - + {icon} ) : ( - + )} - {label} + + {label} + {children} diff --git a/src/core/components/LtrTextField.jsx b/src/core/components/LtrTextField.jsx index aa9efcb..4c32c62 100644 --- a/src/core/components/LtrTextField.jsx +++ b/src/core/components/LtrTextField.jsx @@ -1,4 +1,4 @@ -import {styled, TextField} from "@mui/material"; +import { styled, TextField } from "@mui/material"; const LtrTextField = styled(TextField)` .MuiInputBase-input { @@ -8,4 +8,4 @@ const LtrTextField = styled(TextField)` } `; -export default LtrTextField \ No newline at end of file +export default LtrTextField; diff --git a/src/core/components/Messages.jsx b/src/core/components/Messages.jsx index 8a5cfc9..1877846 100644 --- a/src/core/components/Messages.jsx +++ b/src/core/components/Messages.jsx @@ -2,12 +2,11 @@ import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import SvgLoading from "@/core/components/svgs/SvgLoading"; -const Message = ({text, actions}) => { +const Message = ({ text, actions }) => { return ( - + - + {text} {actions} diff --git a/src/core/components/Middleware/RolePermissionComponent.jsx b/src/core/components/Middleware/RolePermissionComponent.jsx index a445008..99f97ef 100644 --- a/src/core/components/Middleware/RolePermissionComponent.jsx +++ b/src/core/components/Middleware/RolePermissionComponent.jsx @@ -1,6 +1,6 @@ import { Button, Typography } from "@mui/material"; -import {useTranslations} from "next-intl"; -import {NextLinkComposed} from "@/core/components/LinkRouting"; +import { useTranslations } from "next-intl"; +import { NextLinkComposed } from "@/core/components/LinkRouting"; import Message from "@/core/components/Messages"; const RolePermissionComponent = () => { @@ -9,9 +9,7 @@ const RolePermissionComponent = () => { return ( - {t("Permission.typography_you_dont_have_access")} - + {t("Permission.typography_you_dont_have_access")} } actions={ <> diff --git a/src/core/components/Middleware/WithAuthComponent.jsx b/src/core/components/Middleware/WithAuthComponent.jsx index 9a6ff5d..83ea4ed 100644 --- a/src/core/components/Middleware/WithAuthComponent.jsx +++ b/src/core/components/Middleware/WithAuthComponent.jsx @@ -2,7 +2,7 @@ import { Button, Typography } from "@mui/material"; import { useRouter } from "next/router"; import Message from "@/core/components/Messages"; import { NextLinkComposed } from "@/core/components/LinkRouting"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; const WithAuthComponent = () => { const router = useRouter(); @@ -22,7 +22,7 @@ const WithAuthComponent = () => { component={NextLinkComposed} to={{ pathname: "/login-expert", - query: {back_url: encodeURIComponent(router.asPath)}, + query: { back_url: encodeURIComponent(router.asPath) }, }} > {t("login")} diff --git a/src/core/components/Middleware/WithoutAuthComponent.jsx b/src/core/components/Middleware/WithoutAuthComponent.jsx index 59b7cbf..a10b7e2 100644 --- a/src/core/components/Middleware/WithoutAuthComponent.jsx +++ b/src/core/components/Middleware/WithoutAuthComponent.jsx @@ -1,6 +1,6 @@ -import {Stack, Typography} from "@mui/material"; +import { Stack, Typography } from "@mui/material"; import Message from "@/core/components/Messages"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; const WithoutAuthComponent = ({ backUrlDecodedPath }) => { const t = useTranslations(); diff --git a/src/core/components/MuiDatePicker.jsx b/src/core/components/MuiDatePicker.jsx index 18be3cc..5825a7f 100644 --- a/src/core/components/MuiDatePicker.jsx +++ b/src/core/components/MuiDatePicker.jsx @@ -1,46 +1,37 @@ -import {LocalizationProvider, MobileDateTimePicker} from "@mui/x-date-pickers"; -import {AdapterDateFnsJalali} from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import { LocalizationProvider, MobileDateTimePicker } from "@mui/x-date-pickers"; +import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali"; import moment from "jalali-moment"; -import {faIR} from "@mui/x-date-pickers/locales"; -import {Box, IconButton} from "@mui/material"; +import { faIR } from "@mui/x-date-pickers/locales"; +import { Box, IconButton } from "@mui/material"; import ClearIcon from "@mui/icons-material/Clear"; -import {useTranslations} from "next-intl"; +import { useTranslations } from "next-intl"; -export default function MuiDatePicker({column}) { +export default function MuiDatePicker({ column }) { const t = useTranslations(); const filterFnValue = column.columnDef._filterFn; return ( - + { const date = new Date(newValue); - const formattedDate = moment(date) - .locale("en") - .format("YYYY-MM-DD HH:mm"); + const formattedDate = moment(date).locale("en").format("YYYY-MM-DD HH:mm"); column.setFilterValue(formattedDate); }} slotProps={{ textField: { placeholder: "تاریخ خود را وارد کنید", helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, - sx: {minWidth: "120px"}, + sx: { minWidth: "120px" }, variant: "standard", }, }} - value={ - column.getFilterValue() - ? new Date(column.getFilterValue()) - : null - } + value={column.getFilterValue() ? new Date(column.getFilterValue()) : null} /> - + ); diff --git a/src/core/components/NetworkComponent.jsx b/src/core/components/NetworkComponent.jsx index 9610b1c..2803acc 100644 --- a/src/core/components/NetworkComponent.jsx +++ b/src/core/components/NetworkComponent.jsx @@ -1,35 +1,38 @@ import useNetwork from "@/lib/app/hooks/useNetwork"; -import {useEffect, useRef} from "react"; -import {toast} from "react-toastify"; -import WifiIcon from '@mui/icons-material/Wifi'; -import WifiOffIcon from '@mui/icons-material/WifiOff'; -import {useTranslations} from "next-intl"; +import { useEffect, useRef } from "react"; +import { toast } from "react-toastify"; +import WifiIcon from "@mui/icons-material/Wifi"; +import WifiOffIcon from "@mui/icons-material/WifiOff"; +import { useTranslations } from "next-intl"; const NetworkComponent = () => { const networkToastId = useRef(null); - const network = useNetwork() - const t = useTranslations() + const network = useNetwork(); + const t = useTranslations(); useEffect(() => { if (network.online) { toast.update(networkToastId.current, { type: toast.TYPE.SUCCESS, - render: t('online_message'), + render: t("online_message"), autoClose: 2000, closeButton: true, closeOnClick: true, - icon: + icon: , }); - return + return; } - networkToastId.current = toast.warn(t('offline_message'), { - containerId: 'connection', + networkToastId.current = toast.warn(t("offline_message"), { + containerId: "connection", draggable: false, - autoClose: false, closeButton: false, closeOnClick: false, icon: - }) + autoClose: false, + closeButton: false, + closeOnClick: false, + icon: , + }); }, [network.online]); - return '' -} + return ""; +}; -export default NetworkComponent \ No newline at end of file +export default NetworkComponent; diff --git a/src/core/components/NoSsrHandler.jsx b/src/core/components/NoSsrHandler.jsx index 5a4c4e1..88fee1e 100644 --- a/src/core/components/NoSsrHandler.jsx +++ b/src/core/components/NoSsrHandler.jsx @@ -1,6 +1,6 @@ -import {NoSsr} from "@mui/material"; +import { NoSsr } from "@mui/material"; -const NoSsrHandler = ({isBot, children}) => { +const NoSsrHandler = ({ isBot, children }) => { if (isBot) return children; return {children}; }; diff --git a/src/core/components/NumberShowBox.jsx b/src/core/components/NumberShowBox.jsx index 264a7f4..db30b44 100644 --- a/src/core/components/NumberShowBox.jsx +++ b/src/core/components/NumberShowBox.jsx @@ -1,19 +1,15 @@ -import {Box, Typography} from "@mui/material"; +import { Box, Typography } from "@mui/material"; -const NumberShowBox = ({showNumber, headerTitle, unitTitle}) => { +const NumberShowBox = ({ showNumber, headerTitle, unitTitle }) => { return ( <> - - {headerTitle} + + {headerTitle} - {isNaN(showNumber) || showNumber === null - ? "0" - : (showNumber).toLocaleString()}{" "} - {unitTitle} + {isNaN(showNumber) || showNumber === null ? "0" : showNumber.toLocaleString()} {unitTitle} ); }; -export default NumberShowBox \ No newline at end of file +export default NumberShowBox; diff --git a/src/core/components/PasswordField/index.jsx b/src/core/components/PasswordField/index.jsx index d109b73..9aa4197 100644 --- a/src/core/components/PasswordField/index.jsx +++ b/src/core/components/PasswordField/index.jsx @@ -1,7 +1,7 @@ -import {useState} from "react"; -import {IconButton, InputAdornment, TextField} from "@mui/material"; -import {Visibility, VisibilityOff} from "@mui/icons-material"; -import {Field} from "formik"; +import { useState } from "react"; +import { IconButton, InputAdornment, TextField } from "@mui/material"; +import { Visibility, VisibilityOff } from "@mui/icons-material"; +import { Field } from "formik"; const PasswordField = (props) => { const [showPassword, setShowPassword] = useState(false); @@ -21,7 +21,7 @@ const PasswordField = (props) => { endAdornment: ( - {showPassword ? : } + {showPassword ? : } ), diff --git a/src/core/components/PriceField.jsx b/src/core/components/PriceField.jsx index 1df1ba2..75c5bb0 100644 --- a/src/core/components/PriceField.jsx +++ b/src/core/components/PriceField.jsx @@ -1,5 +1,5 @@ -import {Stack, Typography} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { Stack, Typography } from "@mui/material"; +import { useTranslations } from "next-intl"; import LtrTextField from "@/core/components/LtrTextField"; const PriceField = (props) => { @@ -7,18 +7,17 @@ const PriceField = (props) => { return ( - + - - {((props.value) / 10).toLocaleString()} + + {props.value > 9999 ? (props.value / 10000).toLocaleString() :(props.value / 10).toLocaleString()} - {t("ConfirmDialog.toman")} + {props.value > 9999 ? t("ConfirmDialog.milyard_toman"): t("ConfirmDialog.toman")} - ) -} -export default PriceField \ No newline at end of file + + ); +}; +export default PriceField; diff --git a/src/core/components/PrintablePage.jsx b/src/core/components/PrintablePage.jsx index 362cc4e..4788083 100644 --- a/src/core/components/PrintablePage.jsx +++ b/src/core/components/PrintablePage.jsx @@ -1,74 +1,132 @@ -import {Box, Container, Divider, Grid, Paper, Stack, Typography} from '@mui/material'; +import { Box, Container, Divider, Grid, Paper, Stack, Typography } from "@mui/material"; -const PrintablePage = ({children, header, footer, paperSx = {}, landscape = false}) => (<> - +const PrintablePage = ({ children, header, footer, paperSx = {}, landscape = false }) => ( + <> + - + component="article" + maxWidth="false" + > + - - + + - - باسمه تعالی - جمهوری اسلامی ایران - وزارت راه و - شهرسازی - سازمان - راهداری و حمل و نقل جاده - ای + + باسمه تعالی + جمهوری اسلامی ایران + وزارت راه و شهرسازی + + سازمان راهداری و حمل و نقل جاده ای + - شماره: - تاریخ: - پیوست: + شماره: + تاریخ: + پیوست: - + {children} - - - - - آدرس: تهران-بلوار - کشاورز-خیابان فلسطین جنوبی-خیابان - دمشق-پلاک17 - تلفن: 88-88804379 - تلفن گویا: 88804400 - کدپستی: 1416753941 + + + + + + {" "} + آدرس: تهران-بلوار کشاورز-خیابان فلسطین جنوبی-خیابان دمشق-پلاک17{" "} + + + {" "} + تلفن: 88-88804379{" "} + + + {" "} + تلفن گویا: 88804400{" "} + + + {" "} + کدپستی: 1416753941{" "} + - - صندوق پستی: 3773-14155 - پست الکترونیک: info@rmto.ir - سایت الکترونیک: www.rmto.ir + + + صندوق پستی: 3773-14155 + + + پست الکترونیک: info@rmto.ir + + + سایت الکترونیک: www.rmto.ir + - - ); + + +); -export default PrintablePage; \ No newline at end of file +export default PrintablePage; diff --git a/src/core/components/SelectBox.jsx b/src/core/components/SelectBox.jsx index 6fc787c..7e84e0d 100644 --- a/src/core/components/SelectBox.jsx +++ b/src/core/components/SelectBox.jsx @@ -1,31 +1,25 @@ -import {FormControl, FormHelperText, InputLabel, MenuItem, Select,} from "@mui/material"; -import {useTranslations} from "next-intl"; +import { FormControl, FormHelperText, InputLabel, MenuItem, Select } from "@mui/material"; +import { useTranslations } from "next-intl"; function SelectBox({ - select, - name, - selectors, - label, - handleChange, - error, - onBlur, - schema, - disabled, - helperText, - isLoading, - errorEcured, - variant = "outlined" - }) { + select, + name, + selectors, + label, + handleChange, + error, + onBlur, + schema, + disabled, + helperText, + isLoading, + errorEcured, + variant = "outlined", +}) { const t = useTranslations(); return ( - + {label} diff --git a/src/core/components/notifications/ErrorNotification.jsx b/src/core/components/notifications/ErrorNotification.jsx index 776c904..2434264 100644 --- a/src/core/components/notifications/ErrorNotification.jsx +++ b/src/core/components/notifications/ErrorNotification.jsx @@ -1,6 +1,6 @@ import DangerousIcon from "@mui/icons-material/Dangerous"; -import {Box, Typography} from "@mui/material"; -import {toast} from "react-toastify"; +import { Box, Typography } from "@mui/material"; +import { toast } from "react-toastify"; const ErrorNotification = (pushToastList, notificationType, t, status, message) => { const toastId = toast( @@ -14,22 +14,20 @@ const ErrorNotification = (pushToastList, notificationType, t, status, message) justifyContent: "start", }} > - - - + + + {t("notifications.error")} ({t("notifications.code")}: {status}) - - {message || t("notifications.error_static_text")} - + {message || t("notifications.error_static_text")} ), { - containerId: 'validation', + containerId: "validation", autoClose: false, closeOnClick: false, draggable: false, @@ -38,4 +36,4 @@ const ErrorNotification = (pushToastList, notificationType, t, status, message) pushToastList(notificationType, toastId); }; -export default ErrorNotification; \ No newline at end of file +export default ErrorNotification; diff --git a/src/core/components/notifications/PendingNotification.jsx b/src/core/components/notifications/PendingNotification.jsx index cc28a58..6d8440c 100644 --- a/src/core/components/notifications/PendingNotification.jsx +++ b/src/core/components/notifications/PendingNotification.jsx @@ -1,8 +1,8 @@ -import {toast} from "react-toastify"; +import { toast } from "react-toastify"; const PendingNotification = (pushToastList, notificationType, t) => { const toastId = toast(t("notifications.pending"), { - containerId: 'validation', + containerId: "validation", autoClose: false, closeButton: false, closeOnClick: false, @@ -11,4 +11,4 @@ const PendingNotification = (pushToastList, notificationType, t) => { pushToastList(notificationType, toastId); }; -export default PendingNotification; \ No newline at end of file +export default PendingNotification; diff --git a/src/core/components/notifications/SuccessNotification.jsx b/src/core/components/notifications/SuccessNotification.jsx index 1207000..3f0d24a 100644 --- a/src/core/components/notifications/SuccessNotification.jsx +++ b/src/core/components/notifications/SuccessNotification.jsx @@ -1,6 +1,6 @@ import BeenhereIcon from "@mui/icons-material/Beenhere"; -import {Box, Typography} from "@mui/material"; -import {toast} from "react-toastify"; +import { Box, Typography } from "@mui/material"; +import { toast } from "react-toastify"; const SuccessNotification = (pushToastList, notificationType, t, status) => { const toastId = toast( @@ -14,23 +14,20 @@ const SuccessNotification = (pushToastList, notificationType, t, status) => { justifyContent: "start", }} > - - - + + + - {t("notifications.success")} ({t("notifications.code")}:{" "} - {status}) - - - {t("notifications.success_static_text")} + {t("notifications.success")} ({t("notifications.code")}: {status}) + {t("notifications.success_static_text")} ), { - containerId: 'validation', + containerId: "validation", autoClose: 3000, hideProgressBar: true, pauseOnHover: true, @@ -41,4 +38,4 @@ const SuccessNotification = (pushToastList, notificationType, t, status) => { pushToastList(notificationType, toastId); }; -export default SuccessNotification; \ No newline at end of file +export default SuccessNotification; diff --git a/src/core/components/notifications/UploadFileNotification.jsx b/src/core/components/notifications/UploadFileNotification.jsx index 1c20ba3..cd23ab2 100644 --- a/src/core/components/notifications/UploadFileNotification.jsx +++ b/src/core/components/notifications/UploadFileNotification.jsx @@ -1,10 +1,10 @@ import DangerousIcon from "@mui/icons-material/Dangerous"; -import {Box, Typography} from "@mui/material"; -import {toast} from "react-toastify"; +import { Box, Typography } from "@mui/material"; +import { toast } from "react-toastify"; const UploadFileNotification = (t) => { toast( - ({closeToast}) => ( + ({ closeToast }) => ( <> { justifyContent: "start", }} > - - - + + + {t("UploadSystem.uploadfile_error")} @@ -26,8 +26,8 @@ const UploadFileNotification = (t) => { ), { - containerId: 'validation', - toastId: 'upload', + containerId: "validation", + toastId: "upload", autoClose: 3000, hideProgressBar: true, pauseOnHover: true, @@ -37,4 +37,4 @@ const UploadFileNotification = (t) => { ); }; -export default UploadFileNotification; \ No newline at end of file +export default UploadFileNotification; diff --git a/src/core/components/notifications/WarningNotification.jsx b/src/core/components/notifications/WarningNotification.jsx index bc2a1fb..82536ef 100644 --- a/src/core/components/notifications/WarningNotification.jsx +++ b/src/core/components/notifications/WarningNotification.jsx @@ -1,6 +1,6 @@ import ReportIcon from "@mui/icons-material/Report"; -import {Box, Typography} from "@mui/material"; -import {toast} from "react-toastify"; +import { Box, Typography } from "@mui/material"; +import { toast } from "react-toastify"; const WarningNotification = (pushToastList, notificationType, t, status) => { const toastId = toast( @@ -14,23 +14,20 @@ const WarningNotification = (pushToastList, notificationType, t, status) => { justifyContent: "start", }} > - - - + + + - {t("notifications.warning")} ({t("notifications.code")}:{" "} - {status}) - - - {t("notifications.warning_static_text")} + {t("notifications.warning")} ({t("notifications.code")}: {status}) + {t("notifications.warning_static_text")} ), { - containerId: 'validation', + containerId: "validation", autoClose: false, closeOnClick: false, draggable: false, @@ -39,4 +36,4 @@ const WarningNotification = (pushToastList, notificationType, t, status) => { pushToastList(notificationType, toastId); }; -export default WarningNotification; \ No newline at end of file +export default WarningNotification; diff --git a/src/core/components/notifications/index.jsx b/src/core/components/notifications/index.jsx index 34e44f3..c6e2a28 100644 --- a/src/core/components/notifications/index.jsx +++ b/src/core/components/notifications/index.jsx @@ -13,9 +13,9 @@ const Notifications = (pushToastList, notificationType, t, status, message) => { break; case "error": if (message) { - ErrorNotification(pushToastList, notificationType, t, status, message) + ErrorNotification(pushToastList, notificationType, t, status, message); } else { - ErrorNotification(pushToastList, notificationType, t, status) + ErrorNotification(pushToastList, notificationType, t, status); } break; case "success": diff --git a/src/core/components/svgs/Svg403.jsx b/src/core/components/svgs/Svg403.jsx index 720828c..226a2ae 100644 --- a/src/core/components/svgs/Svg403.jsx +++ b/src/core/components/svgs/Svg403.jsx @@ -1,131 +1,295 @@ -import {useTheme} from "@mui/material"; +import { useTheme } from "@mui/material"; -const Svg403 = ({width, height}) => { - const theme = useTheme() - const fillColor = theme.palette.primary.main +const Svg403 = ({ width, height }) => { + const theme = useTheme(); + const fillColor = theme.palette.primary.main; return ( - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + - - + + - - + + - - + + - - + + - + transform="translate(-228.79147 -93.71349)" + fill="#9f616a" + /> + - + transform="translate(-228.79147 -93.71349)" + fill="#2f2e41" + /> + - - - - - - - + transform="translate(-228.79147 -93.71349)" + fill="#2f2e41" + /> + + + + + + + - + transform="translate(-228.79147 -93.71349)" + fill="#9f616a" + /> + - ) + ); +}; -} - -export default Svg403 \ No newline at end of file +export default Svg403; diff --git a/src/core/components/svgs/Svg404.jsx b/src/core/components/svgs/Svg404.jsx index e46ab12..4b9fa15 100644 --- a/src/core/components/svgs/Svg404.jsx +++ b/src/core/components/svgs/Svg404.jsx @@ -1,101 +1,163 @@ -import {useTheme} from "@mui/material"; +import { useTheme } from "@mui/material"; -const Svg404 = ({width, height}) => { - const theme = useTheme() - const fillColor = theme.palette.primary.main +const Svg404 = ({ width, height }) => { + const theme = useTheme(); + const fillColor = theme.palette.primary.main; return ( - + + transform="translate(-169.93432 -164.42601)" + fill="#f2f2f2" + /> + transform="translate(-169.93432 -164.42601)" + fill="#e4e4e4" + /> + transform="translate(-169.93432 -164.42601)" + fill="#e4e4e4" + /> + transform="translate(-169.93432 -164.42601)" + fill="#e4e4e4" + /> + transform="translate(-169.93432 -164.42601)" + fill="#f2f2f2" + /> + transform="translate(-169.93432 -164.42601)" + fill="#f2f2f2" + /> + transform="translate(-169.93432 -164.42601)" + fill="#f2f2f2" + /> + transform="translate(-169.93432 -164.42601)" + fill="#f2f2f2" + /> + transform="translate(-169.93432 -164.42601)" + fill="#f2f2f2" + /> - + transform="translate(-169.93432 -164.42601)" + fill="#f2f2f2" + /> + + transform="translate(-169.93432 -164.42601)" + fill="#f0f0f0" + /> + transform="translate(-169.93432 -164.42601)" + fill="#f0f0f0" + /> + transform="translate(-169.93432 -164.42601)" + fill="#ccc" + /> + transform="translate(-169.93432 -164.42601)" + fill="#3f3d56" + /> + transform="translate(-169.93432 -164.42601)" + fill="#3f3d56" + /> + transform="translate(-169.93432 -164.42601)" + fill="#3f3d56" + /> + transform="translate(-169.93432 -164.42601)" + fill="#3f3d56" + /> + transform="translate(-169.93432 -164.42601)" + opacity="0.2" + /> + transform="translate(-169.93432 -164.42601)" + fill="#3f3d56" + /> + transform="translate(-169.93432 -164.42601)" + fill={fillColor} + /> + transform="translate(-169.93432 -164.42601)" + fill={fillColor} + /> + transform="translate(-169.93432 -164.42601)" + fill="#3f3d56" + /> - - - - - - - - - - - + transform="translate(-169.93432 -164.42601)" + fill="#3f3d56" + /> + + + + + + + + + + + + transform="translate(-169.93432 -164.42601)" + fill="#cacaca" + /> - ) -} + ); +}; -export default Svg404 \ No newline at end of file +export default Svg404; diff --git a/src/core/components/svgs/SvgChangePassword.jsx b/src/core/components/svgs/SvgChangePassword.jsx index a7ee82f..73c1334 100644 --- a/src/core/components/svgs/SvgChangePassword.jsx +++ b/src/core/components/svgs/SvgChangePassword.jsx @@ -1,77 +1,133 @@ -import {useTheme} from "@mui/material"; +import { useTheme } from "@mui/material"; -const SvgChangePassword = ({width, height}) => { - const theme = useTheme() - const fillColor = theme.palette.primary.main +const SvgChangePassword = ({ width, height }) => { + const theme = useTheme(); + const fillColor = theme.palette.primary.main; return ( - + + transform="translate(-124.38226 -133.06928)" + fill="#f0f0f0" + /> + transform="translate(-124.38226 -133.06928)" + fill="#fff" + /> + transform="translate(-124.38226 -133.06928)" + fill="#fff" + /> + transform="translate(-124.38226 -133.06928)" + fill="#fff" + /> + transform="translate(-124.38226 -133.06928)" + fill="#fff" + /> + transform="translate(-124.38226 -133.06928)" + fill="#f0f0f0" + /> + transform="translate(-124.38226 -133.06928)" + fill="#fff" + /> + transform="translate(-124.38226 -133.06928)" + fill="#fff" + /> + transform="translate(-124.38226 -133.06928)" + fill="#fff" + /> + transform="translate(-124.38226 -133.06928)" + fill="#fff" + /> + transform="translate(-124.38226 -133.06928)" + fill="#3f3d56" + /> - - - + transform="translate(-124.38226 -133.06928)" + fill="#e5e5e5" + /> + + + - - + transform="translate(-124.38226 -133.06928)" + fill="#2f2e41" + /> + + - - - - - - - - + transform="translate(-124.38226 -133.06928)" + fill={fillColor} + /> + + + + + + + + - ) -} + ); +}; -export default SvgChangePassword \ No newline at end of file +export default SvgChangePassword; diff --git a/src/core/components/svgs/SvgDashboard.jsx b/src/core/components/svgs/SvgDashboard.jsx index a5b40e0..b177340 100644 --- a/src/core/components/svgs/SvgDashboard.jsx +++ b/src/core/components/svgs/SvgDashboard.jsx @@ -1,117 +1,176 @@ -import {useTheme} from "@mui/material"; +import { useTheme } from "@mui/material"; + +const SvgDashboard = ({ width, height }) => { + const theme = useTheme(); + const fillColor = theme.palette.primary.main; -const SvgDashboard = ({width, height}) => { - const theme = useTheme() - const fillColor = theme.palette.primary.main - return ( - + + transform="translate(-85.21873 -175.65252)" + fill="#f1f1f1" + /> + transform="translate(-85.21873 -175.65252)" + fill="#f1f1f1" + /> + transform="translate(-85.21873 -175.65252)" + fill="#f1f1f1" + /> + transform="translate(-85.21873 -175.65252)" + fill="#f1f1f1" + /> + transform="translate(-85.21873 -175.65252)" + fill="#e6e6e6" + /> + transform="translate(-85.21873 -175.65252)" + fill="#ccc" + /> + transform="translate(-85.21873 -175.65252)" + fill="#3f3d56" + /> + transform="translate(-85.21873 -175.65252)" + fill="#fff" + /> - - - - - - + transform="translate(-85.21873 -175.65252)" + fill="#ccc" + /> + + + + + + - - + transform="translate(-85.21873 -175.65252)" + fill="#e5e5e5" + /> + + - - + transform="translate(-85.21873 -175.65252)" + fill="#e5e5e5" + /> + + - - + transform="translate(-85.21873 -175.65252)" + fill="#e5e5e5" + /> + + - - + transform="translate(-85.21873 -175.65252)" + fill="#e5e5e5" + /> + + - + transform="translate(-85.21873 -175.65252)" + fill="#e5e5e5" + /> + + transform="translate(-85.21873 -175.65252)" + fill="#3f3d56" + /> - - - - - - + fill="#3f3d56" + /> + + + + + + - + transform="translate(-85.21873 -175.65252)" + fill="#ffb7b7" + /> + - + transform="translate(-85.21873 -175.65252)" + fill="#2f2e41" + /> + + transform="translate(-85.21873 -175.65252)" + fill="#2f2e41" + /> + fill="#2f2e41" + /> + transform="translate(-85.21873 -175.65252)" + fill={fillColor} + /> + transform="translate(-85.21873 -175.65252)" + fill={fillColor} + /> + transform="translate(-85.21873 -175.65252)" + fill="#ffb7b7" + /> + transform="translate(-85.21873 -175.65252)" + fill={fillColor} + /> + transform="translate(-85.21873 -175.65252)" + fill="#ffb7b7" + /> + transform="translate(-85.21873 -175.65252)" + fill="#2f2e41" + /> - ) -} + ); +}; -export default SvgDashboard \ No newline at end of file +export default SvgDashboard; diff --git a/src/core/components/svgs/SvgLoading.jsx b/src/core/components/svgs/SvgLoading.jsx index f9cea4a..2212f69 100644 --- a/src/core/components/svgs/SvgLoading.jsx +++ b/src/core/components/svgs/SvgLoading.jsx @@ -1,136 +1,292 @@ -import {useTheme} from "@mui/material"; +import { useTheme } from "@mui/material"; -const SvgLoading = ({width, height}) => { - const theme = useTheme() - const fillColor = theme.palette.primary.main +const SvgLoading = ({ width, height }) => { + const theme = useTheme(); + const fillColor = theme.palette.primary.main; return ( - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - + + + + - - + + - - + + - - + + - - - - - - - - - - - - - - + transform="translate(-253.01352 -93.71349)" + fill="#e6e6e6" + /> + + + + + + + + + + + + + + - + transform="translate(-253.01352 -93.71349)" + fill={fillColor} + /> + - ) -} + ); +}; -export default SvgLoading \ No newline at end of file +export default SvgLoading; diff --git a/src/core/components/svgs/SvgLogin.jsx b/src/core/components/svgs/SvgLogin.jsx index 643c195..a5de266 100644 --- a/src/core/components/svgs/SvgLogin.jsx +++ b/src/core/components/svgs/SvgLogin.jsx @@ -1,75 +1,116 @@ -import {useTheme} from "@mui/material"; +import { useTheme } from "@mui/material"; -const SvgLogin = ({width, height}) => { - const theme = useTheme() - const fillColor = theme.palette.primary.main +const SvgLogin = ({ width, height }) => { + const theme = useTheme(); + const fillColor = theme.palette.primary.main; return ( - + + transform="translate(-165.00003 -189.93073)" + fill="#f2f2f2" + /> + transform="translate(-165.00003 -189.93073)" + fill="#fff" + /> + transform="translate(-165.00003 -189.93073)" + fill="#f2f2f2" + /> + transform="translate(-165.00003 -189.93073)" + fill="#fff" + /> + transform="translate(-165.00003 -189.93073)" + fill="#f2f2f2" + /> - - + transform="translate(-165.00003 -189.93073)" + fill="#ccc" + /> + + - + fill="#2f2e41" + /> + + fill="#2f2e41" + /> + transform="translate(-165.00003 -189.93073)" + fill="#ffb8b8" + /> - + transform="translate(-165.00003 -189.93073)" + fill="#ffb8b8" + /> + - + transform="translate(-165.00003 -189.93073)" + fill={fillColor} + /> + + transform="translate(-165.00003 -189.93073)" + fill={fillColor} + /> + transform="translate(-165.00003 -189.93073)" + fill="#2f2e41" + /> + transform="translate(-165.00003 -189.93073)" + fill="#2f2e41" + /> + transform="translate(-165.00003 -189.93073)" + fill="#3f3d56" + /> - - - - + transform="translate(-165.00003 -189.93073)" + fill="#fff" + /> + + + + - ) + ); +}; -} - -export default SvgLogin \ No newline at end of file +export default SvgLogin; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index bbd34ed..7886e5b 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -15,197 +15,136 @@ export const GET_USER_ROUTE = BASE_URL + "/dashboard/profile/info"; //user data //passenger office -export const GET_PASSENGER_OFFICE = - BASE_URL + "/dashboard/passenger_office_chief/show"; +export const GET_PASSENGER_OFFICE = BASE_URL + "/dashboard/passenger_office_chief/show"; -export const CONFIRM_PASSENGER_OFFICE = - BASE_URL + "/dashboard/passenger_office_chief/confirm"; +export const CONFIRM_PASSENGER_OFFICE = BASE_URL + "/dashboard/passenger_office_chief/confirm"; -export const REJECT_PASSENGER_OFFICE = - BASE_URL + "/dashboard/passenger_office_chief/reject"; +export const REJECT_PASSENGER_OFFICE = BASE_URL + "/dashboard/passenger_office_chief/reject"; -export const EXPORT_PASSENGER_OFFICE = - BASE_URL + "/dashboard/passenger_office_chief/export" +export const EXPORT_PASSENGER_OFFICE = BASE_URL + "/dashboard/passenger_office_chief/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"; +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"; -export const REJECT_PASSENGER_BOSS = - BASE_URL + "/dashboard/province_working_group/reject"; -export const EXPORT_PASSENGER_BOSS = - BASE_URL + "/dashboard/province_working_group/export"; -export const RESERVE_PASSENGER_BOSS = - BASE_URL + "/dashboard/province_working_group/reserve"; -export const EXPORT_PASSENGER_BOSS_DETAILS = - BASE_URL + "/dashboard/province_working_group"; +export const REJECT_PASSENGER_BOSS = BASE_URL + "/dashboard/province_working_group/reject"; +export const EXPORT_PASSENGER_BOSS = BASE_URL + "/dashboard/province_working_group/export"; +export const RESERVE_PASSENGER_BOSS = BASE_URL + "/dashboard/province_working_group/reserve"; +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"; +export const GET_LOAN_FOLLOWUP = BASE_URL + "/dashboard/vezarat_loan_tracking/"; +export const REFER_LOAN_FOLLOWUP_PASSENGERBOSS = BASE_URL + "/dashboard/vezarat_loan_tracking/refer"; +export const GET_HISTORY_COUNCIL = BASE_URL + "/dashboard/vezarat_loan_tracking/planning_council_loan"; //transportation assistance -export const GET_TRANSPORTATION_ASSISTANCE = - BASE_URL + "/dashboard/transportation_assistant/show"; +export const GET_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_assistant/show"; -export const GET_TRANSPORTATION_ASSISTANCE_DETAILS = - BASE_URL + "/dashboard/transportation_assistant"; -export const CONFIRM_TRANSPORTATION_ASSISTANCE = - BASE_URL + "/dashboard/transportation_assistant/confirm"; +export const GET_TRANSPORTATION_ASSISTANCE_DETAILS = BASE_URL + "/dashboard/transportation_assistant"; +export const CONFIRM_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_assistant/confirm"; -export const REJECT_TRANSPORTATION_ASSISTANCE = - BASE_URL + "/dashboard/transportation_assistant/reject"; -export const REFER_TRANSPORTATION_ASSISTANCE = - BASE_URL + "/dashboard/transportation_assistant/refer"; -export const EXPORT_TRANSPORTATION_ASSISTANCE = - BASE_URL + "/dashboard/transportation_assistant/export"; +export const REJECT_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_assistant/reject"; +export const REFER_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_assistant/refer"; +export const EXPORT_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_assistant/export"; //transportation assistance //machinary office -export const GET_MACHINARY_OFFICE = - BASE_URL + "/dashboard/machinery_expert/show"; +export const GET_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/show"; -export const CONFIRM_MACHINARY_OFFICE = - BASE_URL + "/dashboard/machinery_expert/confirm"; +export const CONFIRM_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/confirm"; -export const CONFIRM_MACHINARY_OFFICE_DETAILS = - BASE_URL + "/dashboard/machinery_expert"; +export const CONFIRM_MACHINARY_OFFICE_DETAILS = BASE_URL + "/dashboard/machinery_expert"; -export const REJECT_MACHINARY_OFFICE = - BASE_URL + "/dashboard/machinery_expert/reject"; -export const EXPORT_MACHINARY_OFFICE = - BASE_URL + "/dashboard/machinery_expert/export"; +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/reserved_loan/show"; -export const GET_RESERVE_MACHINARY_LOAN = - BASE_URL + "/dashboard/reserved_loan/show"; - -export const CANSEL_RESERVE_MACHINARY_LOAN = - BASE_URL + "/dashboard/reserved_loan/unreserve"; +export const CANSEL_RESERVE_MACHINARY_LOAN = BASE_URL + "/dashboard/reserved_loan/unreserve"; //machinary office //commercial chief -export const GET_COMMERCIAL_CHIEF = - BASE_URL + "/dashboard/commercial_chief/show"; +export const GET_COMMERCIAL_CHIEF = BASE_URL + "/dashboard/commercial_chief/show"; -export const CONFIRM_COMMERCIAL_CHIEF = - BASE_URL + "/dashboard/commercial_chief/confirm"; +export const CONFIRM_COMMERCIAL_CHIEF = BASE_URL + "/dashboard/commercial_chief/confirm"; -export const REJECT_COMMERCIAL_CHIEF = - BASE_URL + "/dashboard/commercial_chief/reject"; +export const REJECT_COMMERCIAL_CHIEF = BASE_URL + "/dashboard/commercial_chief/reject"; //commercial chief //navgan province manager -export const GET_NAVGAN_PROVINCE_MANAGER = - BASE_URL + "/dashboard/province_manager/show"; +export const GET_NAVGAN_PROVINCE_MANAGER = BASE_URL + "/dashboard/province_manager/show"; -export const CONFIRM_NAVGAN_PROVINCE_MANAGER = - BASE_URL + "/dashboard/province_manager/confirm"; +export const CONFIRM_NAVGAN_PROVINCE_MANAGER = BASE_URL + "/dashboard/province_manager/confirm"; -export const REJECT_NAVGAN_PROVINCE_MANAGER = - BASE_URL + "/dashboard/province_manager/reject"; -export const REFER_NAVGAN_PROVINCE_MANAGER = - BASE_URL + "/dashboard/province_manager/refer"; -export const EXPORT_NAVGAN_PROVINCE_MANAGER = - BASE_URL + "/dashboard/province_manager/export"; +export const REJECT_NAVGAN_PROVINCE_MANAGER = BASE_URL + "/dashboard/province_manager/reject"; +export const REFER_NAVGAN_PROVINCE_MANAGER = BASE_URL + "/dashboard/province_manager/refer"; +export const EXPORT_NAVGAN_PROVINCE_MANAGER = BASE_URL + "/dashboard/province_manager/export"; -export const CONFIRM_PROVINCE_MANAGER_DETAILS = - BASE_URL + "/dashboard/province_manager"; +export const CONFIRM_PROVINCE_MANAGER_DETAILS = BASE_URL + "/dashboard/province_manager"; //navgan province manager // refahi province manager -export const GET_REFAHI_PROVINCE_MANAGER = - BASE_URL + "/dashboard/refahi_province_manager/show"; +export const GET_REFAHI_PROVINCE_MANAGER = BASE_URL + "/dashboard/refahi_province_manager/show"; -export const CONFIRM_REFAHI_PROVINCE_MANAGER = - BASE_URL + "/dashboard/refahi_province_manager/confirm"; +export const CONFIRM_REFAHI_PROVINCE_MANAGER = BASE_URL + "/dashboard/refahi_province_manager/confirm"; -export const REJECT_REFAHI_PROVINCE_MANAGER = - BASE_URL + "/dashboard/refahi_province_manager/reject"; +export const REJECT_REFAHI_PROVINCE_MANAGER = BASE_URL + "/dashboard/refahi_province_manager/reject"; //refahi province manager // development assistant -export const GET_DEVELOPMENT_ASSISTANT = - BASE_URL + "/dashboard/development_assistant/show"; +export const GET_DEVELOPMENT_ASSISTANT = BASE_URL + "/dashboard/development_assistant/show"; -export const CONFIRM_DEVELOPMENT_ASSISTANT = - BASE_URL + "/dashboard/development_assistant/confirm"; +export const CONFIRM_DEVELOPMENT_ASSISTANT = BASE_URL + "/dashboard/development_assistant/confirm"; -export const REJECT_DEVELOPMENT_ASSISTANT = - BASE_URL + "/dashboard/development_assistant/reject"; +export const REJECT_DEVELOPMENT_ASSISTANT = BASE_URL + "/dashboard/development_assistant/reject"; //development assistant // inspector expert -export const GET_INSPECTOR_EXPERT = - BASE_URL + "/dashboard/inspector_expert/show"; +export const GET_INSPECTOR_EXPERT = BASE_URL + "/dashboard/inspector_expert/show"; -export const CONFIRM_INSPECTOR_EXPERT = - BASE_URL + "/dashboard/inspector_expert/confirm"; +export const CONFIRM_INSPECTOR_EXPERT = BASE_URL + "/dashboard/inspector_expert/confirm"; -export const REJECT_INSPECTOR_EXPERT = - BASE_URL + "/dashboard/inspector_expert/reject"; +export const REJECT_INSPECTOR_EXPERT = BASE_URL + "/dashboard/inspector_expert/reject"; -export const REVISE_INSPECTOR_EXPERT = - BASE_URL + "/dashboard/inspector_expert/revise" +export const REVISE_INSPECTOR_EXPERT = BASE_URL + "/dashboard/inspector_expert/revise"; //inspector expert // province head expert -export const GET_PROVINCE_HEAD_EXPERT = - BASE_URL + "/dashboard/province_head_expert/show"; +export const GET_PROVINCE_HEAD_EXPERT = BASE_URL + "/dashboard/province_head_expert/show"; -export const CONFIRM_PROVINCE_HEAD_EXPERT = - BASE_URL + "/dashboard/province_head_expert/confirm"; +export const CONFIRM_PROVINCE_HEAD_EXPERT = BASE_URL + "/dashboard/province_head_expert/confirm"; -export const REJECT_PROVINCE_HEAD_EXPERT = - BASE_URL + "/dashboard/province_head_expert/reject"; +export const REJECT_PROVINCE_HEAD_EXPERT = BASE_URL + "/dashboard/province_head_expert/reject"; -export const REVISE_PROVINCE_HEAD_EXPERT = - BASE_URL + "/dashboard/province_head_expert/revise"; +export const REVISE_PROVINCE_HEAD_EXPERT = BASE_URL + "/dashboard/province_head_expert/revise"; //province head expert //sidebar notification -export const GET_SIDEBAR_NOTIFICATION = - BASE_URL + "/dashboard/notification" +export const GET_SIDEBAR_NOTIFICATION = BASE_URL + "/dashboard/notification"; //sidebar notification //loan management refahi -export const GET_LOAN_MANAGEMENT_REFAHI = - BASE_URL + "/dashboard/refahi_loans" -export const UPDATE_LOAN_MANAGEMENT_REFAHI = - BASE_URL + "/dashboard/refahi_loans/update" -export const GET_LOAN_STATE_REFAHI = - BASE_URL + "/dashboard/loan_states/refahi" +export const GET_LOAN_MANAGEMENT_REFAHI = BASE_URL + "/dashboard/refahi_loans"; +export const UPDATE_LOAN_MANAGEMENT_REFAHI = BASE_URL + "/dashboard/refahi_loans/update"; +export const GET_LOAN_STATE_REFAHI = BASE_URL + "/dashboard/loan_states/refahi"; //loan management refahi // loan management navgan -export const GET_LOAN_MANAGEMENT_NAVGAN = - BASE_URL + "/dashboard/navgan_loans" -export const UPDATE_LOAN_MANAGEMENT_NAVGAN = - BASE_URL + "/dashboard/navgan_loans/update" -export const GET_LOAN_STATE_NAVGAN = - BASE_URL + "/dashboard/loan_states/navgan" -export const EXPORT_LOAN_MANAGEMENT_HISTORY = BASE_URL + "/dashboard/navgan_loans/export" +export const GET_LOAN_MANAGEMENT_NAVGAN = BASE_URL + "/dashboard/navgan_loans"; +export const UPDATE_LOAN_MANAGEMENT_NAVGAN = BASE_URL + "/dashboard/navgan_loans/update"; +export const GET_LOAN_STATE_NAVGAN = BASE_URL + "/dashboard/loan_states/navgan"; +export const EXPORT_LOAN_MANAGEMENT_HISTORY = BASE_URL + "/dashboard/navgan_loans/export"; //loan management navgan //expert management -export const GET_EXPERT_MANAGEMENT = - BASE_URL + "/dashboard/experts/show" -export const CREATE_EXPERT_MANAGEMENT = - BASE_URL + "/dashboard/experts/store" -export const UPDATE_EXPERT_MANAGEMENT = - BASE_URL + "/dashboard/experts/update" -export const DELETE_EXPERT_MANAGEMENT = - BASE_URL + "/dashboard/experts/delete" -export const CHANGE_PASSWORD_EXPERT_MANAGEMENT = - BASE_URL + "/dashboard/experts/change_password" +export const GET_EXPERT_MANAGEMENT = BASE_URL + "/dashboard/experts/show"; +export const CREATE_EXPERT_MANAGEMENT = BASE_URL + "/dashboard/experts/store"; +export const UPDATE_EXPERT_MANAGEMENT = BASE_URL + "/dashboard/experts/update"; +export const DELETE_EXPERT_MANAGEMENT = BASE_URL + "/dashboard/experts/delete"; +export const CHANGE_PASSWORD_EXPERT_MANAGEMENT = BASE_URL + "/dashboard/experts/change_password"; //expert management // province/city list @@ -218,58 +157,48 @@ export const GET_ROLE_LIST = BASE_URL + "/dashboard/roles/list"; // role list //user management -export const GET_USER_MANAGEMENT = - BASE_URL + "/dashboard/user_management/show" -export const ADD_USER_MANAGEMENT = - BASE_URL + "/dashboard/user_management/store" -export const UPDATE_USER_MANAGEMENT = - BASE_URL + "/dashboard/user_management/update" -export const DELETE_USER_MANAGEMENT = - BASE_URL + "/dashboard/user_management/delete" +export const GET_USER_MANAGEMENT = BASE_URL + "/dashboard/user_management/show"; +export const ADD_USER_MANAGEMENT = BASE_URL + "/dashboard/user_management/store"; +export const UPDATE_USER_MANAGEMENT = BASE_URL + "/dashboard/user_management/update"; +export const DELETE_USER_MANAGEMENT = BASE_URL + "/dashboard/user_management/delete"; //user management // role management -export const GET_ROLE_MANAGEMENT = - BASE_URL + "/dashboard/roles" -export const ADD_ROLE_MANAGEMENT = - BASE_URL + "/dashboard/roles/store" -export const UPDATE_ROLE_MANAGEMENT = - BASE_URL + "/dashboard/roles/update" -export const DELETE_ROLE_MANAGEMENT = - BASE_URL + "/dashboard/roles/delete" +export const GET_ROLE_MANAGEMENT = BASE_URL + "/dashboard/roles"; +export const ADD_ROLE_MANAGEMENT = BASE_URL + "/dashboard/roles/store"; +export const UPDATE_ROLE_MANAGEMENT = BASE_URL + "/dashboard/roles/update"; +export const DELETE_ROLE_MANAGEMENT = BASE_URL + "/dashboard/roles/delete"; -export const GET_PERMISSIONS_LIST = - BASE_URL + "/dashboard/permissions/list" +export const GET_PERMISSIONS_LIST = BASE_URL + "/dashboard/permissions/list"; //role management // reports -export const GET_EXPORT = BASE_URL + "/dashboard/exports/navgan" -export const GET_EXCEL_EXPORT = BASE_URL + "/dashboard/exports/navgan/expert_progress" -export const GET_EXCEL_EXPORT_status = BASE_URL + "/dashboard/exports/navgan/loans_state" -export const GET_PROVINCE_PROGRESS = BASE_URL + "/dashboard/reports/navgan/province_progress" -export const GET_LOAN_DISTRIBUTION = BASE_URL + "/dashboard/reports/navgan/loan_distribution" -export const GET_LOAN_EXPERTPROGRESS = BASE_URL + "/dashboard/reports/navgan/expert_progress" -export const GET_LOAN_REFERREDLOANS = BASE_URL + "/dashboard/reports/navgan/referred_loans" +export const GET_EXPORT = BASE_URL + "/dashboard/exports/navgan"; +export const GET_EXCEL_EXPORT = BASE_URL + "/dashboard/exports/navgan/expert_progress"; +export const GET_EXCEL_EXPORT_status = BASE_URL + "/dashboard/exports/navgan/loans_state"; +export const GET_PROVINCE_PROGRESS = BASE_URL + "/dashboard/reports/navgan/province_progress"; +export const GET_LOAN_DISTRIBUTION = BASE_URL + "/dashboard/reports/navgan/loan_distribution"; +export const GET_LOAN_EXPERTPROGRESS = BASE_URL + "/dashboard/reports/navgan/expert_progress"; +export const GET_LOAN_REFERREDLOANS = BASE_URL + "/dashboard/reports/navgan/referred_loans"; // reports //loan history -export const GET_LOAN_HISTORY = BASE_URL + "/dashboard/navgan_loans" -export const GET_HISTORY_DETAIL = BASE_URL + "/dashboard/navgan_loans" -export const EXPORT_LOAN_HISTORY = BASE_URL + "/dashboard/navgan_loans/export" +export const GET_LOAN_HISTORY = BASE_URL + "/dashboard/navgan_loans"; +export const GET_HISTORY_DETAIL = BASE_URL + "/dashboard/navgan_loans"; +export const EXPORT_LOAN_HISTORY = BASE_URL + "/dashboard/navgan_loans/export"; //admin setting -export const GET_ADMIN_SETTING = BASE_URL + "/dashboard/settings/show" -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" +export const GET_ADMIN_SETTING = BASE_URL + "/dashboard/settings/show"; +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/send" -export const EXPORT_BANK_MANAGEMENT = BASE_URL + "/dashboard/bank_referred_loans/export" -export const REJECT_BANK_MANAGEMENT = BASE_URL + "/dashboard/bank_referred_loans/reject" -export const EDIT_APPROVED_AMOUNT = BASE_URL + "/dashboard/bank_referred_loans/update" +export const GET_BANK_STATEMENT = BASE_URL + "/dashboard/bank_referred_loans"; +export const RESEND_BANK_STATEMENT = BASE_URL + "/dashboard/bank_referred_loans/send"; +export const EXPORT_BANK_MANAGEMENT = BASE_URL + "/dashboard/bank_referred_loans/export"; +export const REJECT_BANK_MANAGEMENT = BASE_URL + "/dashboard/bank_referred_loans/reject"; +export const EDIT_APPROVED_AMOUNT = BASE_URL + "/dashboard/bank_referred_loans/update"; // loan statistics -export const GET_LOAN_STATISTICS = BASE_URL + "/dashboard/reports/navgan/statistics" - +export const GET_LOAN_STATISTICS = BASE_URL + "/dashboard/reports/navgan/statistics"; diff --git a/src/core/data/headerProfileItems.jsx b/src/core/data/headerProfileItems.jsx index 577fba3..7196aea 100644 --- a/src/core/data/headerProfileItems.jsx +++ b/src/core/data/headerProfileItems.jsx @@ -6,13 +6,13 @@ const headerProfileItems = [ key: 0, name: "header.edit_profile", route: "/dashboard/edit-profile", - icon: , + icon: , }, { key: 1, name: "header.change_password", route: "/dashboard/change-password", - icon: , + icon: , }, ]; diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index 49413dd..e170091 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -2,21 +2,21 @@ import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard"; import DirectionsRailwayIcon from "@mui/icons-material/DirectionsRailway"; 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 PaidIcon from '@mui/icons-material/Paid'; -import ManageAccountsIcon from '@mui/icons-material/ManageAccounts'; -import PersonIcon from '@mui/icons-material/Person'; -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'; -import AccountBalanceIcon from '@mui/icons-material/AccountBalance'; -import RepeatIcon from '@mui/icons-material/Repeat'; +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 PaidIcon from "@mui/icons-material/Paid"; +import ManageAccountsIcon from "@mui/icons-material/ManageAccounts"; +import PersonIcon from "@mui/icons-material/Person"; +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"; +import AccountBalanceIcon from "@mui/icons-material/AccountBalance"; +import RepeatIcon from "@mui/icons-material/Repeat"; const sidebarMenu = [ [ @@ -24,7 +24,7 @@ const sidebarMenu = [ key: "sidebar.dashboard", type: "page", route: "/dashboard", - icon: , + icon: , selected: false, permissions: ["all"], }, @@ -33,7 +33,7 @@ const sidebarMenu = [ name: "reports", type: "page", route: "/dashboard/reports", - icon: , + icon: , selected: false, permissions: ["view_reports_navgan"], }, @@ -42,18 +42,19 @@ const sidebarMenu = [ name: "loan-history", type: "page", route: "/dashboard/loan-history", - icon: , + icon: , selected: false, permissions: ["view_navgan_loans", "view_navgan_loans_province"], }, - ], [ + ], + [ { key: "sidebar.reserve-loan", secondary: "secondary.navgan-province-manager", name: "reserve_loan", type: "page", route: "/dashboard/reserve-loan", - icon: , + icon: , selected: false, permissions: ["manage_reserved_loans"], }, @@ -63,7 +64,7 @@ const sidebarMenu = [ name: "province_working_group", type: "page", route: "/dashboard/passenger-boss", - icon: , + icon: , selected: false, permissions: ["manage_province_working_group_navgan"], }, @@ -74,7 +75,7 @@ const sidebarMenu = [ name: "transportation_assistant", type: "page", route: "/dashboard/transportation-assistant", - icon: , + icon: , selected: false, permissions: ["manage_transportation_navgan"], }, @@ -84,7 +85,7 @@ const sidebarMenu = [ name: "province_manager_navgan", type: "page", route: "/dashboard/navgan-province-manager", - icon: , + icon: , selected: false, permissions: ["manage_province_affairs_navgan"], }, @@ -94,7 +95,7 @@ const sidebarMenu = [ name: "management", type: "page", route: "/dashboard/bank-management", - icon: , + icon: , selected: false, permissions: ["tracking_bank_loans"], }, @@ -104,7 +105,7 @@ const sidebarMenu = [ name: "loan-followup", type: "page", route: "/dashboard/loan-followup", - icon: , + icon: , selected: false, permissions: ["manage_vezarat_eghtesad_loans"], //permission should change }, @@ -114,18 +115,19 @@ const sidebarMenu = [ name: "navgan_loan_management", type: "page", route: "/dashboard/navgan-loan-management", - icon: , + icon: , selected: false, permissions: ["manage_navgan_loan"], }, - ], [ + ], + [ { key: "sidebar.province-head-expert", secondary: "secondary.refahi-province-manager", name: "province_head_expert", type: "page", route: "/dashboard/province-head-expert", - icon: , + icon: , selected: false, permissions: ["manage_province_headquarter_refahi"], }, @@ -135,7 +137,7 @@ const sidebarMenu = [ name: "inspector_expert", type: "page", route: "/dashboard/inspector-expert", - icon: , + icon: , selected: false, permissions: ["manage_inspector_refahi"], }, @@ -145,7 +147,7 @@ const sidebarMenu = [ name: "commercial_chief", type: "page", route: "/dashboard/commercial-chief", - icon: , + icon: , selected: false, permissions: ["manage_commercial_refahi"], }, @@ -155,7 +157,7 @@ const sidebarMenu = [ name: "development_assistant", type: "page", route: "/dashboard/development-assistant", - icon: , + icon: , selected: false, permissions: ["manage_development_refahi"], }, @@ -165,7 +167,7 @@ const sidebarMenu = [ name: "province_manager_refahi", type: "page", route: "/dashboard/refahi-province-manager", - icon: , + icon: , selected: false, permissions: ["manage_province_affairs_refahi"], }, @@ -175,18 +177,19 @@ const sidebarMenu = [ name: "refahi_loan_management", type: "page", route: "/dashboard/refahi-loan-management", - icon: , + icon: , selected: false, permissions: ["manage_refahi_loan"], }, - ], [ + ], + [ { key: "sidebar.expert-management", secondary: "secondary.admin-management", name: "expert_management", type: "page", route: "/dashboard/expert-management", - icon: , + icon: , selected: false, permissions: ["manage_experts"], }, @@ -196,7 +199,7 @@ const sidebarMenu = [ name: "user_management", type: "page", route: "/dashboard/user-management", - icon: , + icon: , selected: false, permissions: ["manage_users"], }, @@ -206,7 +209,7 @@ const sidebarMenu = [ name: "role_management", type: "page", route: "/dashboard/role-management", - icon: , + icon: , selected: false, permissions: ["manage_roles"], }, @@ -216,10 +219,10 @@ const sidebarMenu = [ name: "admin_setting", type: "page", route: "/dashboard/admin-setting", - icon: , + icon: , selected: false, permissions: ["view_settings"], - } + }, ], ]; diff --git a/src/core/utils/createEmotionCache.jsx b/src/core/utils/createEmotionCache.jsx index 413fafe..5a976c9 100644 --- a/src/core/utils/createEmotionCache.jsx +++ b/src/core/utils/createEmotionCache.jsx @@ -1,5 +1,5 @@ import createCache from "@emotion/cache"; -import {prefixer} from "stylis"; +import { prefixer } from "stylis"; import stylisRTLPlugin from "stylis-plugin-rtl"; const isBrowser = typeof document !== "undefined"; @@ -8,9 +8,7 @@ export const createEmotionCacheLtr = () => { let insertionPoint; if (isBrowser) { - const emotionInsertionPoint = document.querySelector( - 'meta[name="emotion-insertion-point"]' - ); + const emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]'); insertionPoint = emotionInsertionPoint ?? undefined; } @@ -24,9 +22,7 @@ export const createEmotionCacheRtl = () => { let insertionPoint; if (isBrowser) { - const emotionInsertionPoint = document.querySelector( - 'meta[name="emotion-insertion-point"]' - ); + const emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]'); insertionPoint = emotionInsertionPoint ?? undefined; } diff --git a/src/core/utils/errorHandler.js b/src/core/utils/errorHandler.js index 10ff105..3066b71 100644 --- a/src/core/utils/errorHandler.js +++ b/src/core/utils/errorHandler.js @@ -2,53 +2,53 @@ import Notifications from "@/core/components/notifications"; export const errorSetting = (dismissToastList, t, notification) => { if (notification) { - dismissToastList(["pending", "warning", "error", "success"]) + dismissToastList(["pending", "warning", "error", "success"]); } -} +}; export const errorRequest = (dismissToastList, t, notification) => { if (notification) { - dismissToastList(["pending", "warning", "error", "success"]) + dismissToastList(["pending", "warning", "error", "success"]); } -} +}; export const errorResponse = (pushToastList, dismissToastList, response, clearToken, t, notification) => { if (notification) { - dismissToastList(["pending", "warning", "error", "success"]) + dismissToastList(["pending", "warning", "error", "success"]); } if (isServerError(response.status)) { - errorServer(pushToastList, response, t, notification) + errorServer(pushToastList, response, t, notification); } else if (isClientError(response.status)) { - errorClient(pushToastList, response, clearToken, t, notification) + errorClient(pushToastList, response, clearToken, t, notification); } -} +}; const errorServer = (pushToastList, response, t, notification) => { if (notification) Notifications(pushToastList, "warning", t, response.status); -} +}; const errorClient = (pushToastList, response, clearToken, t, notification) => { switch (response.status) { case 401: - clearToken() + clearToken(); if (notification) Notifications(pushToastList, "error", t, response.status); break; case 422: - if ('type' in response.data) { - errorLogic(pushToastList, response, t, notification) + if ("type" in response.data) { + errorLogic(pushToastList, response, t, notification); break; } - errorValidation(pushToastList, response, t, notification) + errorValidation(pushToastList, response, t, notification); break; case 429: if (notification) Notifications(pushToastList, "error", t, response.status); - break + break; default: if (notification) Notifications(pushToastList, "error", t, response.status); - break + break; } -} +}; -const isServerError = status => status >= 500 && status <= 599; -const isClientError = status => status >= 400 && status <= 499; +const isServerError = (status) => status >= 500 && status <= 599; +const isClientError = (status) => status >= 400 && status <= 499; const errorLogic = (pushToastList, response, t, notification) => { if (notification) { @@ -56,23 +56,16 @@ const errorLogic = (pushToastList, response, t, notification) => { response.data.message.map((item) => { Notifications(pushToastList, "error", t, response.status, item); }); - } else - Notifications( - pushToastList, - "error", - t, - response.status, - response.data.message - ); + } else Notifications(pushToastList, "error", t, response.status, response.data.message); } -} +}; const errorValidation = (pushToastList, response, t, notification) => { if (notification) { - const errorsMap = Object.keys(response.data.errors) - const errorsArray = response.data.errors + const errorsMap = Object.keys(response.data.errors); + const errorsArray = response.data.errors; errorsMap.map((item, index) => { Notifications(pushToastList, "error", t, response.status, errorsArray[item][0]); - }) + }); } -} \ No newline at end of file +}; diff --git a/src/core/utils/gradientColorHandler.js b/src/core/utils/gradientColorHandler.js index e16b42a..5b1e1b7 100644 --- a/src/core/utils/gradientColorHandler.js +++ b/src/core/utils/gradientColorHandler.js @@ -1,11 +1,11 @@ export const calculateGradientColor = (percentage) => { let colorStops = [ - {percent: 0, color: [173, 3, 23]}, // 0%: #3D0C11 - {percent: 33, color: [245, 81, 81]}, // 33%: #D80032 - {percent: 34, color: [237, 204, 101]}, // 34%: #F2F7A1 - {percent: 66, color: [240, 184, 7]}, // 66%: #E9B824 - {percent: 67, color: [167, 211, 151]}, // 67%: #B0D9B1 - {percent: 100, color: [0, 91, 65]} // 100%: #005B41 + { percent: 0, color: [173, 3, 23] }, // 0%: #3D0C11 + { percent: 33, color: [245, 81, 81] }, // 33%: #D80032 + { percent: 34, color: [237, 204, 101] }, // 34%: #F2F7A1 + { percent: 66, color: [240, 184, 7] }, // 66%: #E9B824 + { percent: 67, color: [167, 211, 151] }, // 67%: #B0D9B1 + { percent: 100, color: [0, 91, 65] }, // 100%: #005B41 ]; let segment; @@ -18,14 +18,14 @@ export const calculateGradientColor = (percentage) => { let color1 = colorStops[segment].color; let color2 = colorStops[segment + 1].color; - let ratio = (percentage - colorStops[segment].percent) / (colorStops[segment + 1].percent - colorStops[segment].percent); + let ratio = + (percentage - colorStops[segment].percent) / (colorStops[segment + 1].percent - colorStops[segment].percent); let color = [ Math.round(color1[0] + ratio * (color2[0] - color1[0])), Math.round(color1[1] + ratio * (color2[1] - color1[1])), - Math.round(color1[2] + ratio * (color2[2] - color1[2])) + Math.round(color1[2] + ratio * (color2[2] - color1[2])), ]; return `rgb(${color[0]}, ${color[1]}, ${color[2]})`; - -} \ No newline at end of file +}; diff --git a/src/core/utils/isValidJson.js b/src/core/utils/isValidJson.js index 1ba1b86..7214de5 100644 --- a/src/core/utils/isValidJson.js +++ b/src/core/utils/isValidJson.js @@ -1,9 +1,8 @@ export const isValidJson = (value) => { try { - JSON.parse(value) - return true + JSON.parse(value); + return true; } catch (e) { - return false + return false; } - -} \ No newline at end of file +}; diff --git a/src/core/utils/succesHandler.js b/src/core/utils/succesHandler.js index c852f86..ed87200 100644 --- a/src/core/utils/succesHandler.js +++ b/src/core/utils/succesHandler.js @@ -2,7 +2,7 @@ import Notifications from "@/core/components/notifications"; export const successRequest = (pushToastList, dismissToastList, response, t, options) => { if (options.notification && options.success.notification.show) { - dismissToastList(["pending", "warning", "error", "success"]) + dismissToastList(["pending", "warning", "error", "success"]); Notifications(pushToastList, "success", t, response.status); } -} \ No newline at end of file +}; diff --git a/src/core/utils/theme-rtl.jsx b/src/core/utils/theme-rtl.jsx index 33a9ae7..58727bb 100644 --- a/src/core/utils/theme-rtl.jsx +++ b/src/core/utils/theme-rtl.jsx @@ -1,6 +1,6 @@ -import {createTheme} from "@mui/material/styles"; +import { createTheme } from "@mui/material/styles"; import theme from "./theme"; -import {faIR} from "@mui/x-date-pickers/locales"; +import { faIR } from "@mui/x-date-pickers/locales"; const themeRtl = createTheme({ direction: "rtl", diff --git a/src/core/utils/theme.jsx b/src/core/utils/theme.jsx index 672e8a8..7fa2707 100644 --- a/src/core/utils/theme.jsx +++ b/src/core/utils/theme.jsx @@ -1,4 +1,4 @@ -import {colord} from "colord"; +import { colord } from "colord"; const theme = { palette: { diff --git a/src/core/utils/yearPeriodFinder.js b/src/core/utils/yearPeriodFinder.js index 73c01b9..b9f5d41 100644 --- a/src/core/utils/yearPeriodFinder.js +++ b/src/core/utils/yearPeriodFinder.js @@ -2,10 +2,10 @@ import moment from "jalali-moment"; export const periodOfYear = (year) => { const isLeapYear = moment.jIsLeapYear(year); - const firstDayGeorgian = moment.from(`${year}/01/01`, 'fa').format('YYYY-MM-DD'); - const lastDayGeorgian = moment.from(`${year}/12/${isLeapYear ? '30' : '29'}`, 'fa').format('YYYY-MM-DD'); + const firstDayGeorgian = moment.from(`${year}/01/01`, "fa").format("YYYY-MM-DD"); + const lastDayGeorgian = moment.from(`${year}/12/${isLeapYear ? "30" : "29"}`, "fa").format("YYYY-MM-DD"); return { from: firstDayGeorgian, - to: lastDayGeorgian - } -} \ No newline at end of file + to: lastDayGeorgian, + }; +}; diff --git a/src/layouts/AppLayout.jsx b/src/layouts/AppLayout.jsx index 5c01881..179ed7b 100644 --- a/src/layouts/AppLayout.jsx +++ b/src/layouts/AppLayout.jsx @@ -3,18 +3,18 @@ import useLanguage from "@/lib/app/hooks/useLanguage"; import useLoading from "@/lib/app/hooks/useLoading"; import useUser from "@/lib/app/hooks/useUser"; import NextNProgress from "nextjs-progressbar"; -import {useEffect} from "react"; -import {ToastContainer} from "react-toastify"; +import { useEffect } from "react"; +import { ToastContainer } from "react-toastify"; import useDirection from "@/lib/app/hooks/useDirection"; import "react-toastify/dist/ReactToastify.css"; import NetworkComponent from "@/core/components/NetworkComponent"; import GlobalHead from "@/core/components/GlobalHead"; -function AppLayout({children, isBot}) { - const {languageIsReady} = useLanguage(); - const {setLoadingPage} = useLoading(); - const {userChangedLanguage, token, isAuth} = useUser(); - const {directionApp} = useDirection(); +function AppLayout({ children, isBot }) { + const { languageIsReady } = useLanguage(); + const { setLoadingPage } = useLoading(); + const { userChangedLanguage, token, isAuth } = useUser(); + const { directionApp } = useDirection(); useEffect(() => { if (languageIsReady) { @@ -41,25 +41,26 @@ function AppLayout({children, isBot}) { if (!languageIsReady) return; } - return (<> - - - - - - {children} - ); + return ( + <> + + + + + + {children} + + ); } export default AppLayout; diff --git a/src/layouts/CenterLayout.jsx b/src/layouts/CenterLayout.jsx index 1e1b8bf..edfce1d 100644 --- a/src/layouts/CenterLayout.jsx +++ b/src/layouts/CenterLayout.jsx @@ -1,4 +1,4 @@ -import {Fade, Stack} from "@mui/material"; +import { Fade, Stack } from "@mui/material"; const CenterLayout = (props) => { return ( @@ -7,7 +7,7 @@ const CenterLayout = (props) => { alignItems="center" justifyContent="center" spacing={props?.spacing} - sx={{flex: 1, ...props?.sx, py: 3}} + sx={{ flex: 1, ...props?.sx, py: 3 }} > {props.children} diff --git a/src/layouts/DashboardLayout.jsx b/src/layouts/DashboardLayout.jsx index 149f4f4..0d4a0d0 100644 --- a/src/layouts/DashboardLayout.jsx +++ b/src/layouts/DashboardLayout.jsx @@ -4,9 +4,9 @@ import Dashboard from "@/components/layouts/Dashboard"; const DashboardLayout = (props) => { return ( - + ); }; -export default DashboardLayout; \ No newline at end of file +export default DashboardLayout; diff --git a/src/layouts/FullPageLayout.jsx b/src/layouts/FullPageLayout.jsx index d6ed61e..c47af5d 100644 --- a/src/layouts/FullPageLayout.jsx +++ b/src/layouts/FullPageLayout.jsx @@ -1,4 +1,4 @@ -import {Stack} from "@mui/material"; +import { Stack } from "@mui/material"; const FullPageLayout = (props) => { return ( diff --git a/src/layouts/MuiLayout.jsx b/src/layouts/MuiLayout.jsx index 6bfe9c0..34739fd 100644 --- a/src/layouts/MuiLayout.jsx +++ b/src/layouts/MuiLayout.jsx @@ -49,10 +49,11 @@ const MuiLayout = ({ children, isBot }) => { height: "4px", }, }, - " input[type='number']::-webkit-inner-spin-button,input[type='number']::-webkit-outer-spin-button ": { - "-webkit-appearance": "none", - margin: 0 - }, + " input[type='number']::-webkit-inner-spin-button,input[type='number']::-webkit-outer-spin-button ": + { + "-webkit-appearance": "none", + margin: 0, + }, " input[type='number']": { "-moz-appearance": "textfield", }, diff --git a/src/layouts/PrintLayout.jsx b/src/layouts/PrintLayout.jsx index 301a161..a63a96c 100644 --- a/src/layouts/PrintLayout.jsx +++ b/src/layouts/PrintLayout.jsx @@ -4,9 +4,9 @@ import Print from "@/components/layouts/Print"; const PrintLayout = (props) => { return ( - + - ) -} + ); +}; -export default PrintLayout \ No newline at end of file +export default PrintLayout; diff --git a/src/layouts/ScrollableLayout.jsx b/src/layouts/ScrollableLayout.jsx index 583edd7..bc34591 100644 --- a/src/layouts/ScrollableLayout.jsx +++ b/src/layouts/ScrollableLayout.jsx @@ -1,4 +1,4 @@ -import {Box, Fade} from "@mui/material"; +import { Box, Fade } from "@mui/material"; const ScrollableLayout = (props) => { const overflowY = props?.y || "hidden"; diff --git a/src/layouts/index.jsx b/src/layouts/index.jsx index a69d886..8006984 100644 --- a/src/layouts/index.jsx +++ b/src/layouts/index.jsx @@ -1,22 +1,17 @@ import DashboardLayout from "@/layouts/DashboardLayout"; -import {Fragment} from "react"; +import { Fragment } from "react"; import PrintLayout from "@/layouts/PrintLayout"; const layoutList = { DashboardLayout, - PrintLayout -} + PrintLayout, +}; -const Layout = ({layout = {}, children}) => { +const Layout = ({ layout = {}, children }) => { + const Component = layoutList[layout?.name] || Fragment; + const props = layout?.props || {}; - const Component = layoutList[layout?.name] || Fragment - const props = layout?.props || {} + return {children}; +}; - return ( - - {children} - - ) -} - -export default Layout \ No newline at end of file +export default Layout; diff --git a/src/lib/app/contexts/config.jsx b/src/lib/app/contexts/config.jsx index 9505b5f..5af23ca 100644 --- a/src/lib/app/contexts/config.jsx +++ b/src/lib/app/contexts/config.jsx @@ -1,7 +1,7 @@ -import {createContext} from "react"; +import { createContext } from "react"; -export const ConfigContext = createContext() +export const ConfigContext = createContext(); -export const ConfigProvider = ({children, config}) => { - return {children} -} \ No newline at end of file +export const ConfigProvider = ({ children, config }) => { + return {children}; +}; diff --git a/src/lib/app/contexts/language.jsx b/src/lib/app/contexts/language.jsx index 243d7e8..7a7c269 100644 --- a/src/lib/app/contexts/language.jsx +++ b/src/lib/app/contexts/language.jsx @@ -1,12 +1,12 @@ -import {FA_DATATABLE_LOCALIZATION} from "&/locales/fa/datatable"; -import {useRouter} from "next/router"; -import {createContext, useEffect, useState} from "react"; +import { FA_DATATABLE_LOCALIZATION } from "&/locales/fa/datatable"; +import { useRouter } from "next/router"; +import { createContext, useEffect, useState } from "react"; import useUser from "../hooks/useUser"; -import {FA_CHART_LOCALIZATION} from "&/locales/fa/chart"; +import { FA_CHART_LOCALIZATION } from "&/locales/fa/chart"; export const LanguageContext = createContext(); -export const LanguageProvider = ({children}) => { +export const LanguageProvider = ({ children }) => { const router = useRouter(); const languageList = [ { @@ -15,15 +15,13 @@ export const LanguageProvider = ({children}) => { name: "فارسی", fontFamily: `IRANSansFaNum, sans-serif`, tableLocalization: FA_DATATABLE_LOCALIZATION, - chartLocalization: FA_CHART_LOCALIZATION - } + chartLocalization: FA_CHART_LOCALIZATION, + }, ]; - const {user, userChangedLanguage, changeLanguageState} = useUser(); + const { user, userChangedLanguage, changeLanguageState } = useUser(); const [languageIsReady, setLanguageIsReady] = useState(false); const [languageApp, setLanguageApp] = useState(process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE); - const [directionApp, setDirectionApp] = useState( - process.env.NEXT_PUBLIC_DEFAULT_DIRECTION - ); + const [directionApp, setDirectionApp] = useState(process.env.NEXT_PUBLIC_DEFAULT_DIRECTION); useEffect(() => { const lang = localStorage.getItem("_language"); @@ -57,13 +55,9 @@ export const LanguageProvider = ({children}) => { } if (languageApp != router.locale) { - router.replace( - {pathname: router.pathname, query: router.query}, - router.asPath, - { - locale: languageApp, - } - ); + router.replace({ pathname: router.pathname, query: router.query }, router.asPath, { + locale: languageApp, + }); return; } for (const lang of languageList) { diff --git a/src/lib/app/contexts/loading.jsx b/src/lib/app/contexts/loading.jsx index f5b8a47..f5bec10 100644 --- a/src/lib/app/contexts/loading.jsx +++ b/src/lib/app/contexts/loading.jsx @@ -1,13 +1,13 @@ import LoadingHardPage from "@/core/components/LoadingHardPage"; -import {createContext, useState} from "react"; +import { createContext, useState } from "react"; export const LoadingContext = createContext(); -export const LoadingProvider = ({children}) => { +export const LoadingProvider = ({ children }) => { const [loadingPage, setLoadingPage] = useState(false); return ( - - + + {children} ); diff --git a/src/lib/app/contexts/print.jsx b/src/lib/app/contexts/print.jsx index 20fd1dc..9845107 100644 --- a/src/lib/app/contexts/print.jsx +++ b/src/lib/app/contexts/print.jsx @@ -1,4 +1,4 @@ -import {createContext, useReducer} from "react"; +import { createContext, useReducer } from "react"; export const PrintContext = createContext(); @@ -6,19 +6,17 @@ const reducer = (state, action) => { switch (action.type) { case "SET_PRINT_PAGE": return { - ...state, count: action.count + ...state, + count: action.count, }; case "SET_PRINT_TITLE": return { - ...state, title: action.title + ...state, + title: action.title, }; } }; -export const PrintProvider = ({children}) => { - const [printDetails, printDispatch] = useReducer(reducer, {title: '', count: 0}); - return ( - - {children} - - ); -}; \ No newline at end of file +export const PrintProvider = ({ children }) => { + const [printDetails, printDispatch] = useReducer(reducer, { title: "", count: 0 }); + return {children}; +}; diff --git a/src/lib/app/contexts/toast.jsx b/src/lib/app/contexts/toast.jsx index b9d4cbc..dcd4f11 100644 --- a/src/lib/app/contexts/toast.jsx +++ b/src/lib/app/contexts/toast.jsx @@ -1,37 +1,33 @@ -import {createContext, useReducer} from "react"; -import {toast} from "react-toastify"; +import { createContext, useReducer } from "react"; +import { toast } from "react-toastify"; -export const ToastContext = createContext() +export const ToastContext = createContext(); const reducer = (state, action) => { switch (action.type) { case "PUSH": return { ...state, - [action.toast_type]: [...state[action.toast_type], action.toast_id] + [action.toast_type]: [...state[action.toast_type], action.toast_id], }; case "DISMISS": action.toast_type.map((item) => { state[item].map((id) => { toast.dismiss(id); - }) - state[item] = [] + }); + state[item] = []; }); return state; } }; -export const ToastProvider = ({children}) => { +export const ToastProvider = ({ children }) => { const [state, dispatch] = useReducer(reducer, { pending: [], error: [], warning: [], - success: [] + success: [], }); - return ( - - {children} - - ); + return {children}; }; diff --git a/src/lib/app/contexts/user.jsx b/src/lib/app/contexts/user.jsx index 7f5c97c..5dc88b5 100644 --- a/src/lib/app/contexts/user.jsx +++ b/src/lib/app/contexts/user.jsx @@ -1,6 +1,6 @@ -import {GET_USER_ROUTE} from "@/core/data/apiRoutes"; +import { GET_USER_ROUTE } from "@/core/data/apiRoutes"; import axios from "axios"; -import {createContext, useCallback, useEffect, useReducer} from "react"; +import { createContext, useCallback, useEffect, useReducer } from "react"; const initialUser = { isAuth: false, @@ -12,24 +12,24 @@ const initialUser = { const reducer = (state, action) => { switch (action.type) { case "CLEAR_USER": - return {...state, user: {}}; + return { ...state, user: {} }; case "CHANGE_USER": - return {...state, user: action.user}; + return { ...state, user: action.user }; case "CHANGE_USER_LANGUAGE": return { ...state, - user: {...state.user, user_language: action.language}, + user: { ...state.user, user_language: action.language }, }; case "CHANGE_AUTH_STATE": - return {...state, isAuth: action.isAuth}; + return { ...state, isAuth: action.isAuth }; case "CHANGE_LANGUAGE_STATE": - return {...state, userChangedLanguage: action.userChangedLanguage}; + return { ...state, userChangedLanguage: action.userChangedLanguage }; case "CLEAR_TOKEN": localStorage.removeItem("_token"); - return {...state, token: null}; + return { ...state, token: null }; case "SET_TOKEN": localStorage.setItem("_token", action.token); - return {...state, token: action.token}; + return { ...state, token: action.token }; default: return state; } @@ -37,55 +37,54 @@ const reducer = (state, action) => { export const UserContext = createContext(); -export const UserProvider = ({children}) => { +export const UserProvider = ({ children }) => { const [state, dispatch] = useReducer(reducer, initialUser); const clearUser = useCallback(() => { - dispatch({type: "CLEAR_USER"}); + dispatch({ type: "CLEAR_USER" }); }, []); const changeUser = useCallback((user) => { - dispatch({type: "CHANGE_USER", user}); + dispatch({ type: "CHANGE_USER", user }); }, []); const changeUserLanguage = useCallback(/* use in multi language app */); const changeAuthState = useCallback((isAuth) => { - dispatch({type: "CHANGE_AUTH_STATE", isAuth}); + dispatch({ type: "CHANGE_AUTH_STATE", isAuth }); }, []); const changeLanguageState = useCallback((userChangedLanguage) => { - dispatch({type: "CHANGE_LANGUAGE_STATE", userChangedLanguage}); + dispatch({ type: "CHANGE_LANGUAGE_STATE", userChangedLanguage }); }, []); const clearToken = useCallback(() => { - dispatch({type: "CLEAR_TOKEN"}); + dispatch({ type: "CLEAR_TOKEN" }); }, []); const setToken = useCallback((token) => { - dispatch({type: "SET_TOKEN", token}); + dispatch({ type: "SET_TOKEN", token }); }, []); const getUser = useCallback( - (callback = () => { - }) => { + (callback = () => {}) => { axios .get(GET_USER_ROUTE, { - headers: {authorization: `Bearer ${state.token}`}, + headers: { authorization: `Bearer ${state.token}` }, }) - .then(({data}) => { + .then(({ data }) => { if (typeof callback === "function") callback(data); }) - .catch(error => { - if (error.response.status === 401) clearToken() - }) + .catch((error) => { + if (error.response.status === 401) clearToken(); + }); }, [state.token] ); useEffect(() => { const localToken = localStorage.getItem("_token"); - if (localToken) dispatch({type: "SET_TOKEN", token: localToken}); + if (localToken) dispatch({ type: "SET_TOKEN", token: localToken }); }, []); useEffect(() => { diff --git a/src/lib/app/hooks/useChart.jsx b/src/lib/app/hooks/useChart.jsx index 5aac9e2..3fa0676 100644 --- a/src/lib/app/hooks/useChart.jsx +++ b/src/lib/app/hooks/useChart.jsx @@ -1,40 +1,39 @@ import useRequest from "@/lib/app/hooks/useRequest"; import useSWR from "swr"; -import {useState} from "react"; +import { useState } from "react"; const useChart = (chart_url) => { - const requestServer = useRequest({auth: true, notification: false}) + const requestServer = useRequest({ auth: true, notification: false }); const [filterOption, setFilterOption] = useState([]); - const queryString = filterOption.length !== 0 - ? `?${filterOption.map((option) => `${option.key}=${option.value}`).join('&')}` - : ''; + const queryString = + filterOption.length !== 0 ? `?${filterOption.map((option) => `${option.key}=${option.value}`).join("&")}` : ""; //swr config const fetcher = (...args) => { - return requestServer(args, 'get').then(({data}) => { - return data.data; - }).catch(() => { - }) + return requestServer(args, "get") + .then(({ data }) => { + return data.data; + }) + .catch(() => {}); }; - const { - data, - isValidating, - mutate - } = useSWR(filterOption.length !== 0 ? `${chart_url}${queryString}` : chart_url, fetcher, { - revalidateIfStale: true, - revalidateOnFocus: false, - revalidateOnReconnect: false, - keepPreviousData: true - }); - + const { data, isValidating, mutate } = useSWR( + filterOption.length !== 0 ? `${chart_url}${queryString}` : chart_url, + fetcher, + { + revalidateIfStale: true, + revalidateOnFocus: false, + revalidateOnReconnect: false, + keepPreviousData: true, + } + ); return { reportList: data, isLoadingReportList: isValidating, errorReportList: !data, setFilterOption: setFilterOption, - mutate: mutate - } + mutate: mutate, + }; }; -export default useChart; \ No newline at end of file +export default useChart; diff --git a/src/lib/app/hooks/useConfig.jsx b/src/lib/app/hooks/useConfig.jsx index 42d5a78..6737519 100644 --- a/src/lib/app/hooks/useConfig.jsx +++ b/src/lib/app/hooks/useConfig.jsx @@ -1,5 +1,5 @@ -import {useContext} from "react"; -import {ConfigContext} from "@/lib/app/contexts/config"; +import { useContext } from "react"; +import { ConfigContext } from "@/lib/app/contexts/config"; export const useConfig = () => { const context = useContext(ConfigContext); @@ -8,5 +8,5 @@ export const useConfig = () => { throw new Error("useConfig must be used within a ConfigProvider"); } - return {config: context.config}; + return { config: context.config }; }; diff --git a/src/lib/app/hooks/useDirection.jsx b/src/lib/app/hooks/useDirection.jsx index b2e01fe..2d92afe 100644 --- a/src/lib/app/hooks/useDirection.jsx +++ b/src/lib/app/hooks/useDirection.jsx @@ -1,10 +1,10 @@ -import {useContext} from "react"; -import {LanguageContext} from "../contexts/language"; +import { useContext } from "react"; +import { LanguageContext } from "../contexts/language"; const useDirection = () => { - const {directionApp} = useContext(LanguageContext); + const { directionApp } = useContext(LanguageContext); - return {directionApp}; + return { directionApp }; }; export default useDirection; diff --git a/src/lib/app/hooks/useLanguage.jsx b/src/lib/app/hooks/useLanguage.jsx index d663835..2d93702 100644 --- a/src/lib/app/hooks/useLanguage.jsx +++ b/src/lib/app/hooks/useLanguage.jsx @@ -1,16 +1,11 @@ -import {useContext} from "react"; -import {LanguageContext} from "../contexts/language"; +import { useContext } from "react"; +import { LanguageContext } from "../contexts/language"; import useUser from "./useUser"; const useLanguage = () => { - const {isAuth, changeUserLanguage} = useUser(); - const { - languageApp, - setLanguageApp, - languageIsReady, - setLanguageIsReady, - languageList, - } = useContext(LanguageContext); + const { isAuth, changeUserLanguage } = useUser(); + const { languageApp, setLanguageApp, languageIsReady, setLanguageIsReady, languageList } = + useContext(LanguageContext); const changeLanguage = (lang) => { if (lang == languageApp) return; @@ -22,7 +17,7 @@ const useLanguage = () => { } }; - return {languageApp, changeLanguage, languageIsReady, languageList}; + return { languageApp, changeLanguage, languageIsReady, languageList }; }; export default useLanguage; diff --git a/src/lib/app/hooks/useLoading.jsx b/src/lib/app/hooks/useLoading.jsx index a691bd7..7193cf3 100644 --- a/src/lib/app/hooks/useLoading.jsx +++ b/src/lib/app/hooks/useLoading.jsx @@ -1,10 +1,10 @@ -import {useContext} from "react"; -import {LoadingContext} from "../contexts/loading"; +import { useContext } from "react"; +import { LoadingContext } from "../contexts/loading"; const useLoading = () => { - const {setLoadingPage} = useContext(LoadingContext); + const { setLoadingPage } = useContext(LoadingContext); - return {setLoadingPage}; + return { setLoadingPage }; }; export default useLoading; diff --git a/src/lib/app/hooks/useNetwork.jsx b/src/lib/app/hooks/useNetwork.jsx index 9c436a5..184f238 100644 --- a/src/lib/app/hooks/useNetwork.jsx +++ b/src/lib/app/hooks/useNetwork.jsx @@ -1,4 +1,4 @@ -import {useEffect, useState} from "react"; +import { useEffect, useState } from "react"; function useNetwork() { const [state, setState] = useState(() => { @@ -31,4 +31,4 @@ function useNetwork() { return state; } -export default useNetwork; \ No newline at end of file +export default useNetwork; diff --git a/src/lib/app/hooks/useNotification.jsx b/src/lib/app/hooks/useNotification.jsx index 8685227..db552ad 100644 --- a/src/lib/app/hooks/useNotification.jsx +++ b/src/lib/app/hooks/useNotification.jsx @@ -1,27 +1,29 @@ -import useSWR from 'swr' -import {GET_SIDEBAR_NOTIFICATION} from "@/core/data/apiRoutes"; +import useSWR from "swr"; +import { GET_SIDEBAR_NOTIFICATION } from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; const GLOBAL_HAS_VALUE = process.env.NEXT_PUBLIC_HAS_VALUE; const hasPermissionsValue = GLOBAL_HAS_VALUE ? JSON.parse(GLOBAL_HAS_VALUE) : []; const isNotificationEnabled = hasPermissionsValue.includes("NEXT_PUBLIC_HAS_NOTIFICATION"); const useNotification = () => { - - const requestServer = useRequest({auth: true, notification: false}) + const requestServer = useRequest({ auth: true, notification: false }); //swr config const fetcher = (...args) => { - return requestServer(args, 'get').then((response) => { - return response.data.data; - }).catch(() => { - }) + return requestServer(args, "get") + .then((response) => { + return response.data.data; + }) + .catch(() => {}); }; - const {data, mutate} = useSWR( isNotificationEnabled ? GET_SIDEBAR_NOTIFICATION : '', fetcher , {keepPreviousData:true}) - const notification_count = data + const { data, mutate } = useSWR(isNotificationEnabled ? GET_SIDEBAR_NOTIFICATION : "", fetcher, { + keepPreviousData: true, + }); + const notification_count = data; //swr config // render data - return {notification_count, update_notification: mutate} -} -export default useNotification \ No newline at end of file + return { notification_count, update_notification: mutate }; +}; +export default useNotification; diff --git a/src/lib/app/hooks/usePermissions.jsx b/src/lib/app/hooks/usePermissions.jsx index 2e6fff5..8cdbac9 100644 --- a/src/lib/app/hooks/usePermissions.jsx +++ b/src/lib/app/hooks/usePermissions.jsx @@ -1,26 +1,27 @@ import useRequest from "@/lib/app/hooks/useRequest"; import useSWR from "swr"; -import {GET_PERMISSIONS_LIST} from "@/core/data/apiRoutes"; +import { GET_PERMISSIONS_LIST } from "@/core/data/apiRoutes"; const usePermissions = () => { - const requestServer = useRequest({auth: true, notification: false}) + const requestServer = useRequest({ auth: true, notification: false }); const fetcher = (...args) => { - return requestServer(args, 'get').then((response) => { - return response.data.data; - }).catch(() => { - }) + return requestServer(args, "get") + .then((response) => { + return response.data.data; + }) + .catch(() => {}); }; - const {data, isLoading} = useSWR(GET_PERMISSIONS_LIST, fetcher, { + const { data, isLoading } = useSWR(GET_PERMISSIONS_LIST, fetcher, { revalidateIfStale: false, revalidateOnFocus: false, revalidateOnReconnect: false, - keepPreviousData : true - }) - const permissions_list = data + keepPreviousData: true, + }); + const permissions_list = data; //swr config // render data - return {permissions_list, isLoading} -} -export default usePermissions; \ No newline at end of file + return { permissions_list, isLoading }; +}; +export default usePermissions; diff --git a/src/lib/app/hooks/usePrint.jsx b/src/lib/app/hooks/usePrint.jsx index 35a1017..cbe0237 100644 --- a/src/lib/app/hooks/usePrint.jsx +++ b/src/lib/app/hooks/usePrint.jsx @@ -1,18 +1,18 @@ -import {useContext} from "react"; -import {PrintContext} from "@/lib/app/contexts/print"; +import { useContext } from "react"; +import { PrintContext } from "@/lib/app/contexts/print"; const usePrint = () => { - const {printDetails, printDispatch} = useContext(PrintContext); + const { printDetails, printDispatch } = useContext(PrintContext); const setPrintPage = (count) => { - printDispatch({type: 'SET_PRINT_PAGE', count}) - } + printDispatch({ type: "SET_PRINT_PAGE", count }); + }; const setPrintTitle = (title) => { - printDispatch({type: 'SET_PRINT_TITLE', title}) - } + printDispatch({ type: "SET_PRINT_TITLE", title }); + }; - return {printDetails, setPrintPage, setPrintTitle} + return { printDetails, setPrintPage, setPrintTitle }; }; -export default usePrint; \ No newline at end of file +export default usePrint; diff --git a/src/lib/app/hooks/useProvince.jsx b/src/lib/app/hooks/useProvince.jsx index 2bc8c6b..f4bf426 100644 --- a/src/lib/app/hooks/useProvince.jsx +++ b/src/lib/app/hooks/useProvince.jsx @@ -1,30 +1,31 @@ -import {GET_PROVINCE_LIST} from "@/core/data/apiRoutes"; +import { GET_PROVINCE_LIST } from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; import useSWR from "swr"; const useProvince = () => { - const requestServer = useRequest({auth: true, notification: false}) + const requestServer = useRequest({ auth: true, notification: false }); //swr config const fetcher = (...args) => { - return requestServer(args, 'get').then(({data}) => { - return data.data; - }).catch(() => { - }) + return requestServer(args, "get") + .then(({ data }) => { + return data.data; + }) + .catch(() => {}); }; - const {data, isLoading} = useSWR(GET_PROVINCE_LIST, fetcher, { + const { data, isLoading } = useSWR(GET_PROVINCE_LIST, fetcher, { revalidateIfStale: false, revalidateOnFocus: false, revalidateOnReconnect: false, - keepPreviousData: true + keepPreviousData: true, }); return { provinceList: data, isLoadingProvinceList: isLoading, - errorProvinceList: !data - } + errorProvinceList: !data, + }; }; -export default useProvince; \ No newline at end of file +export default useProvince; diff --git a/src/lib/app/hooks/useRequest.jsx b/src/lib/app/hooks/useRequest.jsx index 9421c61..78ac63e 100644 --- a/src/lib/app/hooks/useRequest.jsx +++ b/src/lib/app/hooks/useRequest.jsx @@ -1,8 +1,8 @@ import axios from "axios"; -import {successRequest} from "@/core/utils/succesHandler"; -import {useTranslations} from "next-intl"; +import { successRequest } from "@/core/utils/succesHandler"; +import { useTranslations } from "next-intl"; import useUser from "@/lib/app/hooks/useUser"; -import {errorRequest, errorResponse, errorSetting} from "@/core/utils/errorHandler"; +import { errorRequest, errorResponse, errorSetting } from "@/core/utils/errorHandler"; import useNetwork from "@/lib/app/hooks/useNetwork"; import Notifications from "@/core/components/notifications"; import useToast from "@/lib/app/hooks/useToast"; @@ -11,7 +11,7 @@ const defaultOptions = { auth: false, data: {}, requestOptions: { - headers: {} + headers: {}, }, notification: true, pending: true, @@ -25,26 +25,28 @@ const defaultOptions = { show: true, }, }, -} +}; const useRequest = (initOptions) => { - const network = useNetwork() - const t = useTranslations() - const {token, clearToken} = useUser() - const {pushToastList, dismissToastList} = useToast(); - let _options = {...defaultOptions, ...initOptions} + const network = useNetwork(); + const t = useTranslations(); + const { token, clearToken } = useUser(); + const { pushToastList, dismissToastList } = useToast(); + let _options = { ...defaultOptions, ...initOptions }; - function requestServer(url = '', method = 'get', options) { - _options = {..._options, ...options} - if (_options.auth) _options = { - ..._options, requestOptions: { - ..._options.requestOptions, - headers: {..._options.requestOptions.headers, authorization: `Bearer ${token}`} - } - } + function requestServer(url = "", method = "get", options) { + _options = { ..._options, ...options }; + if (_options.auth) + _options = { + ..._options, + requestOptions: { + ..._options.requestOptions, + headers: { ..._options.requestOptions.headers, authorization: `Bearer ${token}` }, + }, + }; return new Promise((resolve, reject) => { if (!network.online) { - reject() - return + reject(); + return; } if (_options.notification && _options.failed.notification.show && _options.pending) { dismissToastList(["pending", "warning", "error", "success"]); @@ -52,26 +54,36 @@ const useRequest = (initOptions) => { } axios({ - url: url, method: method, data: _options.data, ..._options.requestOptions + url: url, + method: method, + data: _options.data, + ..._options.requestOptions, }) - .then(response => { - successRequest(pushToastList, dismissToastList, response, t, _options) - resolve(response) + .then((response) => { + successRequest(pushToastList, dismissToastList, response, t, _options); + resolve(response); }) - .catch(error => { + .catch((error) => { if (error.response) { - errorResponse(pushToastList, dismissToastList, error.response, clearToken, t, _options.notification && _options.failed.notification.show) + errorResponse( + pushToastList, + dismissToastList, + error.response, + clearToken, + t, + _options.notification && _options.failed.notification.show + ); } else if (error.request) { - errorRequest(dismissToastList, t, _options.notification && _options.failed.notification.show) + errorRequest(dismissToastList, t, _options.notification && _options.failed.notification.show); } else { - errorSetting(dismissToastList, t, _options.notification && _options.failed.notification.show) + errorSetting(dismissToastList, t, _options.notification && _options.failed.notification.show); } - reject(error) - }) + reject(error); + }); }); } - return requestServer -} + return requestServer; +}; -export default useRequest \ No newline at end of file +export default useRequest; diff --git a/src/lib/app/hooks/useRole.jsx b/src/lib/app/hooks/useRole.jsx index b4c231c..4fdd3af 100644 --- a/src/lib/app/hooks/useRole.jsx +++ b/src/lib/app/hooks/useRole.jsx @@ -1,30 +1,31 @@ -import {GET_ROLE_LIST} from "@/core/data/apiRoutes"; +import { GET_ROLE_LIST } from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; import useSWR from "swr"; const useRole = () => { - const requestServer = useRequest({auth: true, notification: false}) + const requestServer = useRequest({ auth: true, notification: false }); //swr config const fetcher = (...args) => { - return requestServer(args, 'get').then(({data}) => { - return data.data; - }).catch(() => { - }) + return requestServer(args, "get") + .then(({ data }) => { + return data.data; + }) + .catch(() => {}); }; - const {data, isLoading} = useSWR(GET_ROLE_LIST, fetcher, { + const { data, isLoading } = useSWR(GET_ROLE_LIST, fetcher, { revalidateIfStale: false, revalidateOnFocus: false, revalidateOnReconnect: false, - keepPreviousData: true + keepPreviousData: true, }); return { roleList: data, isLoadingRoleList: isLoading, - errorRoleList: !data - } + errorRoleList: !data, + }; }; -export default useRole; \ No newline at end of file +export default useRole; diff --git a/src/lib/app/hooks/useToast.jsx b/src/lib/app/hooks/useToast.jsx index 5e1d5b4..daa0493 100644 --- a/src/lib/app/hooks/useToast.jsx +++ b/src/lib/app/hooks/useToast.jsx @@ -1,21 +1,21 @@ -import {useContext} from "react"; -import {ToastContext} from "@/lib/app/contexts/toast"; +import { useContext } from "react"; +import { ToastContext } from "@/lib/app/contexts/toast"; const useToast = () => { - const {dispatch} = useContext(ToastContext); + const { dispatch } = useContext(ToastContext); const pushToastList = (toast_type, toast_id) => { - dispatch({type: "PUSH", toast_type, toast_id}); + dispatch({ type: "PUSH", toast_type, toast_id }); }; const dismissToastList = (toast_type) => { - dispatch({type: "DISMISS", toast_type}); + dispatch({ type: "DISMISS", toast_type }); }; return { pushToastList, - dismissToastList - } + dismissToastList, + }; }; -export default useToast; \ No newline at end of file +export default useToast; diff --git a/src/lib/app/hooks/useUser.jsx b/src/lib/app/hooks/useUser.jsx index b0bbc1a..94b8041 100644 --- a/src/lib/app/hooks/useUser.jsx +++ b/src/lib/app/hooks/useUser.jsx @@ -1,5 +1,5 @@ -import {useContext} from "react"; -import {UserContext} from "../contexts/user"; +import { useContext } from "react"; +import { UserContext } from "../contexts/user"; const useUser = () => { const { diff --git a/src/lib/prefetchDataTable/hooks/useLoanStateNavgan.jsx b/src/lib/prefetchDataTable/hooks/useLoanStateNavgan.jsx index cf3453b..c6d4dec 100644 --- a/src/lib/prefetchDataTable/hooks/useLoanStateNavgan.jsx +++ b/src/lib/prefetchDataTable/hooks/useLoanStateNavgan.jsx @@ -1,27 +1,28 @@ -import useSWR from 'swr' -import {GET_LOAN_STATE_NAVGAN} from "@/core/data/apiRoutes"; +import useSWR from "swr"; +import { GET_LOAN_STATE_NAVGAN } from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; const useLoanStateNavgan = () => { - const requestServer = useRequest({auth: true, notification: false}) + const requestServer = useRequest({ auth: true, notification: false }); //swr config const fetcher = (...args) => { - return requestServer(args, 'get').then((response) => { - return response.data.data; - }).catch(() => { - }) + return requestServer(args, "get") + .then((response) => { + return response.data.data; + }) + .catch(() => {}); }; - const {data} = useSWR(GET_LOAN_STATE_NAVGAN, fetcher, { + const { data } = useSWR(GET_LOAN_STATE_NAVGAN, fetcher, { revalidateIfStale: false, revalidateOnFocus: false, - revalidateOnReconnect: false - }) - const loan_state_navgan = data + revalidateOnReconnect: false, + }); + const loan_state_navgan = data; //swr config // render data - return {loan_state_navgan} -} -export default useLoanStateNavgan \ No newline at end of file + return { loan_state_navgan }; +}; +export default useLoanStateNavgan; diff --git a/src/lib/prefetchDataTable/hooks/useLoanStateRefahi.jsx b/src/lib/prefetchDataTable/hooks/useLoanStateRefahi.jsx index 598ac72..5cb199d 100644 --- a/src/lib/prefetchDataTable/hooks/useLoanStateRefahi.jsx +++ b/src/lib/prefetchDataTable/hooks/useLoanStateRefahi.jsx @@ -1,27 +1,28 @@ -import useSWR from 'swr' -import {GET_LOAN_STATE_REFAHI} from "@/core/data/apiRoutes"; +import useSWR from "swr"; +import { GET_LOAN_STATE_REFAHI } from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; const useLoanStateRefahi = () => { - const requestServer = useRequest({auth: true, notification: false}) + const requestServer = useRequest({ auth: true, notification: false }); //swr config const fetcher = (...args) => { - return requestServer(args, 'get').then((response) => { - return response.data.data; - }).catch(() => { - }) + return requestServer(args, "get") + .then((response) => { + return response.data.data; + }) + .catch(() => {}); }; - const {data} = useSWR(GET_LOAN_STATE_REFAHI, fetcher, { + const { data } = useSWR(GET_LOAN_STATE_REFAHI, fetcher, { revalidateIfStale: false, revalidateOnFocus: false, - revalidateOnReconnect: false - }) - const loan_state_refahi = data + revalidateOnReconnect: false, + }); + const loan_state_refahi = data; //swr config // render data - return {loan_state_refahi} -} -export default useLoanStateRefahi \ No newline at end of file + return { loan_state_refahi }; +}; +export default useLoanStateRefahi; diff --git a/src/middlewares/RolePermission.jsx b/src/middlewares/RolePermission.jsx index c546220..81a46f9 100644 --- a/src/middlewares/RolePermission.jsx +++ b/src/middlewares/RolePermission.jsx @@ -1,14 +1,15 @@ import useUser from "@/lib/app/hooks/useUser"; import RolePermissionComponent from "@/core/components/Middleware/RolePermissionComponent"; -const RolePermissionMiddleware = ({children, requiredPermissions = []}) => { - const {user} = useUser(); +const RolePermissionMiddleware = ({ children, requiredPermissions = [] }) => { + const { user } = useUser(); - const hasPermission = requiredPermissions.length === 0 ? true : requiredPermissions.some((permission) => - user?.permissions?.includes(permission) - ); + const hasPermission = + requiredPermissions.length === 0 + ? true + : requiredPermissions.some((permission) => user?.permissions?.includes(permission)); - return !hasPermission ? : <>{children}; + return !hasPermission ? : <>{children}; }; export default RolePermissionMiddleware; diff --git a/src/middlewares/WithAuth.jsx b/src/middlewares/WithAuth.jsx index 4f55660..beb4bad 100644 --- a/src/middlewares/WithAuth.jsx +++ b/src/middlewares/WithAuth.jsx @@ -1,8 +1,8 @@ import useUser from "@/lib/app/hooks/useUser"; import WithAuthComponent from "@/core/components/Middleware/WithAuthComponent"; -const WithAuthMiddleware = ({children}) => { - const {isAuth} = useUser(); +const WithAuthMiddleware = ({ children }) => { + const { isAuth } = useUser(); return isAuth ? <>{children} : ; }; diff --git a/src/middlewares/WithoutAuth.jsx b/src/middlewares/WithoutAuth.jsx index 80169c8..c8fb014 100644 --- a/src/middlewares/WithoutAuth.jsx +++ b/src/middlewares/WithoutAuth.jsx @@ -1,11 +1,10 @@ import useUser from "@/lib/app/hooks/useUser"; -import {useRouter} from "next/router"; -import {useEffect} from "react"; +import { useRouter } from "next/router"; +import { useEffect } from "react"; import WithoutAuthComponent from "@/core/components/Middleware/WithoutAuthComponent"; -const WithoutAuthMiddleware = ({children}) => { - - const {isAuth} = useUser(); +const WithoutAuthMiddleware = ({ children }) => { + const { isAuth } = useUser(); const router = useRouter(); const backUrlDecodedPath = router.query?.back_url; @@ -13,11 +12,7 @@ const WithoutAuthMiddleware = ({children}) => { useEffect(() => { if (!isAuth) return; const timer = setTimeout(() => { - router.replace( - backUrlDecodedPath - ? decodeURIComponent(backUrlDecodedPath) - : "/dashboard" - ); + router.replace(backUrlDecodedPath ? decodeURIComponent(backUrlDecodedPath) : "/dashboard"); }, 2000); return () => { @@ -25,11 +20,7 @@ const WithoutAuthMiddleware = ({children}) => { }; }, [isAuth]); - return isAuth ? ( - - ) : ( - <>{children} - ); + return isAuth ? : <>{children}; }; export default WithoutAuthMiddleware; diff --git a/src/pages/403.jsx b/src/pages/403.jsx index 15ba915..cb203d9 100644 --- a/src/pages/403.jsx +++ b/src/pages/403.jsx @@ -1,24 +1,24 @@ -import {useEffect, useState} from "react"; -import {useRouter} from "next/router"; -import {NextIntlProvider} from "next-intl"; +import { useEffect, useState } from "react"; +import { useRouter } from "next/router"; +import { NextIntlProvider } from "next-intl"; import UnAuthorizedComponent from "@/components/errors/403"; export default function Custom404() { - const router = useRouter() - const [messages, setMessages] = useState(null) + const router = useRouter(); + const [messages, setMessages] = useState(null); useEffect(() => { const fetch = async () => { - const tempMessages = (await import(`&/locales/${router.locale}/app.json`)).default - setMessages(tempMessages) - } - fetch() + const tempMessages = (await import(`&/locales/${router.locale}/app.json`)).default; + setMessages(tempMessages); + }; + fetch(); }, []); - if (!messages) return + if (!messages) return; return ( - + ); } diff --git a/src/pages/404.jsx b/src/pages/404.jsx index 26de038..b12bff3 100644 --- a/src/pages/404.jsx +++ b/src/pages/404.jsx @@ -1,25 +1,24 @@ -import {useEffect, useState} from "react"; -import {useRouter} from "next/router"; -import {NextIntlProvider} from "next-intl"; +import { useEffect, useState } from "react"; +import { useRouter } from "next/router"; +import { NextIntlProvider } from "next-intl"; import NotFoundComponent from "@/components/errors/404"; export default function Custom404() { - const router = useRouter() - const [messages, setMessages] = useState(null) + const router = useRouter(); + const [messages, setMessages] = useState(null); useEffect(() => { - const fetch = async () => { - const tempMessages = (await import(`&/locales/${router.locale}/app.json`)).default - setMessages(tempMessages) - } - fetch() + const tempMessages = (await import(`&/locales/${router.locale}/app.json`)).default; + setMessages(tempMessages); + }; + fetch(); }, []); - if (!messages) return + if (!messages) return; return ( - + ); } diff --git a/src/pages/500.jsx b/src/pages/500.jsx index 4b85bc2..defd0cb 100644 --- a/src/pages/500.jsx +++ b/src/pages/500.jsx @@ -1,24 +1,24 @@ -import {useEffect, useState} from "react"; -import {useRouter} from "next/router"; -import {NextIntlProvider} from "next-intl"; +import { useEffect, useState } from "react"; +import { useRouter } from "next/router"; +import { NextIntlProvider } from "next-intl"; import ServerErrorComponent from "@/components/errors/500"; export default function Custom500() { - const router = useRouter() - const [messages, setMessages] = useState(null) + const router = useRouter(); + const [messages, setMessages] = useState(null); useEffect(() => { const fetch = async () => { - const tempMessages = (await import(`&/locales/${router.locale}/app.json`)).default - setMessages(tempMessages) - } - fetch() + const tempMessages = (await import(`&/locales/${router.locale}/app.json`)).default; + setMessages(tempMessages); + }; + fetch(); }, []); - if (!messages) return + if (!messages) return; return ( - + ); } diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx index e572fe6..36b2dda 100644 --- a/src/pages/_app.jsx +++ b/src/pages/_app.jsx @@ -1,25 +1,25 @@ import "&/fontiran.scss"; import AppLayout from "@/layouts/AppLayout"; import MuiLayout from "@/layouts/MuiLayout"; -import {LanguageProvider} from "@/lib/app/contexts/language"; -import {LoadingProvider} from "@/lib/app/contexts/loading"; -import {UserProvider} from "@/lib/app/contexts/user"; +import { LanguageProvider } from "@/lib/app/contexts/language"; +import { LoadingProvider } from "@/lib/app/contexts/loading"; +import { UserProvider } from "@/lib/app/contexts/user"; import "moment/locale/fa"; -import {NextIntlProvider} from "next-intl"; +import { NextIntlProvider } from "next-intl"; import TitlePage from "@/core/components/TitlePage"; import Layout from "@/layouts"; -import {ToastProvider} from "@/lib/app/contexts/toast"; -import {PrintProvider} from "@/lib/app/contexts/print"; +import { ToastProvider } from "@/lib/app/contexts/toast"; +import { PrintProvider } from "@/lib/app/contexts/print"; import ConfigApp from "@/core/components/Config"; -const App = ({Component, pageProps}) => { - - return ( +const App = ({ Component, pageProps }) => { + return ( + - {pageProps.messages ? : ''} + {pageProps.messages ? : ""} @@ -35,7 +35,8 @@ const App = ({Component, pageProps}) => { - ); + + ); }; export default App; diff --git a/src/pages/_document.jsx b/src/pages/_document.jsx index 474e29b..bd0c9f4 100644 --- a/src/pages/_document.jsx +++ b/src/pages/_document.jsx @@ -1,23 +1,23 @@ -import {createEmotionCacheRtl} from "@/core/utils/createEmotionCache"; +import { createEmotionCacheRtl } from "@/core/utils/createEmotionCache"; import theme from "@/core/utils/theme"; import createEmotionServer from "@emotion/server/create-instance"; -import Document, {Head, Html, Main, NextScript} from "next/document"; +import Document, { Head, Html, Main, NextScript } from "next/document"; export default function MyDocument(props) { - const {emotionStyleTags} = props; + const { emotionStyleTags } = props; return ( - - - - + + + + {emotionStyleTags} -
- +
+ ); @@ -32,7 +32,7 @@ MyDocument.getInitialProps = async (ctx) => { break; } - const {extractCriticalToChunks} = createEmotionServer(cache); + const { extractCriticalToChunks } = createEmotionServer(cache); ctx.renderPage = () => originalRenderPage({ @@ -50,7 +50,7 @@ MyDocument.getInitialProps = async (ctx) => { data-emotion={`${style.key} ${style.ids.join(" ")}`} key={style.key} // eslint-disable-next-line react/no-danger - dangerouslySetInnerHTML={{__html: style.css}} + dangerouslySetInnerHTML={{ __html: style.css }} /> )); diff --git a/src/pages/dashboard/admin-setting/index.jsx b/src/pages/dashboard/admin-setting/index.jsx index 70dc722..d778c6e 100644 --- a/src/pages/dashboard/admin-setting/index.jsx +++ b/src/pages/dashboard/admin-setting/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardAdminSettingComponent from "@/components/dashboard/admin-setting"; export default function AdminSetting() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.admin_setting", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["view_settings"]}} + layout: { name: "DashboardLayout", props: { permissions: ["view_settings"] } }, }, }; } diff --git a/src/pages/dashboard/bank-management/index.jsx b/src/pages/dashboard/bank-management/index.jsx index 08ed24e..429f265 100644 --- a/src/pages/dashboard/bank-management/index.jsx +++ b/src/pages/dashboard/bank-management/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardBankManagementComponent from "@/components/dashboard/bank-management"; export default function BankManagement() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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: ["tracking_bank_loans"]}} + layout: { name: "DashboardLayout", props: { permissions: ["tracking_bank_loans"] } }, }, }; } diff --git a/src/pages/dashboard/change-password/index.jsx b/src/pages/dashboard/change-password/index.jsx index ef75fb7..7b83837 100644 --- a/src/pages/dashboard/change-password/index.jsx +++ b/src/pages/dashboard/change-password/index.jsx @@ -1,21 +1,19 @@ import DashboardChangePasswordComponent from "@/components/dashboard/change-password"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; export default function LoanFollowUp() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.change_password", isBot, locale, - layout: {name: 'DashboardLayout'} + layout: { name: "DashboardLayout" }, }, }; } diff --git a/src/pages/dashboard/commercial-chief/index.jsx b/src/pages/dashboard/commercial-chief/index.jsx index 1ec5fbf..5d5eec7 100644 --- a/src/pages/dashboard/commercial-chief/index.jsx +++ b/src/pages/dashboard/commercial-chief/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardCommercialChiefComponent from "@/components/dashboard/commercial-chief"; export default function CommercialChief() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.commercial_chief_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_commercial_refahi"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_commercial_refahi"] } }, }, }; } diff --git a/src/pages/dashboard/development-assistant/index.jsx b/src/pages/dashboard/development-assistant/index.jsx index 346a340..6c8aa33 100644 --- a/src/pages/dashboard/development-assistant/index.jsx +++ b/src/pages/dashboard/development-assistant/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardDevelopmentAssistantComponent from "@/components/dashboard/development-assistant"; export default function DevelopmentAssistant() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.development_assistant_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_development_refahi"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_development_refahi"] } }, }, }; } diff --git a/src/pages/dashboard/edit-profile/index.jsx b/src/pages/dashboard/edit-profile/index.jsx index 032a607..5fb010e 100644 --- a/src/pages/dashboard/edit-profile/index.jsx +++ b/src/pages/dashboard/edit-profile/index.jsx @@ -1,21 +1,19 @@ import DashboardEditProfile from "@/components/dashboard/edit-profile"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; export default function LoanFollowUp() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.edit_profile", isBot, locale, - layout: {name: 'DashboardLayout'} + layout: { name: "DashboardLayout" }, }, }; } diff --git a/src/pages/dashboard/expert-management/index.jsx b/src/pages/dashboard/expert-management/index.jsx index 5f1c29a..916e1ca 100644 --- a/src/pages/dashboard/expert-management/index.jsx +++ b/src/pages/dashboard/expert-management/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardExpertManagementComponent from "@/components/dashboard/expert-management"; export default function ExpertManagement() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.expert_management", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_experts"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_experts"] } }, }, }; } diff --git a/src/pages/dashboard/index.jsx b/src/pages/dashboard/index.jsx index a736442..40294a1 100644 --- a/src/pages/dashboard/index.jsx +++ b/src/pages/dashboard/index.jsx @@ -1,28 +1,26 @@ import DashboardFirstComponent from "@/components/dashboard/first"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import useUser from "@/lib/app/hooks/useUser"; export default function Dashboard() { - const {user} = useUser(); + const { user } = useUser(); - const hasPermission = user?.permissions?.includes("view_dashboard_stats") + const hasPermission = user?.permissions?.includes("view_dashboard_stats"); - if (!hasPermission) return null + if (!hasPermission) return null; - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.dashboard_page", isBot, locale, - layout: {name: 'DashboardLayout'} + layout: { name: "DashboardLayout" }, }, }; } diff --git a/src/pages/dashboard/inspector-expert/index.jsx b/src/pages/dashboard/inspector-expert/index.jsx index c2d14f8..24994aa 100644 --- a/src/pages/dashboard/inspector-expert/index.jsx +++ b/src/pages/dashboard/inspector-expert/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardInspectorExpertComponent from "@/components/dashboard/inspector-expert"; export default function InspectorExpert() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.inspector_expert_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_inspector_refahi"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_inspector_refahi"] } }, }, }; } diff --git a/src/pages/dashboard/loan-followup/index.jsx b/src/pages/dashboard/loan-followup/index.jsx index 7494676..fc3d7a6 100644 --- a/src/pages/dashboard/loan-followup/index.jsx +++ b/src/pages/dashboard/loan-followup/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardLoanFollowUpComponent from "@/components/dashboard/loan-followup"; export default function LoanFollowUp() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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 + layout: { name: "DashboardLayout", props: { permissions: ["manage_vezarat_eghtesad_loans"] } }, //permission should change }, }; } diff --git a/src/pages/dashboard/loan-history/index.jsx b/src/pages/dashboard/loan-history/index.jsx index b451589..4e61957 100644 --- a/src/pages/dashboard/loan-history/index.jsx +++ b/src/pages/dashboard/loan-history/index.jsx @@ -1,21 +1,22 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardLoanHistoryComponent from "@/components/dashboard/loan-history"; export default function LoanHistory() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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"]}} + layout: { + name: "DashboardLayout", + props: { permissions: ["view_navgan_loans", "view_navgan_loans_province"] }, + }, }, }; } diff --git a/src/pages/dashboard/navgan-loan-management/index.jsx b/src/pages/dashboard/navgan-loan-management/index.jsx index 792ea3e..6bf8d46 100644 --- a/src/pages/dashboard/navgan-loan-management/index.jsx +++ b/src/pages/dashboard/navgan-loan-management/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardNavganLoanManagementComponent from "@/components/dashboard/navgan-loan-management"; export default function NavganLoanManagement() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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_management_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_navgan_loan"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_navgan_loan"] } }, }, }; } diff --git a/src/pages/dashboard/navgan-province-manager/index.jsx b/src/pages/dashboard/navgan-province-manager/index.jsx index 39102cb..ff370ef 100644 --- a/src/pages/dashboard/navgan-province-manager/index.jsx +++ b/src/pages/dashboard/navgan-province-manager/index.jsx @@ -1,21 +1,19 @@ import DashboardNavganProvinceManagerComponent from "src/components/dashboard/navgan-province-manager"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; export default function PassengerOffice() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.province_manager_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_province_affairs_navgan"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_province_affairs_navgan"] } }, }, }; } diff --git a/src/pages/dashboard/old-reports/index.jsx b/src/pages/dashboard/old-reports/index.jsx index 31e36cd..a9021ca 100644 --- a/src/pages/dashboard/old-reports/index.jsx +++ b/src/pages/dashboard/old-reports/index.jsx @@ -1,20 +1,18 @@ import DashboardReportsComponent from "@/components/dashboard/old-reports"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; export default function Reports() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.reports", isBot, - layout: {name: 'DashboardLayout', props: {permissions: ["view_reports_navgan"]}} + layout: { name: "DashboardLayout", props: { permissions: ["view_reports_navgan"] } }, }, }; } diff --git a/src/pages/dashboard/passenger-boss/index.jsx b/src/pages/dashboard/passenger-boss/index.jsx index c38b95f..440eddc 100644 --- a/src/pages/dashboard/passenger-boss/index.jsx +++ b/src/pages/dashboard/passenger-boss/index.jsx @@ -1,21 +1,19 @@ import DashboardPassengerBossComponent from "@/components/dashboard/passenger-boss"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; export default function PassengerBoss() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.passenger_boss_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_province_working_group_navgan"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_province_working_group_navgan"] } }, }, }; } diff --git a/src/pages/dashboard/province-head-expert/index.jsx b/src/pages/dashboard/province-head-expert/index.jsx index b556d20..7863976 100644 --- a/src/pages/dashboard/province-head-expert/index.jsx +++ b/src/pages/dashboard/province-head-expert/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardProvinceHeadExpertComponent from "@/components/dashboard/province-head-expert"; export default function ProvinceHeadExpertOffice() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.province_head_expert", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_province_headquarter_refahi"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_province_headquarter_refahi"] } }, }, }; } diff --git a/src/pages/dashboard/refahi-loan-management/index.jsx b/src/pages/dashboard/refahi-loan-management/index.jsx index 4aab9a0..bf49b03 100644 --- a/src/pages/dashboard/refahi-loan-management/index.jsx +++ b/src/pages/dashboard/refahi-loan-management/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardRefahiLoanManagementComponent from "@/components/dashboard/refahi-loan-management"; export default function RefahiLoanManagement() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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_management_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_refahi_loan"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_refahi_loan"] } }, }, }; } diff --git a/src/pages/dashboard/refahi-province-manager/index.jsx b/src/pages/dashboard/refahi-province-manager/index.jsx index cc5c1eb..3653beb 100644 --- a/src/pages/dashboard/refahi-province-manager/index.jsx +++ b/src/pages/dashboard/refahi-province-manager/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardRefahiProvinceManagerComponent from "@/components/dashboard/refahi-province-manager"; export default function RefahiProvinceManager() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.province_manager_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_province_affairs_refahi"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_province_affairs_refahi"] } }, }, }; } diff --git a/src/pages/dashboard/reports/index.jsx b/src/pages/dashboard/reports/index.jsx index 7a7de52..088dc33 100644 --- a/src/pages/dashboard/reports/index.jsx +++ b/src/pages/dashboard/reports/index.jsx @@ -1,20 +1,18 @@ import DashboardReportsComponent from "@/components/dashboard/reports"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; export default function Reports() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.reports", isBot, - layout: {name: 'DashboardLayout', props: {permissions: ["view_reports_navgan"]}} + layout: { name: "DashboardLayout", props: { permissions: ["view_reports_navgan"] } }, }, }; } diff --git a/src/pages/dashboard/reserve-loan/index.jsx b/src/pages/dashboard/reserve-loan/index.jsx index b849203..6b6739c 100644 --- a/src/pages/dashboard/reserve-loan/index.jsx +++ b/src/pages/dashboard/reserve-loan/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardReserveLoan from "@/components/dashboard/reserve-loan"; export default function PassengerOffice() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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_reserved_loans"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_reserved_loans"] } }, }, }; } diff --git a/src/pages/dashboard/role-management/index.jsx b/src/pages/dashboard/role-management/index.jsx index 7ae6d45..f127505 100644 --- a/src/pages/dashboard/role-management/index.jsx +++ b/src/pages/dashboard/role-management/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardRoleManagementComponent from "@/components/dashboard/role-management"; export default function RoleManagement() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.role_management_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_roles"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_roles"] } }, }, }; } diff --git a/src/pages/dashboard/transportation-assistant/index.jsx b/src/pages/dashboard/transportation-assistant/index.jsx index 7c0b4b6..c98090e 100644 --- a/src/pages/dashboard/transportation-assistant/index.jsx +++ b/src/pages/dashboard/transportation-assistant/index.jsx @@ -1,21 +1,19 @@ import DashboardTransportationAssistanceComponent from "@/components/dashboard/transportation-assistance"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; export default function TransportationAssistance() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.transportation_assistance", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_transportation_navgan"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_transportation_navgan"] } }, }, }; } diff --git a/src/pages/dashboard/user-management/index.jsx b/src/pages/dashboard/user-management/index.jsx index e92c2b2..ae145f6 100644 --- a/src/pages/dashboard/user-management/index.jsx +++ b/src/pages/dashboard/user-management/index.jsx @@ -1,21 +1,19 @@ -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; import DashboardUserManagementComponent from "@/components/dashboard/user-management"; export default function UserManagement() { - return ( - - ); + return ; } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +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.user_management_page", isBot, locale, - layout: {name: 'DashboardLayout', props: {permissions: ["manage_users"]}} + layout: { name: "DashboardLayout", props: { permissions: ["manage_users"] } }, }, }; } diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 996ba03..c7f17e0 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -1,22 +1,22 @@ import FirstComponent from "@/components/first"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; export default function Home() { return ( <> - + ); } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +export async function getServerSideProps({ req, locale }) { + const { isBot } = parse(req.headers["user-agent"]); return { props: { messages: (await import(`&/locales/${locale}/app.json`)).default, title: "first_page", isBot, - locale + locale, }, }; } diff --git a/src/pages/login-expert.jsx b/src/pages/login-expert.jsx index 393f916..4e7ed00 100644 --- a/src/pages/login-expert.jsx +++ b/src/pages/login-expert.jsx @@ -1,23 +1,23 @@ import LoginComponent from "@/components/login-expert"; import WithoutAuthMiddleware from "@/middlewares/WithoutAuth"; -import {parse} from "next-useragent"; +import { parse } from "next-useragent"; export default function Login() { return ( - + ); } -export async function getServerSideProps({req, locale}) { - const {isBot} = parse(req.headers["user-agent"]); +export async function getServerSideProps({ req, locale }) { + const { isBot } = parse(req.headers["user-agent"]); return { props: { messages: (await import(`&/locales/${locale}/app.json`)).default, title: "Titles.title_login_expert_page", isBot, - locale + locale, }, }; }