diff --git a/client/src/App.js b/client/src/App.js index 6fabda93..5f2ee671 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -3,10 +3,11 @@ import Modal from "features/modal/Modal"; import RejectionModal from "features/modal/RejectionModal"; import WelcomeUserModal from "features/modal/WelcomeUserModal"; import { useAuthContext } from "contexts/AuthContext"; +import FormProvider from "contexts/FormContext"; import LandingPage from "pages/LandingPage"; import CalendarPage from "pages/CalendarPage"; import { AdminDashboard } from "pages/AdminDashboard"; -import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; +import { Routes, Route } from "react-router-dom"; function App() { const auth = useAuthContext(); @@ -38,7 +39,14 @@ function App() { <> } /> - } /> + + + + } + /> } /> {isAuthenticated && ( diff --git a/client/src/contexts/FormContext/useProvideForm.js b/client/src/contexts/FormContext/useProvideForm.js index 5fb9ead1..fd3d33d0 100644 --- a/client/src/contexts/FormContext/useProvideForm.js +++ b/client/src/contexts/FormContext/useProvideForm.js @@ -15,6 +15,13 @@ const useProvideForm = () => { const [formCreateEventErrors, setFormCreateEventErrors] = useState([]); const [formScheduleEventErrors, setFormScheduleEventErrors] = useState([]); + const resetForm = () => { + if (currentStep === 4) { + setFormData({ recurring: { rate: "noRecurr", days: [] } }); + setCurrentStep(1); + } + }; + const handleNewStep = async direction => { const newStep = direction === "next" ? currentStep + 1 : currentStep - 1; @@ -62,6 +69,7 @@ const useProvideForm = () => { setFormCreateEventErrors, setFormScheduleEventErrors, setCurrentStep, + resetForm, }; }; diff --git a/client/src/features/form/FormCreateEvent.js b/client/src/features/form/FormCreateEvent.js index e8c05320..f84df7e9 100644 --- a/client/src/features/form/FormCreateEvent.js +++ b/client/src/features/form/FormCreateEvent.js @@ -21,7 +21,7 @@ export default function FormCreateEvent() {
{formCreateEventErrors.map((error, index) => { return ( -
+
{formScheduleEventErrors.map((error, index) => { return ( -
+
@@ -14,12 +14,7 @@ export default function FormSuccess() { {/* A button to add another event if so desired */} diff --git a/client/src/features/modal/Modal.jsx b/client/src/features/modal/Modal.jsx index 58a5db01..907bdfc1 100644 --- a/client/src/features/modal/Modal.jsx +++ b/client/src/features/modal/Modal.jsx @@ -2,7 +2,7 @@ import { AnimatePresence } from "framer-motion"; import Backdrop from "./Backdrop"; import { motion } from "framer-motion"; -const Modal = ({ children, context }) => { +const Modal = ({ children, context, onBackdropClick }) => { const dropIn = { hidden: { y: "-100vh", @@ -32,7 +32,12 @@ const Modal = ({ children, context }) => { onExitComplete={() => null} > {context.isOpen && ( - + { + context.handleClose(); + if (typeof onBackdropClick === "function") onBackdropClick(); + }} + > e.stopPropagation()} diff --git a/client/src/pages/CalendarPage.js b/client/src/pages/CalendarPage.js index 44c58877..c0920cc1 100644 --- a/client/src/pages/CalendarPage.js +++ b/client/src/pages/CalendarPage.js @@ -1,7 +1,7 @@ import useDate from "hooks/useDate"; import Calendar from "../features/calendar/Calendar"; import CalendarHeader from "../features/calendarHeader"; -import FormProvider from "contexts/FormContext"; +import { useFormContext } from "contexts/FormContext"; import Modal from "features/modal/Modal"; import UserForm from "features/form/UserForm"; import { useAuthContext } from "contexts/AuthContext"; @@ -16,6 +16,7 @@ function CalendarPage() { const date = useDate(); const formModal = useFormModalContext(); const modal = useModalContext(); + const { resetForm } = useFormContext(); const canScrollMonthRef = useRef(true); const handleWheelScroll = e => { @@ -33,7 +34,7 @@ function CalendarPage() { }; return ( - + <>
- + {auth?.user ? ( ) : ( @@ -53,7 +54,7 @@ function CalendarPage() { )}
- + ); } export default CalendarPage; diff --git a/cypress/e2e/create-event-form.cy.js b/cypress/e2e/create-event-form.cy.js index f0420300..fbb0514e 100644 --- a/cypress/e2e/create-event-form.cy.js +++ b/cypress/e2e/create-event-form.cy.js @@ -201,7 +201,6 @@ describe("Event Creation Form", () => { cy.contains("button", "Test Title"); tgt.calendar.button.addEvent().click(); - cy.contains("button", "New Event").click(); tgt.createForm.input.title().should("exist"); }); @@ -281,5 +280,8 @@ describe("Event Creation Form", () => { "have.length.of.at.least", 2 ); + + tgt.calendar.button.addEvent().click(); + tgt.createForm.input.title().should("exist"); }); });