Skip to content

Commit b2f9d4b

Browse files
authored
Merge pull request #3968 from Northeastern-Electric-Racing/#3942-update-gantt-dropdown
#3942 update gantt dropdown
2 parents af21148 + 9e964a9 commit b2f9d4b

3 files changed

Lines changed: 41 additions & 8 deletions

File tree

src/backend/src/prisma/seed.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,23 @@ const performSeed: () => Promise<void> = async () => {
284284
}
285285
});
286286

287+
const miles = await prisma.car.create({
288+
data: {
289+
wbsElement: {
290+
create: {
291+
name: 'Miles',
292+
carNumber: 1,
293+
projectNumber: 0,
294+
workPackageNumber: 0,
295+
organizationId
296+
}
297+
}
298+
},
299+
include: {
300+
wbsElement: true
301+
}
302+
});
303+
287304
/**
288305
* Make an initial change request for car 1 using the wbs of the genesis project
289306
*/

src/frontend/src/pages/GanttPage/ProjectGanttChart/AddGanttProjectModal.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { yupResolver } from '@hookform/resolvers/yup';
2-
import { FormControl, FormHelperText, FormLabel } from '@mui/material';
3-
import { useForm } from 'react-hook-form';
2+
import { FormControl, FormHelperText, FormLabel, MenuItem, TextField } from '@mui/material';
3+
import { Controller, useForm } from 'react-hook-form';
4+
import { Car } from 'shared';
45
import * as yup from 'yup';
56
import NERFormModal from '../../../components/NERFormModal';
67
import ReactHookTextField from '../../../components/ReactHookTextField';
@@ -14,9 +15,10 @@ interface AddGanttProjectModalProps {
1415
showModal: boolean;
1516
handleClose: () => void;
1617
addProject: (project: { name: string; carNumber: number }) => void;
18+
cars: Car[];
1719
}
1820

19-
const AddGanttProjectModal: React.FC<AddGanttProjectModalProps> = ({ showModal, handleClose, addProject }) => {
21+
const AddGanttProjectModal: React.FC<AddGanttProjectModalProps> = ({ showModal, handleClose, addProject, cars }) => {
2022
const onSubmit = async (data: { name: string; carNumber: number }) => {
2123
addProject(data);
2224
handleClose();
@@ -40,20 +42,33 @@ const AddGanttProjectModal: React.FC<AddGanttProjectModalProps> = ({ showModal,
4042
open={showModal}
4143
onHide={handleClose}
4244
title="New Project"
43-
reset={() => reset({ name: '' })}
45+
reset={() => reset({ name: '', carNumber: 0 })}
4446
handleUseFormSubmit={handleSubmit}
4547
onFormSubmit={onSubmit}
4648
formId="new-project-form"
4749
showCloseButton
50+
paperProps={{ width: '350px' }}
4851
>
49-
<FormControl sx={{ marginRight: '10px' }}>
52+
<FormControl>
5053
<FormLabel>Project Name</FormLabel>
5154
<ReactHookTextField name="name" control={control} sx={{ width: 1 }} />
5255
<FormHelperText error>{errors.name?.message}</FormHelperText>
5356
</FormControl>
54-
<FormControl>
55-
<FormLabel>Car Number</FormLabel>
56-
<ReactHookTextField name="carNumber" control={control} sx={{ width: 1 }} />
57+
<FormControl fullWidth>
58+
<FormLabel>Car</FormLabel>
59+
<Controller
60+
name="carNumber"
61+
control={control}
62+
render={({ field: { onChange, value } }) => (
63+
<TextField select onChange={onChange} value={value} fullWidth>
64+
{cars?.toReversed().map((car) => (
65+
<MenuItem key={car.wbsElementId} value={car.wbsNum.carNumber}>
66+
{car.name}
67+
</MenuItem>
68+
))}
69+
</TextField>
70+
)}
71+
/>
5772
<FormHelperText error>{errors.carNumber?.message}</FormHelperText>
5873
</FormControl>
5974
</NERFormModal>

src/frontend/src/pages/GanttPage/ProjectGanttChart/ProjectGanttChartPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ const ProjectGanttChartPage: FC = () => {
465465
toast.error('No Team Selected');
466466
}
467467
}}
468+
cars={cars}
468469
/>
469470
);
470471
};

0 commit comments

Comments
 (0)