diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 055cc36..6c32048 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -193,7 +193,7 @@ "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست", "confirm": "ارجاع به کارشناس ماشین آلات", - "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", + "upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", "excel_report": "گزارش اکسل" }, @@ -231,7 +231,7 @@ "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست", "confirm": "تایید نهایی و ارجاع به بانک", - "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", + "upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", "excel_report": "گزارش اکسل" }, @@ -263,7 +263,7 @@ "upload_file": "صورت جلسه کارگروه را بارگذاری کنید", "upload_file_first_required": "وارد کردن فرم الف الزامیست", "upload_file_second_required": "وارد کردن فرم ب الزامیست", - "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", + "upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", "print_form_a": "چاپ فرم الف", "print_form_b": "چاپ فرم ب", @@ -367,7 +367,7 @@ "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست", "confirm": "ارجاع به مدیر کل", - "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", + "upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", "excel_report": "گزارش اکسل", "confirm_text": "فرم الف و ب به رویت و تایید رسید." @@ -407,7 +407,7 @@ "confirm": "ارجاع به کارگروه", "upload_file": "گزارش کارشناسی را بارگذاری کنید", "upload_file_required": "وارد کردن گزارش کارشناسی الزامیست", - "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", + "upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", "print_report": "چاپ گزارش کارشناسی", "max_amount": "حداکثر مبلغ پیشنهادی {value} میلیون ریال می باشد", @@ -478,7 +478,8 @@ "button-reject": "عدم تایید", "description": "توضیحات خود را وارد نمائید", "optional": " (اختیاری)", - "description_error": "وارد کردن توضیحات الزامی است!" + "description_error": "وارد کردن توضیحات الزامی است!", + "choose_file" : "انتخاب فایل" }, "UpdateDialog": { "update": "ویرایش", @@ -681,6 +682,7 @@ "tanafos_period": "دوره تنفس", "sakht_period": "دوره ساخت", "national_id": "کد ملی", + "postal_code": "کد پستی", "phone_number": "موبایل", "proposed_amount": "مبلغ پیشنهادی", "approved_amount": "مبلغ تصویب شده", diff --git a/src/components/dashboard/loan-history/index.jsx b/src/components/dashboard/loan-history/index.jsx index 8fe4bed..8b886a4 100644 --- a/src/components/dashboard/loan-history/index.jsx +++ b/src/components/dashboard/loan-history/index.jsx @@ -156,6 +156,22 @@ function DashboardLoanHistoryComponent() { {renderedCellValue} ), }, + { + accessorFn: (row) => row.postal_code, + id: "postal_code", + header: t("LoanHistory.postal_code"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, { accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), @@ -356,10 +372,12 @@ function DashboardLoanHistoryComponent() { }, { accessorFn: (row) => row.state_name, - id: "state_id", + id: "state_name", header: t("LoanHistory.state_name"), - enableColumnFilter: false, - datatype: "numeric", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], Cell: ({renderedCellValue}) => ( {renderedCellValue} ), diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx index 05ad51b..a1a6b1f 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx @@ -94,7 +94,7 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type, hand confirm_img: Yup.mixed() .required(t("MachinaryOffice.upload_file_required")) .test('fileSize', `${t("MachinaryOffice.upload_file_unit")}`, (value) => { - return value.size <= 2 * 1024 * 1024; + return value.size <= 5 * 1024 * 1024; }) .test('fileType', `${t("MachinaryOffice.upload_file_format")}`, (value) => { const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; diff --git a/src/components/dashboard/machinary-office/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/machinary-office/Form/RejectForm/RejectContent.jsx index 345f569..afec59e 100644 --- a/src/components/dashboard/machinary-office/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/machinary-office/Form/RejectForm/RejectContent.jsx @@ -1,7 +1,7 @@ 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 {Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography} from "@mui/material" import {useFormik} from "formik"; import {useTranslations} from "next-intl"; import {useState} from "react"; @@ -19,6 +19,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { 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) => { + 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 + return !value || (value.type && allowedTypes.includes(value.type)); + }), }); const formik = useFormik({ @@ -62,18 +70,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(t); - event.target.value = ""; - return; - } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); setfileType(fileType); setfileName(fileName); - formik.setFieldValue("reject_img", uploadedFile); + formik.setFieldValue("reject_img", uploadedFile).then(() => { + formik.setFieldTouched("reject_img", true); + }) setShowAddIcon(false); } }; @@ -113,7 +117,17 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { imageSize={[250 /*width*/, 150 /*height*/]} setShowAddIcon={setShowAddIcon} showAddIcon={showAddIcon} + onBlur={() => formik.handleBlur("reject_img")} + error={ + formik.touched.reject_img && + Boolean(formik.errors.reject_img) + } /> + + {formik.touched.reject_img && formik.errors.reject_img} + diff --git a/src/components/dashboard/navgan-loan-management/index.jsx b/src/components/dashboard/navgan-loan-management/index.jsx index 6c4b8f6..03b5242 100644 --- a/src/components/dashboard/navgan-loan-management/index.jsx +++ b/src/components/dashboard/navgan-loan-management/index.jsx @@ -357,10 +357,12 @@ function DashboardNavganLoanManagementComponent() { }, { accessorFn: (row) => row.state_name, - id: "state_id", + id: "state_name", header: t("NavganLoanManagement.state_name"), - enableColumnFilter: false, - datatype: "numeric", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], Cell: ({renderedCellValue}) => ( {renderedCellValue} ), 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 d63cd63..a7ce958 100644 --- a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx @@ -41,7 +41,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl 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 <= 2 * 1024 * 1024; + return value.size <= 5 * 1024 * 1024; }) .test('fileType', `${t("NavganProvinceManager.upload_file_format")}`, (value) => { if (!value) return true 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 8533094..9907263 100644 --- a/src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx @@ -1,7 +1,7 @@ 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 {Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography} from "@mui/material" import {useFormik} from "formik"; import {useTranslations} from "next-intl"; import {useState} from "react"; @@ -19,6 +19,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { 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) => { + 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 + return !value || (value.type && allowedTypes.includes(value.type)); + }), }); const formik = useFormik({ @@ -62,21 +70,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(t); - event.target.value = ""; - return; - } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); setfileType(fileType); setfileName(fileName); - formik.setFieldValue("reject_img", uploadedFile); + formik.setFieldValue("reject_img", uploadedFile).then(() => { + formik.setFieldTouched("reject_img", true); + }) setShowAddIcon(false); } }; + return ( <> @@ -113,7 +118,17 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { imageSize={[250 /*width*/, 150 /*height*/]} setShowAddIcon={setShowAddIcon} showAddIcon={showAddIcon} + onBlur={() => formik.handleBlur("reject_img")} + error={ + formik.touched.reject_img && + Boolean(formik.errors.reject_img) + } /> + + {formik.touched.reject_img && formik.errors.reject_img} + diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx index 96b000d..ff140ba 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx @@ -101,7 +101,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand first_img: Yup.mixed() .required(t("PassengerBoss.upload_file_first_required")) .test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => { - return value.size <= 2 * 1024 * 1024; + return value.size <= 5 * 1024 * 1024; }) .test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => { const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types @@ -110,7 +110,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand second_img: Yup.mixed() .required(t("PassengerBoss.upload_file_second_required")) .test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => { - return value.size <= 2 * 1024 * 1024; + return value.size <= 5 * 1024 * 1024; }) .test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => { const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx index 7ad9ade..3431cde 100644 --- a/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx @@ -27,7 +27,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { first_reject_img: Yup.mixed() .required(t("PassengerBoss.upload_file_first_required")) .test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => { - return value.size <= 2 * 1024 * 1024; + return value.size <= 5 * 1024 * 1024; }) .test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => { const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types @@ -37,7 +37,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { second_reject_img: Yup.mixed() .required(t("PassengerBoss.upload_file_second_required")) .test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => { - return value.size <= 2 * 1024 * 1024; + return value.size <= 5 * 1024 * 1024; }) .test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => { const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm/ConfirmContent.jsx index d86c4f2..846291b 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm/ConfirmContent.jsx @@ -21,7 +21,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error")) .test('fileSize', `${t("PassengerOffice.upload_file_unit")}`, (value) => { if (!value) return true - return value.size <= 2 * 1024 * 1024; + return value.size <= 5 * 1024 * 1024; }) .test('fileType', `${t("PassengerOffice.upload_file_format")}`, (value) => { if (!value) return true diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx index 825bacc..427d3a3 100644 --- a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx @@ -91,7 +91,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl 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 <= 2 * 1024 * 1024; + return value.size <= 5 * 1024 * 1024; }) .test('fileType', `${t("TransportationAssistance.upload_file_format")}`, (value) => { if (!value) return true diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx index e370041..54ad696 100644 --- a/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx @@ -1,7 +1,7 @@ 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 {Button, DialogActions, DialogContent, FormHelperText, Stack, TextField, Typography} from "@mui/material" import {useFormik} from "formik"; import {useTranslations} from "next-intl"; import {useState} from "react"; @@ -19,6 +19,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { 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) => { + 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 + return !value || (value.type && allowedTypes.includes(value.type)); + }), }); const formik = useFormik({ @@ -62,18 +70,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(t); - event.target.value = ""; - return; - } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); setfileType(fileType); setfileName(fileName); - formik.setFieldValue("reject_img", uploadedFile); + formik.setFieldValue("reject_img", uploadedFile).then(() => { + formik.setFieldTouched("reject_img", true); + }) setShowAddIcon(false); } }; @@ -113,7 +117,17 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => { imageSize={[250 /*width*/, 150 /*height*/]} setShowAddIcon={setShowAddIcon} showAddIcon={showAddIcon} + onBlur={() => formik.handleBlur("reject_img")} + error={ + formik.touched.reject_img && + Boolean(formik.errors.reject_img) + } /> + + {formik.touched.reject_img && formik.errors.reject_img} +