yasi_expert_bug
This commit is contained in:
@@ -184,7 +184,7 @@
|
|||||||
"vehicle_type": "نوع ماشین",
|
"vehicle_type": "نوع ماشین",
|
||||||
"state_name": "وضعیت درخواست",
|
"state_name": "وضعیت درخواست",
|
||||||
"confirm": "ارجاع به کارشناس ماشین آلات",
|
"confirm": "ارجاع به کارشناس ماشین آلات",
|
||||||
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد",
|
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
|
||||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||||
"excel_report": "گزارش اکسل"
|
"excel_report": "گزارش اکسل"
|
||||||
},
|
},
|
||||||
@@ -222,7 +222,7 @@
|
|||||||
"vehicle_type": "نوع ماشین",
|
"vehicle_type": "نوع ماشین",
|
||||||
"state_name": "وضعیت درخواست",
|
"state_name": "وضعیت درخواست",
|
||||||
"confirm": "تایید نهایی و ارجاع به بانک",
|
"confirm": "تایید نهایی و ارجاع به بانک",
|
||||||
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد",
|
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
|
||||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||||
"excel_report": "گزارش اکسل"
|
"excel_report": "گزارش اکسل"
|
||||||
},
|
},
|
||||||
@@ -254,7 +254,7 @@
|
|||||||
"upload_file": "صورت جلسه کارگروه را بارگذاری کنید",
|
"upload_file": "صورت جلسه کارگروه را بارگذاری کنید",
|
||||||
"upload_file_first_required": "وارد کردن فرم الف الزامیست",
|
"upload_file_first_required": "وارد کردن فرم الف الزامیست",
|
||||||
"upload_file_second_required": "وارد کردن فرم ب الزامیست",
|
"upload_file_second_required": "وارد کردن فرم ب الزامیست",
|
||||||
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد",
|
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
|
||||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||||
"print_form_a": "چاپ فرم الف",
|
"print_form_a": "چاپ فرم الف",
|
||||||
"print_form_b": "چاپ فرم ب",
|
"print_form_b": "چاپ فرم ب",
|
||||||
@@ -358,7 +358,7 @@
|
|||||||
"vehicle_type": "نوع ماشین",
|
"vehicle_type": "نوع ماشین",
|
||||||
"state_name": "وضعیت درخواست",
|
"state_name": "وضعیت درخواست",
|
||||||
"confirm": "ارجاع به مدیر کل",
|
"confirm": "ارجاع به مدیر کل",
|
||||||
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد",
|
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
|
||||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||||
"excel_report": "گزارش اکسل",
|
"excel_report": "گزارش اکسل",
|
||||||
"confirm_text": "فرم الف و ب به رویت و تایید رسید."
|
"confirm_text": "فرم الف و ب به رویت و تایید رسید."
|
||||||
@@ -398,7 +398,7 @@
|
|||||||
"confirm": "ارجاع به کارگروه",
|
"confirm": "ارجاع به کارگروه",
|
||||||
"upload_file": "گزارش کارشناسی را بارگذاری کنید",
|
"upload_file": "گزارش کارشناسی را بارگذاری کنید",
|
||||||
"upload_file_required": "وارد کردن گزارش کارشناسی الزامیست",
|
"upload_file_required": "وارد کردن گزارش کارشناسی الزامیست",
|
||||||
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد",
|
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
|
||||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||||
"print_report": "چاپ گزارش کارشناسی",
|
"print_report": "چاپ گزارش کارشناسی",
|
||||||
"max_amount": "حداکثر مبلغ پیشنهادی {value} میلیون ریال می باشد",
|
"max_amount": "حداکثر مبلغ پیشنهادی {value} میلیون ریال می باشد",
|
||||||
@@ -469,7 +469,8 @@
|
|||||||
"button-reject": "عدم تایید",
|
"button-reject": "عدم تایید",
|
||||||
"description": "توضیحات خود را وارد نمائید",
|
"description": "توضیحات خود را وارد نمائید",
|
||||||
"optional": " (اختیاری)",
|
"optional": " (اختیاری)",
|
||||||
"description_error": "وارد کردن توضیحات الزامی است!"
|
"description_error": "وارد کردن توضیحات الزامی است!",
|
||||||
|
"choose_file" : "انتخاب فایل"
|
||||||
},
|
},
|
||||||
"UpdateDialog": {
|
"UpdateDialog": {
|
||||||
"update": "ویرایش",
|
"update": "ویرایش",
|
||||||
@@ -656,6 +657,7 @@
|
|||||||
"tanafos_period": "دوره تنفس",
|
"tanafos_period": "دوره تنفس",
|
||||||
"sakht_period": "دوره ساخت",
|
"sakht_period": "دوره ساخت",
|
||||||
"national_id": "کد ملی",
|
"national_id": "کد ملی",
|
||||||
|
"postal_code": "کد پستی",
|
||||||
"phone_number": "موبایل",
|
"phone_number": "موبایل",
|
||||||
"proposed_amount": "مبلغ پیشنهادی",
|
"proposed_amount": "مبلغ پیشنهادی",
|
||||||
"approved_amount": "مبلغ تصویب شده",
|
"approved_amount": "مبلغ تصویب شده",
|
||||||
|
|||||||
@@ -156,6 +156,22 @@ function DashboardLoanHistoryComponent() {
|
|||||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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}) => (
|
||||||
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) =>
|
accessorFn: (row) =>
|
||||||
moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"),
|
moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"),
|
||||||
@@ -356,10 +372,12 @@ function DashboardLoanHistoryComponent() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.state_name,
|
accessorFn: (row) => row.state_name,
|
||||||
id: "state_id",
|
id: "state_name",
|
||||||
header: t("LoanHistory.state_name"),
|
header: t("LoanHistory.state_name"),
|
||||||
enableColumnFilter: false,
|
enableColumnFilter: true,
|
||||||
datatype: "numeric",
|
datatype: "text",
|
||||||
|
filterFn: "contains",
|
||||||
|
columnFilterModeOptions: ["contains", "equals", "notEquals"],
|
||||||
Cell: ({renderedCellValue}) => (
|
Cell: ({renderedCellValue}) => (
|
||||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type, hand
|
|||||||
confirm_img: Yup.mixed()
|
confirm_img: Yup.mixed()
|
||||||
.required(t("MachinaryOffice.upload_file_required"))
|
.required(t("MachinaryOffice.upload_file_required"))
|
||||||
.test('fileSize', `${t("MachinaryOffice.upload_file_unit")}`, (value) => {
|
.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) => {
|
.test('fileType', `${t("MachinaryOffice.upload_file_format")}`, (value) => {
|
||||||
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf'];
|
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf'];
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import UploadSystem from "@/core/components/UploadSystem"
|
import UploadSystem from "@/core/components/UploadSystem"
|
||||||
import useNotification from "@/lib/app/hooks/useNotification";
|
import useNotification from "@/lib/app/hooks/useNotification";
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
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 {useFormik} from "formik";
|
||||||
import {useTranslations} from "next-intl";
|
import {useTranslations} from "next-intl";
|
||||||
import {useState} from "react";
|
import {useState} from "react";
|
||||||
@@ -19,6 +19,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
description: Yup.string().required(t("RejectDialog.description_error")),
|
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({
|
const formik = useFormik({
|
||||||
@@ -62,18 +70,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
const handleUploadChange = (event) => {
|
const handleUploadChange = (event) => {
|
||||||
const uploadedFile = event.target?.files?.[0];
|
const uploadedFile = event.target?.files?.[0];
|
||||||
if (uploadedFile) {
|
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 fileType = event.target?.files?.[0].type;
|
||||||
const fileName = event.target?.files?.[0].name;
|
const fileName = event.target?.files?.[0].name;
|
||||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||||
setfileType(fileType);
|
setfileType(fileType);
|
||||||
setfileName(fileName);
|
setfileName(fileName);
|
||||||
formik.setFieldValue("reject_img", uploadedFile);
|
formik.setFieldValue("reject_img", uploadedFile).then(() => {
|
||||||
|
formik.setFieldTouched("reject_img", true);
|
||||||
|
})
|
||||||
setShowAddIcon(false);
|
setShowAddIcon(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -113,7 +117,17 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
imageSize={[250 /*width*/, 150 /*height*/]}
|
imageSize={[250 /*width*/, 150 /*height*/]}
|
||||||
setShowAddIcon={setShowAddIcon}
|
setShowAddIcon={setShowAddIcon}
|
||||||
showAddIcon={showAddIcon}
|
showAddIcon={showAddIcon}
|
||||||
|
onBlur={() => formik.handleBlur("reject_img")}
|
||||||
|
error={
|
||||||
|
formik.touched.reject_img &&
|
||||||
|
Boolean(formik.errors.reject_img)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
<FormHelperText
|
||||||
|
error={Boolean(formik.errors.reject_img)}
|
||||||
|
>
|
||||||
|
{formik.touched.reject_img && formik.errors.reject_img}
|
||||||
|
</FormHelperText>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
@@ -357,10 +357,12 @@ function DashboardNavganLoanManagementComponent() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.state_name,
|
accessorFn: (row) => row.state_name,
|
||||||
id: "state_id",
|
id: "state_name",
|
||||||
header: t("NavganLoanManagement.state_name"),
|
header: t("NavganLoanManagement.state_name"),
|
||||||
enableColumnFilter: false,
|
enableColumnFilter: true,
|
||||||
datatype: "numeric",
|
datatype: "text",
|
||||||
|
filterFn: "contains",
|
||||||
|
columnFilterModeOptions: ["contains", "equals", "notEquals"],
|
||||||
Cell: ({renderedCellValue}) => (
|
Cell: ({renderedCellValue}) => (
|
||||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
|||||||
confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error"))
|
confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error"))
|
||||||
.test('fileSize', `${t("NavganProvinceManager.upload_file_unit")}`, (value) => {
|
.test('fileSize', `${t("NavganProvinceManager.upload_file_unit")}`, (value) => {
|
||||||
if (!value) return true
|
if (!value) return true
|
||||||
return value.size <= 2 * 1024 * 1024;
|
return value.size <= 5 * 1024 * 1024;
|
||||||
})
|
})
|
||||||
.test('fileType', `${t("NavganProvinceManager.upload_file_format")}`, (value) => {
|
.test('fileType', `${t("NavganProvinceManager.upload_file_format")}`, (value) => {
|
||||||
if (!value) return true
|
if (!value) return true
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import UploadSystem from "@/core/components/UploadSystem"
|
import UploadSystem from "@/core/components/UploadSystem"
|
||||||
import useNotification from "@/lib/app/hooks/useNotification";
|
import useNotification from "@/lib/app/hooks/useNotification";
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
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 {useFormik} from "formik";
|
||||||
import {useTranslations} from "next-intl";
|
import {useTranslations} from "next-intl";
|
||||||
import {useState} from "react";
|
import {useState} from "react";
|
||||||
@@ -19,6 +19,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
description: Yup.string().required(t("RejectDialog.description_error")),
|
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({
|
const formik = useFormik({
|
||||||
@@ -62,21 +70,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
const handleUploadChange = (event) => {
|
const handleUploadChange = (event) => {
|
||||||
const uploadedFile = event.target?.files?.[0];
|
const uploadedFile = event.target?.files?.[0];
|
||||||
if (uploadedFile) {
|
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 fileType = event.target?.files?.[0].type;
|
||||||
const fileName = event.target?.files?.[0].name;
|
const fileName = event.target?.files?.[0].name;
|
||||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||||
setfileType(fileType);
|
setfileType(fileType);
|
||||||
setfileName(fileName);
|
setfileName(fileName);
|
||||||
formik.setFieldValue("reject_img", uploadedFile);
|
formik.setFieldValue("reject_img", uploadedFile).then(() => {
|
||||||
|
formik.setFieldTouched("reject_img", true);
|
||||||
|
})
|
||||||
setShowAddIcon(false);
|
setShowAddIcon(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
@@ -113,7 +118,17 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
imageSize={[250 /*width*/, 150 /*height*/]}
|
imageSize={[250 /*width*/, 150 /*height*/]}
|
||||||
setShowAddIcon={setShowAddIcon}
|
setShowAddIcon={setShowAddIcon}
|
||||||
showAddIcon={showAddIcon}
|
showAddIcon={showAddIcon}
|
||||||
|
onBlur={() => formik.handleBlur("reject_img")}
|
||||||
|
error={
|
||||||
|
formik.touched.reject_img &&
|
||||||
|
Boolean(formik.errors.reject_img)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
<FormHelperText
|
||||||
|
error={Boolean(formik.errors.reject_img)}
|
||||||
|
>
|
||||||
|
{formik.touched.reject_img && formik.errors.reject_img}
|
||||||
|
</FormHelperText>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
|
|||||||
first_img: Yup.mixed()
|
first_img: Yup.mixed()
|
||||||
.required(t("PassengerBoss.upload_file_first_required"))
|
.required(t("PassengerBoss.upload_file_first_required"))
|
||||||
.test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => {
|
.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) => {
|
.test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => {
|
||||||
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
|
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()
|
second_img: Yup.mixed()
|
||||||
.required(t("PassengerBoss.upload_file_second_required"))
|
.required(t("PassengerBoss.upload_file_second_required"))
|
||||||
.test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => {
|
.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) => {
|
.test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => {
|
||||||
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
|
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
first_reject_img: Yup.mixed()
|
first_reject_img: Yup.mixed()
|
||||||
.required(t("PassengerBoss.upload_file_first_required"))
|
.required(t("PassengerBoss.upload_file_first_required"))
|
||||||
.test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => {
|
.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) => {
|
.test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => {
|
||||||
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
|
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()
|
second_reject_img: Yup.mixed()
|
||||||
.required(t("PassengerBoss.upload_file_second_required"))
|
.required(t("PassengerBoss.upload_file_second_required"))
|
||||||
.test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => {
|
.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) => {
|
.test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => {
|
||||||
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
|
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
|||||||
confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error"))
|
confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error"))
|
||||||
.test('fileSize', `${t("PassengerOffice.upload_file_unit")}`, (value) => {
|
.test('fileSize', `${t("PassengerOffice.upload_file_unit")}`, (value) => {
|
||||||
if (!value) return true
|
if (!value) return true
|
||||||
return value.size <= 2 * 1024 * 1024;
|
return value.size <= 5 * 1024 * 1024;
|
||||||
})
|
})
|
||||||
.test('fileType', `${t("PassengerOffice.upload_file_format")}`, (value) => {
|
.test('fileType', `${t("PassengerOffice.upload_file_format")}`, (value) => {
|
||||||
if (!value) return true
|
if (!value) return true
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, handleSizeChangeCl
|
|||||||
confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error"))
|
confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error"))
|
||||||
.test('fileSize', `${t("TransportationAssistance.upload_file_unit")}`, (value) => {
|
.test('fileSize', `${t("TransportationAssistance.upload_file_unit")}`, (value) => {
|
||||||
if (!value) return true
|
if (!value) return true
|
||||||
return value.size <= 2 * 1024 * 1024;
|
return value.size <= 5 * 1024 * 1024;
|
||||||
})
|
})
|
||||||
.test('fileType', `${t("TransportationAssistance.upload_file_format")}`, (value) => {
|
.test('fileType', `${t("TransportationAssistance.upload_file_format")}`, (value) => {
|
||||||
if (!value) return true
|
if (!value) return true
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import UploadSystem from "@/core/components/UploadSystem"
|
import UploadSystem from "@/core/components/UploadSystem"
|
||||||
import useNotification from "@/lib/app/hooks/useNotification";
|
import useNotification from "@/lib/app/hooks/useNotification";
|
||||||
import useRequest from "@/lib/app/hooks/useRequest";
|
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 {useFormik} from "formik";
|
||||||
import {useTranslations} from "next-intl";
|
import {useTranslations} from "next-intl";
|
||||||
import {useState} from "react";
|
import {useState} from "react";
|
||||||
@@ -19,6 +19,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
description: Yup.string().required(t("RejectDialog.description_error")),
|
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({
|
const formik = useFormik({
|
||||||
@@ -62,18 +70,14 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
const handleUploadChange = (event) => {
|
const handleUploadChange = (event) => {
|
||||||
const uploadedFile = event.target?.files?.[0];
|
const uploadedFile = event.target?.files?.[0];
|
||||||
if (uploadedFile) {
|
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 fileType = event.target?.files?.[0].type;
|
||||||
const fileName = event.target?.files?.[0].name;
|
const fileName = event.target?.files?.[0].name;
|
||||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||||
setfileType(fileType);
|
setfileType(fileType);
|
||||||
setfileName(fileName);
|
setfileName(fileName);
|
||||||
formik.setFieldValue("reject_img", uploadedFile);
|
formik.setFieldValue("reject_img", uploadedFile).then(() => {
|
||||||
|
formik.setFieldTouched("reject_img", true);
|
||||||
|
})
|
||||||
setShowAddIcon(false);
|
setShowAddIcon(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -113,7 +117,17 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
|||||||
imageSize={[250 /*width*/, 150 /*height*/]}
|
imageSize={[250 /*width*/, 150 /*height*/]}
|
||||||
setShowAddIcon={setShowAddIcon}
|
setShowAddIcon={setShowAddIcon}
|
||||||
showAddIcon={showAddIcon}
|
showAddIcon={showAddIcon}
|
||||||
|
onBlur={() => formik.handleBlur("reject_img")}
|
||||||
|
error={
|
||||||
|
formik.touched.reject_img &&
|
||||||
|
Boolean(formik.errors.reject_img)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
<FormHelperText
|
||||||
|
error={Boolean(formik.errors.reject_img)}
|
||||||
|
>
|
||||||
|
{formik.touched.reject_img && formik.errors.reject_img}
|
||||||
|
</FormHelperText>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user