1- import React , { useState } from 'react' ;
1+ import { useState } from 'react' ;
22import { useHistory } from 'react-router-dom' ;
33import { useForm , useFormState } from 'react-hook-form' ;
44import {
@@ -13,7 +13,6 @@ import {
1313 RadioGroup ,
1414 Paper ,
1515} from '@mui/material' ;
16- import { styled } from '@mui/material/styles' ;
1716
1817import useAuth from '../hooks/useAuth' ;
1918import ProjectApiService from '../api/ProjectApiService' ;
@@ -29,28 +28,12 @@ import ChangesModal from './ChangesModal';
2928 * -the rest are inline
3029 */
3130
32- export const StyledButton = styled ( Button ) ( ( { theme } ) => ( {
33- width : '150px' ,
34- } ) ) ;
35-
36- const StyledFormControlLabel = styled ( FormControlLabel ) ( ( { theme } ) => ( {
37- width : 'max-content' ,
38- '& .MuiFormControlLabel-label' : {
39- fontSize : '14px' ,
40- } ,
41- } ) ) ;
42-
43- const StyledRadio = styled ( Radio ) ( ( { theme } ) => ( {
44- padding : '0px 0px 0px 0px' ,
45- marginRight : '.5rem' ,
46- } ) ) ;
47-
4831/**Project Form Component
4932 * -renders a form for creating and updating a project
5033
5134
5235/**
53-
36+
5437/**
5538 * Takes Array, formData, projectToEdit, handleChage, isEdit
5639 * submitForm, handleChange, and isEdit are for the edit forms.
@@ -146,11 +129,12 @@ export default function ProjectForm({
146129
147130 // Handles the location radio button change.
148131 const handleRadioChange = ( event ) => {
132+ alert ( event . target . value ) ;
149133 setLocationType ( event . target . value ) ;
150134 } ;
151135
152136 // Toggles the project view to edit mode change.
153- const handleEditMode = ( event ) => {
137+ const handleEditMode = ( ) => {
154138 setEditMode ( ! editMode ) ;
155139 // React hook form method to reset data back to original values. Triggered when Edit Mode is cancelled.
156140 reset ( {
@@ -212,16 +196,16 @@ export default function ProjectForm({
212196 onChange = { handleRadioChange }
213197 sx = { { mb : 0.5 } }
214198 >
215- < StyledFormControlLabel
199+ < FormControlLabel
216200 value = "remote"
217- control = { < StyledRadio size = "small" /> }
201+ control = { < Radio size = "small" /> }
218202 label = "Remote"
219203 disabled = { isEdit ? ! editMode : false }
220204 />
221205 < Box sx = { { width : '10px' } } />
222- < StyledFormControlLabel
206+ < FormControlLabel
223207 value = "in-person"
224- control = { < StyledRadio size = "small" /> }
208+ control = { < Radio size = "small" /> }
225209 label = "In-Person"
226210 disabled = { isEdit ? ! editMode : false }
227211 />
@@ -247,7 +231,8 @@ export default function ProjectForm({
247231 badge = { isEdit ? editIcon ( ) : addIcon ( ) }
248232 expandable = { true }
249233 >
250- < form
234+ < Box
235+ component = "form"
251236 id = "project-form"
252237 onSubmit = { handleSubmit ( ( data ) => {
253238 isEdit ? submitEditProject ( data ) : submitNewProject ( data ) ;
@@ -273,33 +258,39 @@ export default function ProjectForm({
273258 aria-describedby = "modal-modal-description"
274259 handleClose = { handleClose }
275260 />
276- </ form >
261+ </ Box >
277262 < Grid container justifyContent = "space-evenly" sx = { { my : 3 } } >
278263 < Grid item xs = "auto" >
279- < StyledButton
264+ < Button
280265 type = "submit"
281266 form = "project-form"
282267 variant = {
283268 ! isEdit ? 'secondary' : ! editMode ? 'contained' : 'secondary'
284269 }
285- cursor = "pointer"
270+ sx = { {
271+ width : '150px' ,
272+ cursor : 'pointer' ,
273+ } }
286274 disabled = { isEdit && isLoading ? ! editMode : false }
287275 >
288276 { isLoading ? < CircularProgress /> : 'Save' }
289- </ StyledButton >
277+ </ Button >
290278 </ Grid >
291279 < Grid item xs = "auto" >
292- < StyledButton
280+ < Button
293281 variant = "contained"
294- cursor = "pointer"
282+ sx = { {
283+ width : '150px' ,
284+ cursor : 'pointer' ,
285+ } }
295286 onClick = {
296287 ! editMode || Object . keys ( dirtyFields ) . length === 0
297288 ? checkFields
298289 : handleOpen
299290 }
300291 >
301292 Close
302- </ StyledButton >
293+ </ Button >
303294 </ Grid >
304295 </ Grid >
305296 </ TitledBox >
0 commit comments