Skip to content

Commit ebddc35

Browse files
committed
#2131 helper text
1 parent 5dfee5a commit ebddc35

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/frontend/src/pages/CalendarPage/DesignReviewCreateModal.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Autocomplete,
77
Box,
88
FormControl,
9+
FormHelperText,
910
FormLabel,
1011
Grid,
1112
MenuItem,
@@ -32,7 +33,10 @@ const schema = yup.object().shape({
3233
date: yup.date().required('Date is required'),
3334
startTime: yup.number().required('Start time is required'),
3435
teamTypeId: yup.string().required('Team Type is required'),
35-
endTime: yup.number().min(yup.ref('startTime'), `End time can't be before start time`).required('End time is required')
36+
endTime: yup
37+
.number()
38+
.moreThan(yup.ref('startTime'), `End time must be after the start time`)
39+
.required('End time is required')
3640
});
3741

3842
interface CreateDesignReviewFormInput {
@@ -73,6 +77,7 @@ export const DesignReviewCreateModal: React.FC<DesignReviewCreateModalProps> = (
7377
error: allWorkPackagesError,
7478
data: allWorkPackages
7579
} = useAllWorkPackages();
80+
const [teamError, setTeamError] = useState(true);
7681

7782
const { mutateAsync } = useCreateDesignReviews();
7883

@@ -183,6 +188,7 @@ export const DesignReviewCreateModal: React.FC<DesignReviewCreateModalProps> = (
183188
/>
184189
)}
185190
/>
191+
<FormHelperText error>{errors.date?.message}</FormHelperText>
186192
</FormControl>
187193

188194
<FormControl>
@@ -221,6 +227,7 @@ export const DesignReviewCreateModal: React.FC<DesignReviewCreateModalProps> = (
221227
</Select>
222228
)}
223229
/>
230+
<FormHelperText error>{errors.startTime?.message}</FormHelperText>
224231
</FormControl>
225232
<FormControl>
226233
<FormLabel sx={{ alignSelf: 'start', paddingTop: '10px' }}>Meeting End Time</FormLabel>
@@ -258,6 +265,7 @@ export const DesignReviewCreateModal: React.FC<DesignReviewCreateModalProps> = (
258265
</Select>
259266
)}
260267
/>
268+
<FormHelperText error>{errors.endTime?.message}</FormHelperText>
261269
</FormControl>
262270
</Box>
263271
<Grid container gap={1}>
@@ -272,6 +280,7 @@ export const DesignReviewCreateModal: React.FC<DesignReviewCreateModalProps> = (
272280
placeholder="Select a work package"
273281
value={wbsDropdownOptions.find((element) => element.id === wbsNum) || null}
274282
/>
283+
{wbsNum === '' && <FormHelperText error>Work Package is required</FormHelperText>}
275284
</Grid>
276285
<Grid item xs={3}>
277286
<FormControl>
@@ -292,7 +301,10 @@ export const DesignReviewCreateModal: React.FC<DesignReviewCreateModalProps> = (
292301
<Typography style={{ color: 'gray' }}>Select Subteam</Typography>
293302
);
294303
}}
295-
onChange={(event: SelectChangeEvent<string>) => onChange(event.target.value)}
304+
onChange={(event: SelectChangeEvent<string>) => {
305+
setTeamError(false);
306+
return onChange(event.target.value);
307+
}}
296308
sx={{ height: 56, width: '100%', textAlign: 'left' }}
297309
MenuProps={{
298310
anchorOrigin: {
@@ -315,6 +327,7 @@ export const DesignReviewCreateModal: React.FC<DesignReviewCreateModalProps> = (
315327
</Select>
316328
)}
317329
/>
330+
<FormHelperText error>{teamError ? 'Team Type is required' : errors.teamTypeId?.message}</FormHelperText>
318331
</FormControl>
319332
</Grid>
320333
</Grid>

0 commit comments

Comments
 (0)