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

1045 Dynamically name recurring events #1092

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
17 changes: 14 additions & 3 deletions client/src/components/manageProjects/createNewEvent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import '../../sass/ManageProjects.scss';
import { findNextOccuranceOfDay } from './utilities/findNextDayOccuranceOfDay';
import { addDurationToTime } from './utilities/addDurationToTime';
Expand All @@ -15,8 +15,9 @@ const CreateNewEvent = ({
}) => {
// These are the initial form values
const initialFormValues = {
name: `${projectName} Team Meeting`,
eventType: 'Team Meeting',
name: '',
eventType: '',
eventSubtype: '',
description: '',
videoConferenceLink: '',
day: '0',
Expand All @@ -31,6 +32,11 @@ const CreateNewEvent = ({
setFormValues({ ...formValues, [event.target.name]: event.target.value });
};

useEffect(() => {
let type = formValues.eventType, subtype = formValues.eventSubtype;
setFormValues({...formValues, name: type + " " + subtype});
}, [formValues.eventSubtype, formValues.eventType])

const handleEventCreate = () => {
const date = findNextOccuranceOfDay(formValues.day);
const startTimeDate = timeConvertFromForm(date, formValues.startTime);
Expand All @@ -55,6 +61,7 @@ const CreateNewEvent = ({
hacknight: 'Online',
brigade: 'Hack for LA',
eventType: formValues.eventType,
eventSubtype: formValues.eventSubtype,
description: formValues.description,
project: projectID,
date: startDateTimeGMT,
Expand Down Expand Up @@ -108,6 +115,10 @@ const CreateNewEvent = ({
type="button"
className="create-form-button"
onClick={() => {
if (formValues.eventType == null) {
FoxShaunR marked this conversation as resolved.
Show resolved Hide resolved
setFormErrors("Event type is blank. Select an event type.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be setting errors to an object with the key being the field name and the value being the error message:

setFormErrors({ eventType: "Event type is blank. Select an event type." })

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not fixed.

return;
}
handleFormSubmit();
}}
>
Expand Down
38 changes: 30 additions & 8 deletions client/src/components/manageProjects/eventForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@ const EventForm = ({
}) => {
// This creates the clock hours for the form
const clockHours = createClockHours();
const subtypes = [
'All Team',
'Data Science',
'UI/UX Design',
'UI/UX Design & Research',
'UI/UX Research',
'Engineering All',
'Engineering Front End',
'Engineering Back End',
'PM',
'PM & Org',
'Other',
];
return (
<div className="event-form-box">
{title && <h3 className="event-form-title">{title}</h3>}
<label className="event-form-label" htmlFor="name">
Event Name:
<input
id="name"
placeholder="Meeting name..."
name="name"
value={formValues.name}
onChange={handleInputChange}
maxLength={30}
/>
<p>{formValues.name}</p>
{formErrors?.name ? (
<div className="event-form-error">{formErrors.name}</div>
) : null}
Expand All @@ -37,10 +43,26 @@ const EventForm = ({
onChange={handleInputChange}
name="eventType"
>
<option value={null}>--Select--</option>
<option value="Team Meeting">Team Meeting</option>
<option value="Onboarding">Onboarding</option>
</select>
</label>
{formValues.eventType === 'Team Meeting' && (
<label className="event-form-label" htmlFor="eventSubtype">
Event Subtype:
<select
id="eventSubtype"
value={formValues.eventSubtype}
onChange={handleInputChange}
name="eventSubtype"
>
{subtypes.map((subtype) => (
<option value={subtype}>{subtype}</option>
))}
</select>
</label>
)}
<label className="event-form-label" htmlFor="day">
Day of the Week:
<select
Expand Down
4 changes: 2 additions & 2 deletions client/src/sass/ManageProjects.scss
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ div.editable-field {
padding: 10px;
position: relative;
border: solid black 2px;
display: flex;
flex-direction: column;
display: grid;
grid-template-columns: 1 1;
}

.event-form-box .event-form-title {
Expand Down