diff --git a/src/app/(main)/events/[eventID]/page.tsx b/src/app/(main)/events/[eventID]/page.tsx index 81b98cf..c11e028 100644 --- a/src/app/(main)/events/[eventID]/page.tsx +++ b/src/app/(main)/events/[eventID]/page.tsx @@ -40,14 +40,12 @@ export default function ShowEvent() { if (isLoading || userLoading) { return ( -
- Loading... -
+
Loading...
); } if (error || !eventData?.data?.event) { return ( -
+
Error loading event.
); @@ -70,167 +68,169 @@ export default function ShowEvent() { }; return ( - - +
+ + - -
-
-
-
- + +
+
+
+
+ +
+
+

+ {event.title || 'Untitled Event'} +

+
+
-
-

- {event.title || 'Untitled Event'} -

-
-
-
-
-
- - -
-
- - -
-
- - -
-
-
-
- - + + +
); } diff --git a/src/app/(main)/events/new/page.tsx b/src/app/(main)/events/new/page.tsx index 997a9d6..1dc1bde 100644 --- a/src/app/(main)/events/new/page.tsx +++ b/src/app/(main)/events/new/page.tsx @@ -4,7 +4,7 @@ import { Suspense } from 'react'; export default function NewEvent() { return ( -
+
diff --git a/src/app/(main)/events/page.tsx b/src/app/(main)/events/page.tsx index f0391dd..bcd1e57 100644 --- a/src/app/(main)/events/page.tsx +++ b/src/app/(main)/events/page.tsx @@ -17,7 +17,7 @@ export default function Events() { const events = eventsData?.data?.events || []; return ( -
+
{/* Heading */}

My Events diff --git a/src/components/calendar.tsx b/src/components/calendar.tsx index e19101a..ab23c35 100644 --- a/src/components/calendar.tsx +++ b/src/components/calendar.tsx @@ -233,7 +233,7 @@ function CalendarWithUserEvents({ resourceTitleAccessor={(event) => event.title} startAccessor={(event) => event.start} endAccessor={(event) => event.end} - selectable={sesstion.data?.user?.id === userId && !additionalEvents} + selectable={sesstion.data?.user?.id === userId} onEventDrop={(event) => { const { start, end, event: droppedEvent } = event; if (droppedEvent.type === 'blocked_private') return; diff --git a/src/components/forms/event-form.tsx b/src/components/forms/event-form.tsx index 2a2912c..d4fb216 100644 --- a/src/components/forms/event-form.tsx +++ b/src/components/forms/event-form.tsx @@ -51,7 +51,12 @@ const EventForm: React.FC = (props) => { const startFromUrl = searchParams.get('start'); const endFromUrl = searchParams.get('end'); - const { mutate: createEvent, status, isSuccess, error } = usePostApiEvent(); + const { + mutateAsync: createEvent, + status, + isSuccess, + error, + } = usePostApiEvent(); const { data, isLoading, error: fetchError } = useGetApiUserMe(); const { data: eventData } = useGetApiEventEventID(props.eventId!, { query: { enabled: props.type === 'edit' }, @@ -150,8 +155,10 @@ const EventForm: React.FC = (props) => { participants: selectedParticipants.map((u) => u.id), }; + let eventID: string | undefined; + if (props.type === 'edit' && props.eventId) { - await patchEvent.mutateAsync({ + const mutationResult = await patchEvent.mutateAsync({ eventID: props.eventId, data: { title: data.title, @@ -162,9 +169,12 @@ const EventForm: React.FC = (props) => { participants: data.participants, }, }); + eventID = mutationResult.data.event.id; console.log('Updating event'); } else { console.log('Creating event'); + const mutationResult = await createEvent({ data }); + eventID = mutationResult.data.event.id; createEvent({ data }); } @@ -173,7 +183,7 @@ const EventForm: React.FC = (props) => { toastId={t} title='Event saved' description={event?.title} - onAction={() => router.push(`/events/${event?.id}`)} + onAction={() => router.push(`/events/${eventID}`)} variant='success' buttonText='show' />