Skip to content
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
2 changes: 1 addition & 1 deletion frontend/components/dialog/events/event-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function EventDialog({
<DialogHeader>
<DialogTitle className={"flex justify-between items-center"}>
<span className={"flex items-center"}>
{event ? (
{event?.title ? (
<>
<Edit2 size={18} className={"inline mr-2"} /> Event
bearbeiten
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/dialog/events/event-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export function EventForm({ event, edit, onCloseAction }: EventFormProps) {
from: formatDateToHHMM(event ? new Date(event.from) : new Date()),
to: formatDateToHHMM(
event ? new Date(event.to) : new Date(Date.now() + 30 * 60 * 1000)
),
),
topicIDs: event?.topics.map((t) => t.ID),
typeID: event?.type.ID,
needsTutors: event?.needsTutors ?? true,
Expand Down Expand Up @@ -208,8 +208,8 @@ export function EventForm({ event, edit, onCloseAction }: EventFormProps) {
registrationNeeded: data.registrationNeeded,
umbrellaID: data.umbrellaID,
};

if (event) await handleUpdate(data, newEvent);
if (event?.title) await handleUpdate(data, newEvent);
else await handleCreation(data, newEvent);
}

Expand Down
4 changes: 1 addition & 3 deletions frontend/components/event-calendar/day-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ export function DayView({
)}
onClick={() => {
if (user?.role !== Role.Admin) return
const startTime = currentDate;
startTime.set({ hour: hourValue });
startTime.set({ minute: quarter * 15 });
const startTime = currentDate.set({hour: hourValue}).set({minute: quarter * 15});
onEventCreateAction(startTime);
}}
/>
Expand Down
7 changes: 4 additions & 3 deletions frontend/components/event-calendar/event-calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export function EventCalendar({
setIsEventDialogOpen(true);
};

const handleEventCreate = (startTime: DateTime) => {
const handleEventCreate = (startTime: DateTime) => {
// Snap to 15-minute intervals
const minutes = startTime.minute;
const remainder = minutes % 15;
Expand Down Expand Up @@ -328,8 +328,9 @@ export function EventCalendar({
<Button
className="max-[479px]:aspect-square max-[479px]:p-0!"
onClick={() => {
setSelectedEvent(null); // Ensure we're creating a new event
setIsEventDialogOpen(true);
// setSelectedEvent(null); // Ensure we're creating a new event
handleEventCreate(DateTime.now())
// setIsEventDialogOpen(true);
}}
>
<PlusIcon
Expand Down
3 changes: 1 addition & 2 deletions frontend/components/event-calendar/month-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ export function MonthView({
date={day}
onClick={() => {
if (user?.role !== Role.Admin) return
const startTime = day;
startTime.set({ hour: DefaultStartHour });
const startTime = day.set({hour: DefaultStartHour});
onEventCreateAction(startTime);
}}
>
Expand Down
6 changes: 2 additions & 4 deletions frontend/components/event-calendar/week-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,8 @@ export function WeekView({
)}
onClick={() => {
if (user?.role !== Role.Admin) return
const startTime = day.setZone(TimeZone);
startTime.set({ hour: hourValue });
startTime.set({ minute: quarter * 15 });
onEventCreateAction(startTime);
const startTime = day.setZone(TimeZone).set({hour: hourValue}).set({minute: quarter * 15})
onEventCreateAction(startTime);
}}
/>
);
Expand Down
Loading