From a0fafed37f0c9d98db9e623074b71f9dbfc32ebf Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Tue, 18 Jul 2023 14:15:34 +0330 Subject: [PATCH] input file --- .../passenger-office/Form/ConfirmForm.jsx | 61 +++++++++---------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx index 82a84b6..8d39af1 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx @@ -8,17 +8,17 @@ import { Button, TextField, FormHelperText, - Input, } from "@mui/material"; import { useFormik } from "formik"; import { useTranslations } from "next-intl"; -import { useState } from "react"; +import { useRef, useState } from "react"; const MAX_FILE_SIZE_IN_BYTES = 2 * 1024 * 1024; const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); const [description, setDescription] = useState(""); const [fileData, setFileData] = useState(null); + const inputRef = useRef(null); const formik = useFormik({ initialValues: { @@ -35,18 +35,17 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { }, }); + const handleUploadClick = () => { + // 👇 We redirect the click event onto the hidden input element + inputRef.current?.click(); + }; + const handleDescriptionChange = (event) => { setDescription(event.target.value); formik.handleChange(event); }; - const handleConfirm = () => { - handleClose(); - confirmData(CONFIRM_PASSENGER_OFFICE, rowId); - }; - const handleFileChange = (e) => { - console.log("hiiii"); const selectedFile = e.target.files[0]; if (selectedFile) { const fileSizeInBytes = selectedFile.size; @@ -82,45 +81,41 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { sx={{ mt: 1 }} />
+ - - {/* */}
{formik.errors.fileData && formik.errors.fileData} - {formik.values.fileData && - `Selected file: ${formik.values.fileData.name}`} -