RejectModal.js 6.01 KB
import { Formik } from "formik";
import { Fragment, useState } from "react";
import { Button, Form, Modal } from "react-bootstrap";
import ReactSelect from "react-select";
import * as Yup from "yup";

const RejectModal = ({ show, handleClose }) => {
    const formValidationSchema = Yup.object().shape({
        email: Yup.string().required("Email Id is Required").email("Please Enter An Valid Email Id"),
        reason: Yup.string().required("Reason is Required"),
        comments: Yup.string().required("Comment is Required"),
    });

    const reasonOptions = [
        { value: "Not listed", label: "Not listed" }
    ]
    const [selectedOption, setSelectedOption] = useState(null);

    return (
        <Fragment>
            <Modal show={show} onHide={handleClose} aria-labelledby="contained-modal-title-vcenter"
                centered>
                <Modal.Body>
                    <div className="row">
                        <div className="col-12 col-lg-12">
                            <div className="px-3">
                                <p className="mphead">Reject reason</p>
                                <div className="form-container">
                                    <Formik
                                        initialValues={{
                                            email: "",
                                            reason: "",
                                            comments: "",
                                        }}
                                        validationSchema={formValidationSchema}
                                        onSubmit={(values) => {
                                        }}
                                    >
                                        {({ values, errors, touched, handleChange, handleBlur, handleSubmit }) => (
                                            <Form
                                                onSubmit={e => {
                                                    e.preventDefault();
                                                    handleSubmit();
                                                }}
                                            >
                                                <div className="input-group">
                                                    <label>Email Id</label>
                                                    <input type="text" name="email" onChange={handleChange} onBlur={handleBlur} value={values.email} placeholder="yourname@example.com" style={{ backgroundColor: "#EBEBEB", boxShadow: "1.63px 3.26px 4.07px 0px #FFFFFF40 inset", border: "none" }} />
                                                    {errors.email && touched.email && <span className="form-error">{errors.email}</span>}
                                                </div>
                                                <div className="input-group mb-1">
                                                    <label>Reason</label>
                                                    <select
                                                        name="reason"
                                                        onChange={handleChange}
                                                        onBlur={handleBlur}
                                                        value={values.reason}
                                                    >
                                                        <option value="">Select</option>
                                                        <option value="Not listed">Not listed</option>
                                                    </select>
                                                    {/* <ReactSelect
                                                        defaultValue={selectedOption}
                                                        onChange={setSelectedOption}
                                                        options={reasonOptions}
                                                    /> */}
                                                    {errors.reason && touched.reason && <span className="form-error">{errors.reason}</span>}
                                                </div>
                                                <div className="input-group">
                                                    <textarea rows={4} placeholder="Leave your comments here..." name="comments"
                                                        onChange={handleChange}
                                                        onBlur={handleBlur}
                                                        value={values.comments} />
                                                    {errors.comments && touched.comments && <span className="form-error">{errors.comments}</span>}
                                                </div>

                                                <div className="my-4">
                                                    <div className="d-flex justify-content-center">
                                                        <Button type="submit" variant="" className="btnAdd btnApprove m-0">
                                                            Submit
                                                        </Button>
                                                        <div className="px-1"></div>
                                                        <Button type="button" variant="" className="btnAdd btnReject m-0" onClick={handleClose}>
                                                            Cancel
                                                        </Button>
                                                    </div>
                                                </div>
                                            </Form>
                                        )}
                                    </Formik>
                                </div>
                            </div>
                        </div>
                    </div>
                </Modal.Body>
            </Modal>
        </Fragment>
    )
}
export default RejectModal;