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

UI suggestions event edit modal #494

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions src/ui/components/EditEvent.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.ofc-form-grid {
display: grid;
grid-template-columns: auto 1fr;
gap: 10px;
margin-top: 10px;
align-items: center;
}
29 changes: 16 additions & 13 deletions src/ui/components/EditEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DateTime } from "luxon";
import * as React from "react";
import { useEffect, useRef, useState } from "react";
import { CalendarInfo, OFCEvent } from "../../types";
import "./EditEvent.css";

function makeChangeListener<T>(
setState: React.Dispatch<React.SetStateAction<T>>,
Expand Down Expand Up @@ -97,15 +98,15 @@ export const EditEvent = ({
defaultCalendarIndex,
}: EditEventProps) => {
const [date, setDate] = useState(
initialEvent
(initialEvent
? initialEvent.type === "single"
? initialEvent.date
: initialEvent.type === "recurring"
? initialEvent.startRecur
: initialEvent.type === "rrule"
? initialEvent.startDate
: ""
: ""
: "") || ""
);
const [endDate, setEndDate] = useState(
initialEvent && initialEvent.type === "single"
Expand Down Expand Up @@ -249,7 +250,9 @@ export const EditEvent = ({
</select>
</p>
<p>
{!isRecurring && (
{isRecurring ? (
<></>
) : (
<input
type="date"
id="date"
Expand All @@ -264,6 +267,7 @@ export const EditEvent = ({
<></>
) : (
<>
{!isRecurring && " @ "}
<input
type="time"
id="startTime"
Expand All @@ -274,7 +278,7 @@ export const EditEvent = ({
(x) => x
)}
/>
-
{" - "}
<input
type="time"
id="endTime"
Expand All @@ -289,22 +293,22 @@ export const EditEvent = ({
)}
</p>
<p>
<label htmlFor="allDay">All day event </label>
<input
id="allDay"
checked={allDay}
onChange={(e) => setAllDay(e.target.checked)}
type="checkbox"
/>
<label htmlFor="allDay">All day event</label>
</p>
<p>
<label htmlFor="recurring">Recurring Event </label>
<input
id="recurring"
checked={isRecurring}
onChange={(e) => setIsRecurring(e.target.checked)}
type="checkbox"
/>
<label htmlFor="recurring">Recurring Event</label>
</p>

{isRecurring && (
Expand All @@ -313,16 +317,15 @@ export const EditEvent = ({
value={daysOfWeek}
onChange={setDaysOfWeek}
/>
<p>
Starts recurring
<div className="ofc-form-grid">
<div>Start:</div>
<input
type="date"
id="startDate"
value={date}
// @ts-ignore
onChange={makeChangeListener(setDate, (x) => x)}
/>
and stops recurring
<div>Stop:</div>
<input
type="date"
id="endDate"
Expand All @@ -332,11 +335,10 @@ export const EditEvent = ({
(x) => x
)}
/>
</p>
</div>
</>
)}
<p>
<label htmlFor="task">Task Event </label>
<input
id="task"
checked={isTask}
Expand All @@ -345,11 +347,11 @@ export const EditEvent = ({
}}
type="checkbox"
/>
<label htmlFor="task">Task Event</label>
</p>

{isTask && (
<>
<label htmlFor="taskStatus">Complete? </label>
<input
id="taskStatus"
checked={
Expand All @@ -364,6 +366,7 @@ export const EditEvent = ({
}
type="checkbox"
/>
<label htmlFor="taskStatus">Complete</label>
</>
)}

Expand Down