Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Needs entry to student when selecting "other" #497

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions frontend/src/components/Modal/RiderModalInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { useForm } from 'react-hook-form';
import cn from 'classnames';
import { Button, Input, Label } from '../FormElements/FormElements';
Expand Down Expand Up @@ -63,7 +63,7 @@ const RiderModalInfo = ({
const localUserType = localStorage.getItem('userType');
const isEditing = rider !== undefined;
const isStudentEditing = isEditing && localUserType === 'Rider';

const [needsOption, setNeedsOption] = useState('');
return (
<form onSubmit={handleSubmit(beforeSubmit)} className={styles.form}>
<div className={cn(styles.inputContainer, styles.rideTime)}>
Expand Down Expand Up @@ -138,6 +138,7 @@ const RiderModalInfo = ({
name="needs"
aria-required="true"
ref={register({ required: true })}
onChange={(e) => setNeedsOption(e.target.value)}
>
{Object.values(Accessibility).map((value, index) => {
return (
Expand All @@ -147,6 +148,16 @@ const RiderModalInfo = ({
);
})}
</select>
{needsOption == 'Other' ? (
<Input
id="otherNeeds"
name="otherNeeds"
type="text"
placeholder="Please Specify Needs"
></Input>
) : (
<></>
)}
{errors.needs?.type === 'validate' && (
<p className={styles.error}>
Invalid needs. You can enter 'Assistant', 'Crutches', or
Expand Down
Loading