diff --git a/example.env.local b/example.env.local index f3bd371..4712424 100644 --- a/example.env.local +++ b/example.env.local @@ -1,5 +1,5 @@ NEXT_PUBLIC_API_NAME = "Loan Facilities Dashboard" -NEXT_PUBLIC_API_VERSION = "2.0.0" +NEXT_PUBLIC_API_VERSION = "2.1.0" NEXT_PUBLIC_DEFAULT_LANGUAGE = "fa" NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl" diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 99ce155..7ef24ee 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -241,6 +241,12 @@ }, "PassengerBoss": { "name": "نام", + "button-reserve-confirm": "رزرو", + "reserve-loan-title": "رزرو وام", + "description-reserve-loan-first": "آیا از رزرو وام به کد یکتا", + "description-reserve-loan-second": "اطمینان دارید؟", + "button-reserve-cancel": "بستن", + "button-reserve-confirm": "رزرو", "city_name": "شهرستان", "plate_number": "پلاک", "statement_count": "تعداد صورت وضعیت", @@ -264,13 +270,14 @@ "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست", "confirm": "ارجاع به معاون حمل و نقل", - "upload_file": "صورت جلسه کارگروه را بارگذاری کنید", - "upload_file_first_required": "وارد کردن فرم الف الزامیست", - "upload_file_second_required": "وارد کردن فرم ب الزامیست", + "upload_file": "فایل خود را بارگذاری کنید(اختیاری)", + "upload_expert_img": "فایل گزارش کارشناسی را بارگذاری کنید", + "upload_file_required": "وارد کردن گزارش کارشناسی الزامیست", "upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", - "print_form_a": "چاپ فرم الف", - "print_form_b": "چاپ فرم ب", + "upload_expert_file_required": "وارد کردن گزارش کارشناسی الزامیست", + "upload_expert_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد", + "upload_expert_file_format": "فرمت قابل قبول : png,jpg,pdf", "max_amount": "حداکثر مبلغ تصویب شده {value} میلیون ریال می باشد", "excel_report": "گزارش اکسل", "first_form": "فرم الف را بارگذاری کنید", @@ -467,31 +474,68 @@ }, "ConfirmDialog": { "confirm": "ارجاع", + "month": "(ماه)", "context": "آیا از تایید این آیتم اطمینان دارید؟", "button-cancel": "بستن", "button-confirm": "ارجاع", + "bank_facility": "تسهیلات سهم بانک", + "user_facility": "تسهیلات سهم متقاضی", + "government_facility": "تسهیلات سهم دولت", + "committed_employment": "تعداد اشتغال تعهد شده", + "history_facilities": "سابقه استفاده از تسهیلات تکلیفی", + "available_jobs": "تعداد اشتغال موجود", + "physical_progress": "درصد پیشرفت فیزیکی", + "interest_rate": "نرخ بهره", "description_error": "وارد کردن توضیحات الزامی است!", "optional": " (اختیاری)", "unit": " (میلیون ریال)", "description": "توضیحات خود را وارد نمائید", "choose_file": "انتخاب فایل", + "repayment_period": "دوره باز پرداخت", + "participation_period": "دوره مشارکت", "approved_amount": "مبلغ تصویب شده", "sakht_period": "دوره ساخت", "tanafos_period": "دوره تنفس", "approved_amount_error": "وارد کردن مبلغ تصویب شده الزامیست", + "bank_facility_error": "وارد کردن تسهیلات سهم بانک الزامیست", + "government_facility_error": "وارد کردن تسهیلات سهم دولت الزامیست", + "committed_employment_error": "وارد کردن تعداد اشتغال تعهد شده الزامیست", + "history_facilities_error": "وارد کردن سابقه استفاده از تسهیلات تکلیفی الزامیست", + "available_jobs_error": "وارد کردن تعداد اشتغال موجود الزامیست", "sakht_period_error": "وارد کردن دوره ساخت الزامیست", "tanafos_period_error": "وارد کردن دوره تنفس الزامیست", "approved_amount_positive": "مبلغ تصویب شده باید مثبت باشد", + "bank_facility_positive": "تسهیلات سهم بانک باید مثبت باشد", + "repayment_period_positive": "دوره باز پرداخت باید مثبت باشد", + "participation_period_positive": "دوره مشارکت باید مثبت باشد", + "government_facility_positive": "تسهیلات سهم دولت باید مثبت باشد", + "committed_employment_positive": "تعداد اشتغال تعهد شده باید مثبت باشد", + "history_facilities_positive": "سابقه استفاده از تسهیلات تکلیفی باید مثبت باشد", + "available_jobs_positive": "تعدلد اشتغال موجود باید مثبت باشد", "approved_amount_number": "مبلغ تصویب شده باید عدد باشد", + "bank_facility_number": "تسهیلات سهم بانک باید عدد باشد", + "interest_rate_number": "نرخ بهره باید عدد باشد", + "government_facility_number": "تسهیلات سهم دولت باید عدد باشد", + "committed_employment_number": "تعداد سابقه استفاده از تسهیلات تکلیفی باید عدد باشد", + "history_facilities_number": "تعداد اشتغال تعهد شده باید عدد باشد", + "available_jobs_number": "تعداد اشتغال موجود باید عدد باشد", "sakht_period_positive": "دوره ساخت باید مثبت باشد", + "interest_rate_positive": "نرخ بهره باید مثبت باشد", "tanafos_period_positive": "دوره تنفس باید مثبت باشد", "sakht_period_number": "دوره ساخت باید عدد باشد", + "repayment_period_number": "دوره باز پرداخت باید عدد باشد", + "participation_period_number": "دوره مشارکت باید عدد باشد", "tanafos_period_number": "دوره تنفس باید عدد باشد", "toman": "میلیون تومان", + "bank_facility_max_amount": "جمع مبلغ سهم دولت و سهم بانک نباید از مبلغ تصویب شده بیشتر باشد .", + "government_facility_max_amount": "جمع مبلغ سهم دولت و سهم بانک نباید از مبلغ تصویب شده بیشتر باشد .", "tanafos_period_month": "ماه", "approved_amount_title": "مبلغ تصویب شده کارگروه", "sakht_period_day": "روز", "proposed_amount_error": "وارد کردن مقدار پیشنهادی الزامیست", + "repayment_period_error": "وارد کردن دوره باز پرداخت الزامیست", + "participation_period_error": "وارد کردن دوره مشارکت الزامیست", + "interest_rate_error": "وارد کردن نرخ بهره الزامیست", "proposed_amount": "مبلغ پیشنهادی", "proposed_amount_positive": "مقدار پیشنهادی باید مثبت باشد", "proposed_amount_number": "مقدار پیشنهادی باید عدد باشد" diff --git a/src/components/dashboard/passenger-boss/Buttons/printFormA.jsx b/src/components/dashboard/passenger-boss/Buttons/printFormA.jsx deleted file mode 100644 index 6e0405e..0000000 --- a/src/components/dashboard/passenger-boss/Buttons/printFormA.jsx +++ /dev/null @@ -1,89 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useRouter} from "next/router"; -import {useState} from "react"; -import useRequest from "@/lib/app/hooks/useRequest"; -import usePrint from "@/lib/app/hooks/usePrint"; -import {Button, CircularProgress} from "@mui/material"; -import PrintIcon from "@mui/icons-material/Print"; -import {GET_PASSENGER_BOSS} from "@/core/data/apiRoutes"; - -const PrintFormA = () => { - 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 filterRequest = async (filterArr) => { - setLoading(true); - - const requests = filterArr.map(async (item) => { - try { - const params = new URLSearchParams(); - params.set("start", '0'); - params.set("filters", JSON.stringify([item])); - params.set("sorting", '[]'); - - const response = await requestServer(`${GET_PASSENGER_BOSS}?${params}`, 'get'); - const _chunkSize = 6; - const _data = response.data.data; - const chunk = Array.from({length: Math.ceil(_data.length / _chunkSize)}, (v, i) => - _data.slice(i * _chunkSize, i * _chunkSize + _chunkSize) - ); - return chunk; - } catch (error) { - setLoading(false); - throw error; // Propagate the error - } - }); - - try { - const chunks = await Promise.all(requests); - setLoading(false); - return chunks.flat(); // Flatten the chunks into a single array - } catch (error) { - console.error("Error processing requests:", error); - throw error; - } - }; - - const clickHandler = async () => { - try { - const chunks = await filterRequest([ - { - id: "vehicle_type", - value: "اتوبوس", - fn: "contains", - datatype: "text", - }, - { - id: "vehicle_type", - value: "مینی بوس", - fn: "contains", - datatype: "text", - }, - ]); - setPrintPage(chunks.length); - setPrintTitle(t('PassengerBoss.print_form_a')); - sessionStorage.setItem('form-a-print', JSON.stringify(chunks)); - router.push('/dashboard/passenger-boss/prints/form-a'); - } catch (error) { - console.error("Error in clickHandler:", error); - } - }; - return ( - - ) -} - -export default PrintFormA \ No newline at end of file diff --git a/src/components/dashboard/passenger-boss/Buttons/printFormB.jsx b/src/components/dashboard/passenger-boss/Buttons/printFormB.jsx deleted file mode 100644 index 8380b07..0000000 --- a/src/components/dashboard/passenger-boss/Buttons/printFormB.jsx +++ /dev/null @@ -1,47 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useRouter} from "next/router"; -import {useState} from "react"; -import useRequest from "@/lib/app/hooks/useRequest"; -import usePrint from "@/lib/app/hooks/usePrint"; -import {GET_PASSENGER_BOSS} from "@/core/data/apiRoutes"; -import {Button, CircularProgress} from "@mui/material"; -import PrintIcon from "@mui/icons-material/Print"; - -const PrintFormB = () => { - 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 clickHandler = () => { - 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_form_b')) - sessionStorage.setItem('form-b-print', JSON.stringify(_data)) - router.push('/dashboard/passenger-boss/prints/form-b') - }).catch(() => { - setLoading(false) - }) - } - return ( - - ) -} - -export default PrintFormB \ No newline at end of file diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx index ff140ba..b9dbf5f 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx @@ -6,88 +6,36 @@ import { DialogActions, DialogContent, FormHelperText, - Grid, - LinearProgress, Stack, TextField, Typography } from "@mui/material" import {useFormik} from "formik"; import {useTranslations} from "next-intl"; -import {CONFIRM_PASSENGER_BOSS, EXPORT_PASSENGER_BOSS_DETAILS,} from "@/core/data/apiRoutes"; -import {useEffect, useState} from "react"; +import {CONFIRM_PASSENGER_BOSS} from "@/core/data/apiRoutes"; +import {useState} from "react"; import PriceField from "@/core/components/PriceField"; import * as Yup from "yup"; -import CustomAccordion from "@/core/components/CustomAccordion"; -import ImageContent from "@/core/components/ImageContent"; -import NumberShowBox from "@/core/components/NumberShowBox"; +import SelectBox from "@/core/components/SelectBox"; const vehicle_amount = { "اتوبوس": 7000, "مینی بوس": 2000, } -const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, handleSizeChangeClick}) => { + +const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type}) => { const t = useTranslations(); - const [selectedImageAForm, setSelectedImageAForm] = useState(""); - const [selectedImageBForm, setSelectedImageBForm] = useState(""); - const [fileTypesA, setFileTypesA] = useState(null); - const [fileNamesA, setFileNamesA] = useState(null); - const [fileTypesB, setFileTypesB] = useState(null); - const [fileNamesB, setFileNamesB] = useState(null); - const [showAddIconA, setShowAddIconA] = useState(true); - const [showAddIconB, setShowAddIconB] = useState(true); + const [selectedImage, setSelectedImage] = useState(""); + const [expertImg, setExpertImg] = useState(""); + const [fileType, setFileType] = useState(null); + const [fileName, setFileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const [expertFileType, setExpertFileType] = useState(null); + const [expertFileName, setExpertFileName] = useState(null); + const [showExpertAddIcon, setShowExpertAddIcon] = useState(true); const requestServer = useRequest({auth: true, notification: false}) const {update_notification} = useNotification(); - const [attachmentsData, setAttachmentsData] = useState([]); - const [accordionStates, setAccordionStates] = useState([]); - const [hasImageShown, setHasImageShown] = useState(false); - const [imageLink, setImageLink] = useState(null); - const [detailsList, setDetailsData] = useState(null); - const [loading, setLoading] = useState(true); - const [isSkeleton, setIsSkeleton] = useState(false); - - useEffect(() => { - requestServer(`${EXPORT_PASSENGER_BOSS_DETAILS}/${rowId}`, 'get') - .then((response) => { - const allAttachments = []; - response.data.data.histories.map((history) => { - history.attachments.map((attachment) => { - allAttachments.push(attachment); - }); - }); - setDetailsData(response.data); - setAttachmentsData(allAttachments); - setDetailsData(response.data) - }) - .catch(() => { - }).finally(() => { - setLoading(false); - }); - }, []); - - useEffect(() => { - if (attachmentsData.length !== 0) { - const booleanData = Array.from({length: attachmentsData.length}, () => false); - setAccordionStates(booleanData); - } - }, [attachmentsData]); - - const handleAccordionChange = (index) => { - const newAccordionStates = accordionStates.map((state, i) => i === index ? !state : false); - setAccordionStates(newAccordionStates); - - if (!newAccordionStates[index]) { - handleSizeChangeClick('sm'); - setHasImageShown(false); - setIsSkeleton(false) - } else { - handleSizeChangeClick('xl'); - setHasImageShown(true); - setImageLink(attachmentsData[index]) - setIsSkeleton(true) - } - }; - + const [showFacility, setShowFacility] = useState(false) const validationSchema = Yup.object().shape({ approved_amount: Yup.mixed().test( @@ -98,22 +46,87 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand (value) => value <= vehicle_amount[vehicle_type]) .test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.approved_amount_error")), - first_img: Yup.mixed() - .required(t("PassengerBoss.upload_file_first_required")) + bank_facility: Yup.mixed().test( + "is-number", + `${t("ConfirmDialog.bank_facility_number")}`, + (value) => !isNaN(value) + ).test("positive", `${t("ConfirmDialog.bank_facility_positive")}`, (value) => value >= 0) + .test("max_bank", `${t("ConfirmDialog.bank_facility_max_amount")}`, function (value) { + const government_facility = this.parent.government_facility || 0; + const max_amount = (this.parent.approved_amount || 0) - government_facility; + return value <= max_amount; + }) + .required(t("ConfirmDialog.bank_facility_error")), + government_facility: Yup.mixed() + .test( + "is-number", + `${t("ConfirmDialog.government_facility_number")}`, + (value) => !isNaN(value) + ) + .test("positive", `${t("ConfirmDialog.government_facility_positive")}`, (value) => value >= 0) + .test("max_government", `${t("ConfirmDialog.government_facility_max_amount")}`, function (value) { + const bank_facility = this.parent.bank_facility || 0; + const max_amount = (this.parent.approved_amount || 0) - bank_facility; + return value <= max_amount; + }) + .required(t("ConfirmDialog.government_facility_error")), + repayment_period: Yup.mixed().test( + "is-number", + `${t("ConfirmDialog.repayment_period_number")}`, + (value) => !isNaN(value) + ).test("positive", `${t("ConfirmDialog.repayment_period_positive")}`, (value) => value >= 0) + .required(t("ConfirmDialog.repayment_period_error")), + participation_period: Yup.mixed().test( + "is-number", + `${t("ConfirmDialog.participation_period_number")}`, + (value) => !isNaN(value) + ).test("positive", `${t("ConfirmDialog.participation_period_positive")}`, (value) => value >= 0) + .required(t("ConfirmDialog.participation_period_error")), + + committed_employment: Yup.mixed().test( + "is-number", + `${t("ConfirmDialog.committed_employment_number")}`, + (value) => !isNaN(value) + ).test("positive", `${t("ConfirmDialog.committed_employment_positive")}`, (value) => value >= 0) + .required(t("ConfirmDialog.committed_employment_error")), + available_jobs: Yup.mixed().test( + "is-number", + `${t("ConfirmDialog.available_jobs_number")}`, + (value) => !isNaN(value) + ).test("positive", `${t("ConfirmDialog.available_jobs_positive")}`, (value) => value >= 0) + .required(t("ConfirmDialog.available_jobs_error")), + sakht_period: Yup.mixed() + .test("is-number", `${t("ConfirmDialog.sakht_period_number")}`, + (value) => !isNaN(value)) + .test("positive", `${t("ConfirmDialog.sakht_period_positive")}`, (value) => value > 0) + .required(t("ConfirmDialog.sakht_period_error")), + tanafos_period: Yup.mixed() + .test("is-number", `${t("ConfirmDialog.tanafos_period_number")}`, + (value) => !isNaN(value)) + .test("positive", `${t("ConfirmDialog.tanafos_period_positive")}`, (value) => value > 0) + .required(t("ConfirmDialog.tanafos_period_error")), + interest_rate: Yup.mixed() + .test("is-number", `${t("ConfirmDialog.interest_rate_number")}`, + (value) => !isNaN(value)) + .test("positive", `${t("ConfirmDialog.interest_rate_positive")}`, (value) => value > 0) + .required(t("ConfirmDialog.interest_rate_error")), + 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) => { - const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types + if (!value) return true + const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; return allowedTypes.includes(value.type); }), - second_img: Yup.mixed() - .required(t("PassengerBoss.upload_file_second_required")) - .test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => { + expert_img: Yup.mixed() + .required(t("PassengerBoss.upload_expert_file_required")) + .test('fileSize', `${t("PassengerBoss.upload_expert_file_unit")}`, (value) => { 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 + .test('fileType', `${t("PassengerBoss.upload_expert_file_format")}`, (value) => { + const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; return allowedTypes.includes(value.type); }) }); @@ -122,25 +135,62 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand initialValues: { description: "", approved_amount: "", - first_img: null, - second_img: null + bank_facility: "0", + government_facility: "0", + user_facility: "0", + physical_progress: "", + repayment_period: "", + participation_period: "", + interest_rate: "", + committed_employment: "", + sakht_period: "", + tanafos_period: "", + history_facilities: "0", + available_jobs: "", + expert_img: null, + confirm_img: null, }, validationSchema, onSubmit: (values, {setSubmitting}) => { const formData = new FormData(); - formData.append("approved_amount", values.approved_amount); + formData.append("bank_facility", values.bank_facility); + formData.append("government_facility", values.government_facility); + formData.append("user_facility", values.user_facility); + formData.append("repayment_period", values.repayment_period); + formData.append("participation_period", values.participation_period); + formData.append("interest_rate", values.interest_rate); + formData.append("committed_employment", values.committed_employment); + formData.append("available_jobs", values.available_jobs); + formData.append("sakht_period", values.sakht_period); + formData.append("tanafos_period", values.tanafos_period); + formData.append("history_facilities", values.history_facilities); if (values.description != "") formData.append("expert_description", values.description); - - const attachments = [ - {title: 'فرم الف', file: values.first_img}, - {title: 'فرم ب', file: values.second_img} - ]; - - attachments.forEach((attachment, index) => { - formData.append(`attachment[${index}][title]`, attachment.title); - formData.append(`attachment[${index}][file]`, attachment.file); - }); + if (values.physical_progress != "") formData.append("physical_progress", values.physical_progress); + if (values.confirm_img != null) { + const attachments = [ + { + title: "فایل ضمیمه کارتابل کارگروه", + file: values.confirm_img + } + ]; + attachments.forEach((attachment, index) => { + formData.append(`attachment[${index}][title]`, attachment.title); + formData.append(`attachment[${index}][file]`, attachment.file); + }); + } + if (values.expert_img != null) { + const attachments = [ + { + title: "فایل ضمیمه گزارش کارشناس", + file: values.expert_img + } + ]; + attachments.forEach((attachment, index) => { + formData.append(`attachment[${index}][title]`, attachment.title); + formData.append(`attachment[${index}][file]`, attachment.file); + }); + } requestServer(`${CONFIRM_PASSENGER_BOSS}/${rowId}`, 'post', { notification: true, @@ -156,197 +206,505 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand }, }); - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - - const handleUploadChangeAForm = (event) => { + const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; - setSelectedImageAForm(URL.createObjectURL(uploadedFile)); - setFileTypesA(fileType); - setFileNamesA(fileName); - formik.setFieldValue("first_img", uploadedFile).then(() => { - formik.setFieldTouched("first_img", true); + setSelectedImage(URL.createObjectURL(uploadedFile)); + setFileType(fileType); + setFileName(fileName); + formik.setFieldValue("confirm_img", uploadedFile).then(() => { + formik.setFieldTouched("confirm_img", true); }) - setShowAddIconA(false); + setShowAddIcon(false); } }; - const handleUploadChangeBForm = (event) => { + const handleExpertFileChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; - setSelectedImageBForm(URL.createObjectURL(uploadedFile)); - setFileTypesB(fileType); - setFileNamesB(fileName); - formik.setFieldValue("second_img", uploadedFile).then(() => { - formik.setFieldTouched("second_img", true); + setExpertImg(URL.createObjectURL(uploadedFile)); + setExpertFileType(fileType); + setExpertFileName(fileName); + formik.setFieldValue("expert_img", uploadedFile).then(() => { + formik.setFieldTouched("expert_img", true); }) - setShowAddIconB(false); + setShowExpertAddIcon(false); } }; const handleAmountChange = (event) => { if (!isNaN(event.target.value)) { - formik.setFieldValue("approved_amount", event.target.value) + formik.setFieldValue("approved_amount", event.target.value).then(() => { + formik.setFieldValue("user_facility", Number(event.target.value) - (Number(formik.values.bank_facility) + Number(formik.values.government_facility))) + }) + event.target.value !== "" ? setShowFacility(true) : setShowFacility(false) } else { formik.setFieldValue("approved_amount", formik.values.approved_amount) + setShowFacility(false) } }; - const renderCustomAccordions = () => { - if (attachmentsData) { - return attachmentsData.map((file, index) => ( - handleAccordionChange(index)} - accordionIndex={index} - downloadFile={file.file} - /> - )); - } - return null; - }; return ( <> - - - {loading ? : - <> - - - - {renderCustomAccordions()} - - } - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - - {t("ConfirmDialog.approved_amount")}{t("ConfirmDialog.unit")}} - type="text" - inputProps={{ - inputMode: "number", - min: 0, - pattern: "[0-9]*", - }} - variant="outlined" - 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}} - fullWidth - /> - - - - - {t("PassengerBoss.first_form")} - formik.handleBlur("first_img")} - error={ - formik.touched.first_img && - Boolean(formik.errors.first_img) - } - /> - - {formik.touched.first_img && formik.errors.first_img} - - - - {t("PassengerBoss.second_form")} - formik.handleBlur("second_img")} - error={ - formik.touched.second_img && - Boolean(formik.errors.second_img) - } - /> - - {formik.touched.second_img && formik.errors.second_img} - - - - - - - - - - - - + + + + {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={formik.handleChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + + {t("ConfirmDialog.approved_amount")}{t("ConfirmDialog.unit")}} + type="text" + inputProps={{ + inputMode: "number", + min: 0, + pattern: "[0-9]*", + }} + variant="outlined" + 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}} + fullWidth + /> + + + + {t("ConfirmDialog.bank_facility")}{t("ConfirmDialog.unit")}} + type="text" + inputProps={{ + inputMode: "number", + min: 0, + pattern: "[0-9]*", + }} + variant="outlined" + value={formik.values.bank_facility} + onChange={(event) => { + if (!isNaN(event.target.value)) { + formik.setFieldValue("bank_facility", event.target.value).then(() => { + formik.setFieldValue("user_facility", Number(formik.values.approved_amount) - (Number(event.target.value) + Number(formik.values.government_facility))) + }) + } else { + formik.setFieldValue("bank_facility", formik.values.bank_facility) + } + }} + onBlur={formik.handleBlur("bank_facility")} + error={ + formik.touched.bank_facility && + Boolean(formik.errors.bank_facility) + } + helperText={ + formik.touched.bank_facility && formik.errors.bank_facility + } + fullWidth + disabled={!showFacility} + /> + + + + {t("ConfirmDialog.government_facility")}{t("ConfirmDialog.unit")}} + type="text" + inputProps={{ + inputMode: "number", + min: 0, + pattern: "[0-9]*", + }} + variant="outlined" + value={formik.values.government_facility} + onChange={(event) => { + if (!isNaN(event.target.value)) { + formik.setFieldValue("government_facility", event.target.value).then(() => { + formik.setFieldValue("user_facility", Number(formik.values.approved_amount) - (Number(formik.values.bank_facility) + Number(event.target.value))) + }) + } else { + formik.setFieldValue("government_facility", formik.values.government_facility) + } + }} + onBlur={formik.handleBlur("government_facility")} + error={ + formik.touched.government_facility && + Boolean(formik.errors.government_facility) + } + helperText={ + formik.touched.government_facility && formik.errors.government_facility + } + disabled={!showFacility} + fullWidth + /> + + + + {t("ConfirmDialog.user_facility")}{t("ConfirmDialog.unit")}} + variant="outlined" + value={formik.values.user_facility} + disabled + fullWidth + /> + + + + {t("ConfirmDialog.physical_progress")}{t("ConfirmDialog.optional")}} + type="text" + inputProps={{ + inputMode: "number", + min: 0, + pattern: "[0-9]*", + }} + variant="outlined" + value={formik.values.physical_progress} + onChange={(event) => { + if (!isNaN(event.target.value)) { + formik.setFieldValue("physical_progress", event.target.value) + } else { + formik.setFieldValue("physical_progress", formik.values.physical_progress) + } + }} + onBlur={formik.handleBlur("physical_progress")} + fullWidth + /> + + + { + if (isNaN(event.target.value) || event.target.value > 100) formik.setFieldValue("interest_rate", formik.values.interest_rate) + else + formik.setFieldValue("interest_rate", event.target.value) + }} + onBlur={formik.handleBlur("interest_rate")} + error={ + formik.touched.interest_rate && + Boolean(formik.errors.interest_rate) + } + helperText={ + formik.touched.interest_rate && formik.errors.interest_rate + } + fullWidth + /> + + + + {t("ConfirmDialog.repayment_period")} {t("ConfirmDialog.month")}} + type="text" + inputProps={{ + inputMode: "number", + min: 0, + pattern: "[0-9]*", + }} + variant="outlined" + value={formik.values.repayment_period} + onChange={(event) => { + if (!isNaN(event.target.value)) { + formik.setFieldValue("repayment_period", event.target.value) + } else { + formik.setFieldValue("repayment_period", formik.values.repayment_period) + } + }} + onBlur={formik.handleBlur("repayment_period")} + error={ + formik.touched.repayment_period && + Boolean(formik.errors.repayment_period) + } + helperText={ + formik.touched.repayment_period && formik.errors.repayment_period + } + fullWidth + /> + + + + {t("ConfirmDialog.participation_period")} {t("ConfirmDialog.month")}} + type="text" + inputProps={{ + inputMode: "number", + min: 0, + pattern: "[0-9]*", + }} + variant="outlined" + value={formik.values.participation_period} + onChange={(event) => { + if (!isNaN(event.target.value)) { + formik.setFieldValue("participation_period", event.target.value) + } else { + formik.setFieldValue("participation_period", formik.values.participation_period) + } + }} + onBlur={formik.handleBlur("participation_period")} + error={ + formik.touched.participation_period && + Boolean(formik.errors.participation_period) + } + helperText={ + formik.touched.participation_period && formik.errors.participation_period + } + fullWidth + /> + + + { + formik.setFieldValue('sakht_period', event.target.value) + }} + setFieldTouched={formik.setFieldTouched} + error={formik.touched.sakht_period && Boolean(formik.errors.sakht_period)} + helperText={formik.touched.sakht_period && formik.errors.sakht_period} + onBlur={formik.handleBlur("sakht_period")} + /> + + + { + formik.setFieldValue('tanafos_period', event.target.value) + }} + setFieldTouched={formik.setFieldTouched} + error={formik.touched.tanafos_period && Boolean(formik.errors.tanafos_period)} + helperText={formik.touched.tanafos_period && formik.errors.tanafos_period} + onBlur={formik.handleBlur("tanafos_period")} + /> + + + { + if (!isNaN(event.target.value)) { + formik.setFieldValue("committed_employment", event.target.value) + } else { + formik.setFieldValue("committed_employment", formik.values.committed_employment) + } + }} + onBlur={formik.handleBlur("committed_employment")} + error={ + formik.touched.committed_employment && + Boolean(formik.errors.committed_employment) + } + helperText={ + formik.touched.committed_employment && formik.errors.committed_employment + } + fullWidth + /> + + + { + if (!isNaN(event.target.value)) { + formik.setFieldValue("available_jobs", event.target.value) + } else { + formik.setFieldValue("available_jobs", formik.values.available_jobs) + } + }} + onBlur={formik.handleBlur("available_jobs")} + error={ + formik.touched.available_jobs && + Boolean(formik.errors.available_jobs) + } + helperText={ + formik.touched.available_jobs && formik.errors.available_jobs + } + fullWidth + /> + + + { + formik.setFieldValue('history_facilities', event.target.value) + }} + setFieldTouched={formik.setFieldTouched} + error={formik.touched.history_facilities && Boolean(formik.errors.history_facilities)} + helperText={formik.touched.history_facilities && formik.errors.history_facilities} + onBlur={formik.handleBlur("history_facilities")} + /> + + + {t("PassengerBoss.upload_expert_img")} + + + {formik.touched.expert_img && formik.errors.expert_img} + + + + {t("PassengerBoss.upload_file")} + + + {formik.touched.confirm_img && formik.errors.confirm_img} + + + + + + + + ) + +} +export default ReserveForm; \ No newline at end of file diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx index cef474d..6a8b915 100644 --- a/src/components/dashboard/passenger-boss/TableRowActions.jsx +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -1,6 +1,7 @@ import {Box} from "@mui/material"; import Reject from "./Form/RejectForm" import Confirm from "./Form/ConfirmForm"; +import ReserveForm from "@/components/dashboard/passenger-boss/Form/ReserveForm"; const TableRow = ({row, mutate}) => { @@ -11,6 +12,10 @@ const TableRow = ({row, mutate}) => { vehicle_type={row.original.vehicle_type} mutate={mutate} /> + { return ( - - ) diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx index 8932e19..fb141d5 100644 --- a/src/components/dashboard/passenger-boss/index.jsx +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -289,53 +289,6 @@ function DashboardPassengerOfficeComponent() { ), }, - { - accessorFn: (row) => row.proposed_amount, - id: "proposed_amount", - header: t("PassengerBoss.proposed_amount"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue / 1000000} - ), - }, - { - accessorFn: (row) => row.sakht_period, - id: "sakht_period", - header: t("PassengerBoss.sakht_period"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.tanafos_period, - id: "tanafos_period", - header: t("PassengerBoss.tanafos_period"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals" - ], - Cell: ({renderedCellValue}) => ( - {renderedCellValue} - ), - }, { accessorFn: (row) => row.state_name, id: "state_id", diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index e860a13..f0d4774 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -39,7 +39,8 @@ 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 @@ -77,8 +78,6 @@ export const EXPORT_MACHINARY_OFFICE = export const GET_RESERVE_MACHINARY_LOAN = BASE_URL + "/dashboard/reserved_loan/show"; -export const RESERVE_MACHINARY_LOAN = - BASE_URL + "/dashboard/machinery_expert/reserve"; export const CANSEL_RESERVE_MACHINARY_LOAN = BASE_URL + "/dashboard/reserved_loan/unreserve";