diff --git a/src/App.jsx b/src/App.jsx
index f516d08..4815f28 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -8,7 +8,6 @@ import DummySuccessfulLogin from './pages/DummySuccessfulLogin';
import DummyVolunteerData from './pages/DummyVolunteerData';
import DummyVolunteerEvent from './pages/DummyVolunteerEvent';
import DummyStatsPage from './pages/DummyStatsPage';
-import DummyVolunteerRegistrationForm from './pages/DummyVolunteerRegistrationForm';
import DummyCheckin from './pages/DummyCheckin';
import DummyEventCreation from './pages/DummyEventCreation';
import Login from './pages/Login';
@@ -16,6 +15,7 @@ import Playground from './components/Playground/Playground';
import EventCardTest from './pages/EventCardTest';
import DataEntryModalTestPage from './pages/DataEntryModalTestPage';
import Register from './pages/Register';
+import SelectEvent from './pages/SelectEvent';
import DummyVolunteerQR from './pages/DummyVolunteerQR';
import DummyAdminQR from './pages/DummyAdminQR';
@@ -32,7 +32,7 @@ const App = () => {
Placeholder for the waiver signing page
- ); -} + const { eventId } = useParams(); + const [waiverText, setWaiverText] = useState(''); + + const defaultValues = { + volunteer_id: '', + firstName: '', + lastName: '', + number_in_party: '', + checked: undefined, + }; + + const getWaiver = async () => { + try { + const response = await Backend.get(`/events/${eventId}`); + setWaiverText(response.data.waiver); + } catch (err) { + console.log(err); + } + }; + + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ resolver: yupResolver(schema), defaultValues }); + + const postVolunteerData = async formData => { + console.log(formData); + + const submitData = { + volunteer_id: formData.volunteer_id, + number_in_party: formData.number_in_party, + event_id: eventId, + is_checked_in: false, + pounds: 0, + ounces: 0, + }; + + try { + await Backend.post('/data', submitData); + } catch (e) { + console.log('Error posting', e); + } + }; + + useEffect(() => { + getWaiver(); + }, []); + + return ( + + ); +}; -export default Register; \ No newline at end of file +export default Register; diff --git a/src/pages/DummyVolunteerRegistrationForm.jsx b/src/pages/SelectEvent.jsx similarity index 52% rename from src/pages/DummyVolunteerRegistrationForm.jsx rename to src/pages/SelectEvent.jsx index 3a300d2..cc1eed8 100644 --- a/src/pages/DummyVolunteerRegistrationForm.jsx +++ b/src/pages/SelectEvent.jsx @@ -1,16 +1,10 @@ import { useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; import Backend from '../utils/utils'; -import { - FormControl, - FormLabel, - Input, - Button, - Select, - FormErrorMessage, -} from '@chakra-ui/react'; +import { FormControl, FormLabel, Button, Select, FormErrorMessage } from '@chakra-ui/react'; import { yupResolver } from '@hookform/resolvers/yup'; import * as yup from 'yup'; +import { useNavigate } from 'react-router-dom'; const schema = yup.object({ volunteer_id: yup.string().required('ID required').max(10, 'ID exceeds 10 character limit'), @@ -18,22 +12,20 @@ const schema = yup.object({ event_id: yup.string().required('Event required'), }); -const DummyVolunteerRegistrationForm = () => { +const SelectEvent = () => { const [eventsData, setEventsData] = useState([]); + const [currEvent, setCurrEvent] = useState(''); + const navigate = useNavigate(); + const defaultValues = { - volunteer_id: '', - number_in_party: '', - pounds: 0, - ounces: 0, - unusual_items: '', - event_id: '', - is_checked_in: false, + firstName: '', + lastName: '', + email: '', }; const { register, - handleSubmit, formState: { errors }, } = useForm({ resolver: yupResolver(schema), defaultValues }); @@ -47,14 +39,8 @@ const DummyVolunteerRegistrationForm = () => { } }; - const postVolunteerData = async formData => { - try { - await Backend.post('/data', formData); - console.log('Submitted '); - console.log(formData); - } catch (e) { - console.log('Error posting', e); - } + const handleNewRoute = () => { + navigate(`/register/${currEvent}`); }; useEffect(() => { @@ -62,21 +48,7 @@ const DummyVolunteerRegistrationForm = () => { }, []); return ( -