LFFE-19 get vehicle type and set maximum number base on it
This commit is contained in:
@@ -206,7 +206,7 @@
|
||||
"upload_file_required": "وارد کردن صورت جلسه کارگروه استانی الزامیست",
|
||||
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد",
|
||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||
"max_amount": "حداکثر مبلغ پیشنهادی {value} تومان می باشد"
|
||||
"max_amount": "حداکثر مبلغ تصویب شده {value} میلیون تومان می باشد"
|
||||
},
|
||||
"RefahiProvinceManager": {
|
||||
"name": "نام",
|
||||
@@ -305,7 +305,7 @@
|
||||
"upload_file_required": "وارد کردن گزارش کارشناسی الزامیست",
|
||||
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد",
|
||||
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
|
||||
"max_amount": "حداکثر مبلغ پیشنهادی {value} هزار تومان می باشد"
|
||||
"max_amount": "حداکثر مبلغ پیشنهادی {value} میلیون تومان می باشد"
|
||||
},
|
||||
"UserManagement": {
|
||||
"name": "نام",
|
||||
|
||||
@@ -9,8 +9,7 @@ import {useState} from "react";
|
||||
import PriceField from "@/core/components/PriceField";
|
||||
import * as Yup from "yup";
|
||||
|
||||
const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
const max_amount_number = 70000000000
|
||||
const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type}) => {
|
||||
const t = useTranslations();
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
@@ -18,24 +17,30 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({auth: true})
|
||||
const {update_notification} = useNotification()
|
||||
|
||||
let max_amount_number
|
||||
if (vehicle_type === "اتوبوس") {
|
||||
max_amount_number = 7000
|
||||
} else if (vehicle_type === "مینی بوس") {
|
||||
max_amount_number = 2000
|
||||
} else {
|
||||
max_amount_number = 5000
|
||||
}
|
||||
const validationSchema = Yup.object().shape({
|
||||
proposed_amount: Yup.mixed().test(
|
||||
"is-number",
|
||||
`${t("ConfirmDialog.proposed_amount_number")}`,
|
||||
(value) => !isNaN(value)
|
||||
).test("max-amount", `${t("MachinaryOffice.max_amount", {value: parseInt(max_amount_number).toLocaleString('en')})}`, (value) => value <= max_amount_number)
|
||||
).test("max-amount", `${t("MachinaryOffice.max_amount", {value: parseInt(max_amount_number / 10).toLocaleString('en')})}`,
|
||||
(value) => value <= max_amount_number)
|
||||
.test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0)
|
||||
.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)
|
||||
return value.size <= 2 * 1024 * 1024;
|
||||
})
|
||||
.test('fileType', `${t("MachinaryOffice.upload_file_format")}`, (value) => {
|
||||
// if (!value) return true; // Skip if no file is provided
|
||||
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'];
|
||||
return allowedTypes.includes(value.type);
|
||||
})
|
||||
});
|
||||
@@ -51,7 +56,6 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
formData.append("proposed_amount", values.proposed_amount);
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_MACHINARY_OFFICE}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
}).then((response) => {
|
||||
|
||||
@@ -3,7 +3,8 @@ import {useTranslations} from "next-intl";
|
||||
import {useState} from "react";
|
||||
import ConfirmContent from "./ConfirmContent";
|
||||
import CallMadeIcon from '@mui/icons-material/CallMade';
|
||||
const Confirm = ({rowId, mutate}) => {
|
||||
|
||||
const Confirm = ({rowId, mutate, vehicle_type}) => {
|
||||
const t = useTranslations();
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
return (
|
||||
@@ -21,7 +22,8 @@ const Confirm = ({rowId, mutate}) => {
|
||||
<Dialog fullWidth open={openConfirmDialog}
|
||||
PaperProps={{sx: {boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}}>
|
||||
<DialogTitle>{t("MachinaryOffice.confirm")}</DialogTitle>
|
||||
<ConfirmContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog}/>
|
||||
<ConfirmContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog}
|
||||
vehicle_type={vehicle_type}/>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -3,11 +3,11 @@ import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
|
||||
const TableRow = ({row, mutate}) => {
|
||||
|
||||
return (
|
||||
<Box sx={{display: "flex", flexWrap: "nowrap", gap: "8px"}}>
|
||||
<Confirm
|
||||
rowId={row.getValue("id")}
|
||||
vehicle_type={row.original.vehicle_type}
|
||||
mutate={mutate}
|
||||
/>
|
||||
<Reject
|
||||
|
||||
@@ -9,8 +9,7 @@ import {useState} from "react";
|
||||
import PriceField from "@/core/components/PriceField";
|
||||
import * as Yup from "yup";
|
||||
|
||||
const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
const max_amount_number = 70000000000
|
||||
const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type}) => {
|
||||
const t = useTranslations();
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
@@ -18,14 +17,22 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({auth: true})
|
||||
const {update_notification} = useNotification()
|
||||
|
||||
let max_amount_number
|
||||
if (vehicle_type === "اتوبوس") {
|
||||
max_amount_number = 7000
|
||||
} else if (vehicle_type === "مینی بوس") {
|
||||
max_amount_number = 2000
|
||||
} else {
|
||||
max_amount_number = 5000
|
||||
}
|
||||
|
||||
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(max_amount_number).toLocaleString('en')})}`, (value) => value <= max_amount_number)
|
||||
).test("max-amount", `${t("PassengerBoss.max_amount", {value: parseInt(max_amount_number / 10).toLocaleString('en')})}`,
|
||||
(value) => value <= max_amount_number)
|
||||
.test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0)
|
||||
.required(t("ConfirmDialog.approved_amount_error")),
|
||||
confirm_img: Yup.mixed()
|
||||
|
||||
@@ -3,7 +3,8 @@ import {useTranslations} from "next-intl";
|
||||
import {useState} from "react";
|
||||
import ConfirmContent from "./ConfirmContent";
|
||||
import CallMadeIcon from '@mui/icons-material/CallMade';
|
||||
const Confirm = ({rowId, mutate}) => {
|
||||
|
||||
const Confirm = ({rowId, mutate, vehicle_type}) => {
|
||||
const t = useTranslations();
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
return (
|
||||
@@ -21,7 +22,8 @@ const Confirm = ({rowId, mutate}) => {
|
||||
<Dialog fullWidth open={openConfirmDialog}
|
||||
PaperProps={{sx: {boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}}>
|
||||
<DialogTitle>{t("PassengerBoss.confirm")}</DialogTitle>
|
||||
<ConfirmContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog}/>
|
||||
<ConfirmContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog}
|
||||
vehicle_type={vehicle_type}/>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@ const TableRow = ({row, mutate}) => {
|
||||
<Box sx={{display: "flex", flexWrap: "nowrap", gap: "8px"}}>
|
||||
<Confirm
|
||||
rowId={row.getValue("id")}
|
||||
vehicle_type={row.original.vehicle_type}
|
||||
mutate={mutate}
|
||||
/>
|
||||
<Reject
|
||||
|
||||
Reference in New Issue
Block a user