From fa8e0ba1e755188ffc503ef0db5ac2206d50dbce Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Mon, 17 Jul 2023 14:27:47 +0330 Subject: [PATCH 1/4] prevent proposed amount to get negetive values --- .../dashboard/machinary-office/Form/ConfirmForm.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 754abce..4e7ac76 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -41,7 +41,9 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { setDescription(event.target.value); }; const handleAmountChange = (event) => { - setProposedAmount(event.target.value); + if (/^\d*$/.test(event.target.value)) { + setProposedAmount(event.target.value); + } formik.handleChange(event); }; @@ -65,6 +67,11 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { name="proposed_amount" label={t("MachinaryOffice.proposed_amount")} type="number" + inputProps={{ + min: 0, + inputMode: "numeric", + pattern: "[0-9]*", + }} variant="outlined" value={proposedAmount} onChange={handleAmountChange} From db19c29f896cd4cddde1545773014e0eddbfea6e Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Tue, 18 Jul 2023 09:49:09 +0330 Subject: [PATCH 2/4] description in cinfirm form --- public/locales/fa/app.json | 3 +- .../passenger-office/Form/ConfirmForm.jsx | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index b6bd06f..b553d3b 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -130,7 +130,8 @@ "context": "آیا از تایید این آیتم اطمینان دارید", "button-confirm": "تایید", "button-cancel": "بستن", - "amount_error": "وارد کردن مقدار پیشنهادی الزامیست" + "amount_error": "وارد کردن مقدار پیشنهادی الزامیست", + "description_error": "وارد کردن توضیحات الزامی است!" }, "RejectDialog": { "reject": "عدم تایید", diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx index 43c6bb3..08bbde6 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx @@ -6,11 +6,36 @@ import { DialogContentText, DialogActions, Button, + TextField, } from "@mui/material"; +import { useFormik } from "formik"; import { useTranslations } from "next-intl"; +import { useState } from "react"; const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); + const [description, setDescription] = useState(""); + + const formik = useFormik({ + initialValues: { + description: "", + fileData: null, + }, + onSubmit: () => { + const formData = new FormData(); + if (description !== "") + formData.append("expert_description", description); + // if (fileData !== null) formData.append("file", fileData); + handleClose(); + confirmData(CONFIRM_PASSENGER_OFFICE, rowId, formData); + }, + }); + + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; + const handleConfirm = () => { handleClose(); confirmData(CONFIRM_PASSENGER_OFFICE, rowId); @@ -20,6 +45,18 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} + + + {/* */} + + + {formik.errors.fileData && formik.errors.fileData} + {formik.values.fileData && + `Selected file: ${formik.values.fileData.name}`} + + - - {/* */} {formik.errors.fileData && formik.errors.fileData} - {formik.values.fileData && - `Selected file: ${formik.values.fileData.name}`} -