UNPKG

rap-react

Version:

To make it easy for you to get started with GitLab, here's a list of recommended next steps.

47 lines (42 loc) 1.18 kB
import { useContext, useState } from "react"; import { forwardRef, useImperativeHandle } from "react"; import { FeedbackBox } from "./../feedbackBox"; import { ResetPasswordBox } from "./../resetPassword"; import loaderContext from "../../../context/loader/LoaderContext"; export const DialogBox = forwardRef((props, ref) => { const [open, setOpen] = useState(false); const [which, setWhich] = useState(null); const { updateLoaderStatus } = useContext(loaderContext); useImperativeHandle(ref, () => ({ handleSendFeedback() { setWhich(0); setOpen(true); }, handleResetPassword() { setWhich(1); setOpen(true); }, })); const callSetShow = () => { setOpen(false); updateLoaderStatus(false); }; return ( <> {which === 0 && ( <FeedbackBox open={open} callSetShow={callSetShow} callOpen={setOpen} ></FeedbackBox> )} {which === 1 && ( <ResetPasswordBox open={open} callSetShow={callSetShow} callOpen={setOpen} ></ResetPasswordBox> )} </> ); });