LFFE-18 validation on confirm img in machinary expert
This commit is contained in:
@@ -161,7 +161,7 @@
|
||||
"navgan_id": "کد ناوگان",
|
||||
"vehicle_type": "نوع ماشین",
|
||||
"state_name": "وضعیت درخواست",
|
||||
"confirm" : "ارجاع به ماشین آلات"
|
||||
"confirm" : "ارجاع به کارشناس ماشین آلات"
|
||||
},
|
||||
"CommercialChief": {
|
||||
"name": "نام",
|
||||
@@ -196,7 +196,7 @@
|
||||
"navgan_id": "کد ناوگان",
|
||||
"vehicle_type": "نوع ماشین",
|
||||
"state_name": "وضعیت درخواست",
|
||||
"confirm" : "ارجاع به معاونت حمل و نقل"
|
||||
"confirm" : "ارجاع به معاون حمل و نقل"
|
||||
},
|
||||
"RefahiProvinceManager": {
|
||||
"name": "نام",
|
||||
@@ -288,7 +288,17 @@
|
||||
"navgan_id": "کد ناوگان",
|
||||
"vehicle_type": "نوع ماشین",
|
||||
"state_name": "وضعیت درخواست",
|
||||
"confirm" : "ارجاع به کارگروه استانی"
|
||||
"confirm" : "ارجاع به کارگروه استانی",
|
||||
"upload_file": "گزارش کارشناسی را وارد کنید",
|
||||
"upload_file_required": "وارد کردن گزارش کارشناسی الزامیست",
|
||||
"upload_file_unit": "حداکثر 2Mb",
|
||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||
"delete": "پاک کردن",
|
||||
"phone_number": "شماره تلفن",
|
||||
"national_id": "کد ملی",
|
||||
"navgan_id": "کد ناوگان",
|
||||
"type_id": "نوع کاربر",
|
||||
"uploadfile_error": "حجم فایل بیشتر از 2 مگابایت می باشد"
|
||||
},
|
||||
"UserManagement": {
|
||||
"name": "نام",
|
||||
@@ -325,6 +335,7 @@
|
||||
"approved_amount_number": "مبلغ تصویب شده باید عدد باشد",
|
||||
"toman": "تومان",
|
||||
"proposed_amount_error": "وارد کردن مقدار پیشنهادی الزامیست",
|
||||
"proposed_amount_number": "مقدار پیشنهادی باید عدد باشد",
|
||||
"proposed_amount": "مقدار پیشنهادی",
|
||||
"proposed_amount_positive": "مقدار پیشنهادی باید مثبت باشد"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
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 {CONFIRM_MACHINARY_OFFICE} from "@/core/data/apiRoutes";
|
||||
@@ -25,7 +33,18 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
`${t("ConfirmDialog.proposed_amount_number")}`,
|
||||
(value) => !isNaN(value)
|
||||
).test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0)
|
||||
.required(t("ConfirmDialog.proposed_amount_error"))
|
||||
.required(t("ConfirmDialog.proposed_amount_error")),
|
||||
confirm_img: Yup.mixed()
|
||||
.required(t("MachinaryOffice.upload_file_required"))
|
||||
.test('fileSize', `${t("MachinaryOffice.upload_file_unit")}`, (value) => {
|
||||
// if (!value) return true; // Skip if no file is provided
|
||||
return value.size <= 2 * 1024 * 1024; // 100KB limit (adjust as needed)
|
||||
})
|
||||
.test('fileType', `${t("MachinaryOffice.upload_file_format")}`, (value) => {
|
||||
// if (!value) return true; // Skip if no file is provided
|
||||
const allowedTypes = ['image/jpg', 'image/png', 'application/pdf']; // Define your allowed file types
|
||||
return allowedTypes.includes(value.type);
|
||||
})
|
||||
});
|
||||
|
||||
const formik = useFormik({
|
||||
@@ -129,7 +148,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Typography>{t("UploadSystem.upload_file")}{t("UploadSystem.optional")}</Typography>
|
||||
<Typography>{t("MachinaryOffice.upload_file")}</Typography>
|
||||
<UploadSystem
|
||||
selectedImage={selectedImage}
|
||||
handleUploadChange={handleUploadChange} // Pass the updated function directly
|
||||
@@ -140,9 +159,22 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
fileName={fileName}
|
||||
imageAlt={t("app_name")}
|
||||
imageSize={[250, 150]}
|
||||
onBlur={formik.handleBlur("confirm_img")}
|
||||
error={
|
||||
formik.touched.confirm_img &&
|
||||
Boolean(formik.errors.confirm_img)
|
||||
}
|
||||
helperText={
|
||||
formik.touched.confirm_img && formik.errors.confirm_img
|
||||
}
|
||||
setShowAddIcon={setShowAddIcon}
|
||||
showAddIcon={showAddIcon}
|
||||
/>
|
||||
<FormHelperText
|
||||
error={Boolean(formik.errors.confirm_img)}
|
||||
>
|
||||
{formik.errors.confirm_img ? formik.errors.confirm_img : null}
|
||||
</FormHelperText>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
|
||||
@@ -10,7 +10,6 @@ const UploadSystem = ({
|
||||
handleUploadChange,
|
||||
fieldname,
|
||||
setFieldValue,
|
||||
imageAlt,
|
||||
imageSize,
|
||||
fileType,
|
||||
fileName,
|
||||
|
||||
Reference in New Issue
Block a user