@@ -8,7 +8,6 @@ import { Controller, useFieldArray, useForm } from 'react-hook-form';
88import { yupResolver } from '@hookform/resolvers/yup' ;
99import { ChangeRequestReason , ChangeRequestType , Project , ProposedSolution , wbsPipe , WorkPackage } from 'shared' ;
1010import { routes } from '../../utils/routes' ;
11- import PageBlock from '../../layouts/PageBlock' ;
1211import TextField from '@mui/material/TextField' ;
1312import FormHelperText from '@mui/material/FormHelperText' ;
1413import Box from '@mui/material/Box' ;
@@ -24,6 +23,7 @@ import {
2423 FormLabel ,
2524 IconButton ,
2625 MenuItem ,
26+ RadioGroup ,
2727 Select
2828} from '@mui/material' ;
2929import { FormInput } from './CreateChangeRequest' ;
@@ -37,6 +37,8 @@ import NERSuccessButton from '../../components/NERSuccessButton';
3737import { wbsNamePipe } from '../../utils/pipes' ;
3838import PageLayout from '../../components/PageLayout' ;
3939import { wbsNumComparator } from 'shared/src/validate-wbs' ;
40+ import { ChangeEvent } from 'react' ;
41+ import { NERButton } from '../../components/NERButton' ;
4042import { useQuery } from '../../hooks/utils.hooks' ;
4143
4244interface CreateChangeRequestViewProps {
@@ -169,31 +171,46 @@ const CreateChangeRequestsView: React.FC<CreateChangeRequestViewProps> = ({
169171 < ReactHookTextField
170172 required
171173 multiline
174+ rows = { 4 }
172175 control = { control }
173176 label = "Explain"
174- sx = { { flexGrow : 1 , mx : 1 , borderRadius : 2 } }
177+ sx = { { flexGrow : 1 , borderRadius : 2 , width : '100%' } }
175178 { ...register ( `why.${ index } .explain` ) }
176179 errorMessage = { errors . why ?. [ index ] ?. explain }
177180 />
178181 ) ;
179182 } ;
180183
181184 return (
182- < PageLayout title = "New Change Request" previousPages = { [ { name : 'Change Requests' , route : routes . CHANGE_REQUESTS } ] } >
183- < form
184- id = { 'create-standard-change-request-form' }
185- onSubmit = { ( e ) => {
186- e . preventDefault ( ) ;
187- e . stopPropagation ( ) ;
188- handleSubmit ( onSubmit ) ( e ) ;
189- } }
190- onKeyPress = { ( e ) => {
191- e . key === 'Enter' && e . preventDefault ( ) ;
192- } }
185+ < form
186+ id = { 'create-standard-change-request-form' }
187+ onSubmit = { ( e ) => {
188+ e . preventDefault ( ) ;
189+ e . stopPropagation ( ) ;
190+ handleSubmit ( onSubmit ) ( e ) ;
191+ } }
192+ onKeyPress = { ( e ) => {
193+ e . key === 'Enter' && e . preventDefault ( ) ;
194+ } }
195+ >
196+ < PageLayout
197+ stickyHeader
198+ title = "New Change Request"
199+ previousPages = { [ { name : 'Change Requests' , route : routes . CHANGE_REQUESTS } ] }
200+ headerRight = {
201+ < Box textAlign = "right" sx = { { mb : 2 } } >
202+ < NERFailButton variant = "contained" onClick = { handleCancel } sx = { { mx : 1 , width : 90 } } >
203+ Cancel
204+ </ NERFailButton >
205+ < NERSuccessButton variant = "contained" type = "submit" sx = { { mx : 1 , width : 90 , mt : { xs : 1 , md : 0 } } } >
206+ Submit
207+ </ NERSuccessButton >
208+ </ Box >
209+ }
193210 >
194- < PageBlock title = "Details ">
195- < Grid container spacing = { 2 } >
196- < Grid item xs = { 6 } >
211+ < Grid container spacing = { 2 } display = "flex" justifyContent = "space-between ">
212+ < Grid container item spacing = { 2 } xs = { 12 } md = { 6 } >
213+ < Grid item xs = { 12 } >
197214 < FormLabel > WBS</ FormLabel >
198215 < NERAutocomplete
199216 id = "wbs-autocomplete"
@@ -204,61 +221,75 @@ const CreateChangeRequestsView: React.FC<CreateChangeRequestViewProps> = ({
204221 value = { wbsDropdownOptions . find ( ( element ) => element . id === wbsNum ) || null }
205222 />
206223 </ Grid >
207- < Grid item xs = { 6 } >
224+ < Grid item xs = { 10 } >
208225 < FormControl fullWidth >
209226 < FormLabel > Type</ FormLabel >
210227 < Controller
211228 name = "type"
212229 control = { control }
213230 rules = { { required : true } }
214231 render = { ( { field : { onChange, value } } ) => (
215- < TextField select onChange = { onChange } value = { value } >
216- { permittedTypes . map ( ( t ) => (
217- < MenuItem key = { t } value = { t } >
218- { t }
219- </ MenuItem >
220- ) ) }
221- </ TextField >
232+ < RadioGroup onChange = { onChange } value = { value } >
233+ < Box display = "flex" flexDirection = { { xs : 'column' , md : 'row' } } sx = { { gap : 2 } } >
234+ { permittedTypes . map ( ( t ) => (
235+ < NERButton
236+ sx = { {
237+ fontSize : { xs : '0.8rem' , md : '1rem' } ,
238+ width : { xs : '83%' , md : 'auto' }
239+ } }
240+ key = { t }
241+ variant = { value === t ? 'contained' : 'outlined' }
242+ onClick = { ( ) => onChange ( t as 'ISSUE' | ChangeEvent < Element > ) }
243+ >
244+ { t }
245+ </ NERButton >
246+ ) ) }
247+ </ Box >
248+ </ RadioGroup >
222249 ) }
223250 />
224251 </ FormControl >
225252 </ Grid >
226253 < Grid item xs = { 12 } >
227254 < FormControl fullWidth >
228- < FormLabel > What</ FormLabel >
255+ < FormLabel > What needs to be changed? </ FormLabel >
229256 < ReactHookTextField
230257 name = "what"
231258 control = { control }
232259 multiline
233260 rows = { 4 }
234261 errorMessage = { errors . what }
235- placeholder = "What is the situation? "
262+ placeholder = "Explain * "
236263 />
237264 </ FormControl >
238265 </ Grid >
239266 < Grid item xs = { 12 } >
240267 < FormControl fullWidth >
241- < FormLabel > Why</ FormLabel >
268+ < FormLabel > Why does this need to be changed? </ FormLabel >
242269 < Box >
243270 { whys . map ( ( element , index ) => (
244- < Box display = "flex" flexDirection = "row" sx = { { mb : 1 } } >
245- < Select
246- { ...register ( `why.${ index } .type` ) }
247- sx = { { width : 200 } }
248- defaultValue = { element . type }
249- key = { element . id }
250- >
251- { Object . values ( ChangeRequestReason ) . map ( ( type ) => (
252- < MenuItem key = { type } value = { type } >
253- { type }
254- </ MenuItem >
255- ) ) }
256- </ Select >
257- { renderReasonInput ( index ) }
258- < IconButton type = "button" onClick = { ( ) => removeWhy ( index ) } >
259- < DeleteIcon />
260- </ IconButton >
261- </ Box >
271+ < Grid container xs = { 12 } display = "flex" flexDirection = "row" sx = { { mb : 1 } } >
272+ < Grid item xs = { 12 } >
273+ < Select
274+ { ...register ( `why.${ index } .type` ) }
275+ sx = { { width : { sx : 'auto' , md : 200 } , mr : 2 } }
276+ defaultValue = { element . type }
277+ key = { element . id }
278+ >
279+ { Object . values ( ChangeRequestReason ) . map ( ( type ) => (
280+ < MenuItem key = { type } value = { type } >
281+ { type }
282+ </ MenuItem >
283+ ) ) }
284+ </ Select >
285+ < IconButton color = "error" type = "button" onClick = { ( ) => removeWhy ( index ) } >
286+ < DeleteIcon />
287+ </ IconButton >
288+ </ Grid >
289+ < Grid item xs = { 12 } sx = { { mt : 1 , mb : 1 } } >
290+ { renderReasonInput ( index ) }
291+ </ Grid >
292+ </ Grid >
262293 ) ) }
263294 </ Box >
264295 < FormHelperText > { errors . why ?. message } </ FormHelperText >
@@ -276,20 +307,12 @@ const CreateChangeRequestsView: React.FC<CreateChangeRequestViewProps> = ({
276307 </ Button >
277308 </ Grid >
278309 </ Grid >
279- </ PageBlock >
280- < PageBlock title = "Proposed Solutions" >
281- < CreateProposedSolutionsList proposedSolutions = { proposedSolutions } setProposedSolutions = { setProposedSolutions } />
282- </ PageBlock >
283- < Box textAlign = "right" >
284- < NERFailButton variant = "contained" onClick = { handleCancel } sx = { { mx : 1 } } >
285- Cancel
286- </ NERFailButton >
287- < NERSuccessButton variant = "contained" type = "submit" sx = { { mx : 1 } } >
288- Submit
289- </ NERSuccessButton >
290- </ Box >
291- </ form >
292- </ PageLayout >
310+ < Grid item xs = { 12 } md = { 5 } sx = { { mt : - 2 } } >
311+ < CreateProposedSolutionsList proposedSolutions = { proposedSolutions } setProposedSolutions = { setProposedSolutions } />
312+ </ Grid >
313+ </ Grid >
314+ </ PageLayout >
315+ </ form >
293316 ) ;
294317} ;
295318
0 commit comments