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

EventForm Refactor to Material UI #1844

Open
wants to merge 15 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 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
2 changes: 2 additions & 0 deletions client/src/components/manageProjects/createNewEvent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const CreateNewEvent = ({
startTime: '7:00pm',
duration: '1',
};

sasszz marked this conversation as resolved.
Show resolved Hide resolved
const [formValues, setFormValues] = useState(initialFormValues);
const [formErrors, setFormErrors] = useState({});
const { showSnackbar } = useSnackbar();
Expand Down Expand Up @@ -82,6 +83,7 @@ const CreateNewEvent = ({
}
setFormErrors(errors);
};

return (
<div>
<button
Expand Down
1 change: 1 addition & 0 deletions client/src/components/manageProjects/editableMeeting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const EditableMeeting = ({
handleInputChange={handleInputChange}
formValues={formValues}
formErrors={formErrors}
title="Edit Recurring Event"
JackHaeg marked this conversation as resolved.
Show resolved Hide resolved
>
<Box>
<Button
Expand Down
131 changes: 0 additions & 131 deletions client/src/components/manageProjects/eventForm.jsx

This file was deleted.

39 changes: 39 additions & 0 deletions client/src/components/manageProjects/eventForm/EventForm.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.event-form-box {
min-width: 100%;
min-height: 540px;
padding: 10px;
position: relative;
border: solid black 2px;
display: flex;
flex-direction: column;
gap: 20px;
background-color: white;

// Resets the label text size on Text Fields
// A global variable was interacting with MUI styles and overflowing the label
.MuiInputLabel-root {
font-size: inherit;
}

// Forces horizontal padding inside Text Fields
.MuiInputBase-input {
padding-left: 15px !important;
padding-right: 15px !important;
}

}

.event-form-title {
font-size: 20px;
}

.event-form-row {
display: flex;
flex-direction: row;
gap: 16px;
}

.event-form-error {
color: red;
margin-bottom: 10px;
}
152 changes: 152 additions & 0 deletions client/src/components/manageProjects/eventForm/eventForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import React from 'react';
import { createClockHours } from '../../../utils/createClockHours';
import {
Box,
TextField,
MenuItem,
Select,
FormControl,
InputLabel,
} from '@mui/material';
import './EventForm.scss';

const EventForm = ({
title,
formValues,
formErrors,
handleInputChange,
children,
}) => {
// This creates the clock hours for the form
const clockHours = createClockHours();

return (
<Box className="event-form-box">
{title && <h3 className="event-form-title">{title}</h3>}
<FormControl fullWidth>
<TextField
required
helperText={formErrors?.name ? formErrors?.name : ''}
error={formErrors?.name}
id="name"
name="name"
value={formValues.name}
label="Event Name:"
placeholder="Meeting name..."
onChange={handleInputChange}
/>
</FormControl>
<Box className="event-form-row">
<FormControl fullWidth>
<InputLabel id="event-type-label">Event Type</InputLabel>
<Select
labelId="event-type-label"
name="eventType"
value={formValues.eventType}
label="Event Type"
onChange={handleInputChange}
>
<MenuItem value="Team Meeting">Team Meeting</MenuItem>
<MenuItem value="Onboarding">Onboarding</MenuItem>
</Select>
</FormControl>
<FormControl fullWidth>
<InputLabel id="day-input-label">Day of the Week</InputLabel>
<Select
labelId="day-input-label"
id="day-input"
name="day"
value={formValues.day}
label="Day of the Week"
onChange={handleInputChange}
>
<MenuItem value="0">Sunday</MenuItem>
<MenuItem value="1">Monday</MenuItem>
<MenuItem value="2">Tuesday</MenuItem>
<MenuItem value="3">Wednesday</MenuItem>
<MenuItem value="4">Thursday</MenuItem>
<MenuItem value="5">Friday</MenuItem>
<MenuItem value="6">Saturday</MenuItem>
</Select>
</FormControl>
</Box>
<Box className="event-form-row">
<FormControl fullWidth>
<InputLabel id="start-time-label">Start Time</InputLabel>
<Select
labelId="start-time-label"
name="startTime"
value={formValues.startTime}
label="Start Time"
onChange={handleInputChange}
>
{clockHours.map((value) => {
return (
<MenuItem key={value} value={value}>
{value}
</MenuItem>
);
})}
</Select>
</FormControl>
<FormControl fullWidth>
<InputLabel id="duration-label">Duration</InputLabel>
<Select
labelId="duration-label"
id="duration"
name="duration"
value={formValues.duration}
label="Duration"
onChange={handleInputChange}
>
<MenuItem value=".5">.5</MenuItem>
<MenuItem value="1">1</MenuItem>
<MenuItem value="1.5">1.5</MenuItem>
<MenuItem value="2">2</MenuItem>
<MenuItem value="2.5">2.5</MenuItem>
<MenuItem value="3">3</MenuItem>
<MenuItem value="3.5">3.5</MenuItem>
<MenuItem value="4">4</MenuItem>
</Select>
</FormControl>
</Box>
<Box className="event-form-row">
<FormControl fullWidth>
<TextField
id="Description"
label="Description"
variant="outlined"
name="description"
fullWidth
value={formValues.description}
onChange={handleInputChange}
/>
</FormControl>
</Box>
<Box className="event-form-row">
<FormControl fullWidth>
<TextField
required
helperText={
formErrors?.videoConferenceLink
? formErrors?.videoConferenceLink
: ''
}
error={formErrors?.videoConferenceLink}
id="Meeting URL"
label="Meeting URL"
variant="outlined"
name="videoConferenceLink"
fullWidth
value={formValues.videoConferenceLink}
onChange={handleInputChange}
/>
</FormControl>
</Box>

{children}
</Box>
);
};

export default EventForm;
1 change: 1 addition & 0 deletions client/src/components/manageProjects/eventForm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './eventForm';
Loading
Loading