Skip to content

Commit

Permalink
trying again
Browse files Browse the repository at this point in the history
  • Loading branch information
amykapernick committed Jul 31, 2024
1 parent f4308ea commit fbfb90c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module.exports = async (phase, { defaultConfig }) => {
const nextConfig = {
...defaultConfig,
reactStrictMode: true,
reactStrictMode: false,
images: {
remotePatterns: [
{
Expand Down
14 changes: 8 additions & 6 deletions src/components/fetchData/schedules/guest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import { TrackEvent } from "@components/fathom";
import fetchCurrentGuest from "@utils/fetchData/currentGuest";
import fetchRunsheetData from "@utils/fetchData/runsheets";
import fetchGuestData from "@utils/fetchData/guestData";
import Schedule from "@components/schedule";
import Schedule, { ScheduleProps } from "@components/schedule";
import formatSchedule from "@utils/formatSchedule";
import { CalendarEvent } from "@ts/runsheet";

type FetchGuestRunsheetProps = {
guest?: string | null;
};

const FetchData = async (props: FetchGuestRunsheetProps) => {
const { guest, email } = await fetchCurrentGuest(props.guest ?? undefined);
const people = await fetchGuestData(guest?.id || '');
const people = await fetchGuestData(guest?.id ?? '');

const peopleIds = guest?.properties.Guests.relation as NotionRelation[];

Expand All @@ -34,9 +35,7 @@ const FetchData = async (props: FetchGuestRunsheetProps) => {
};
});

// console.log({ guestData });

const scheduleData = formatSchedule({
const scheduleData: ScheduleProps = formatSchedule({
type: "guest",
guests: guestData,
events: runsheetEvents.results,
Expand All @@ -46,7 +45,10 @@ const FetchData = async (props: FetchGuestRunsheetProps) => {
return (
<>
{email.toLowerCase() && <TrackEvent name="Signed In" />}
<Schedule {...scheduleData} />
<Schedule
{...scheduleData}
events={scheduleData.events as CalendarEvent[]}
/>
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/schedule/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'react-big-calendar/lib/css/react-big-calendar.css'
import { accessors, localizer, views, customComponents, dateFormats } from '@utils/setupCalendar'
import Dialog from "@components/dialog";

type ScheduleProps = {
export type ScheduleProps = {
type: "guest" | "vendor";
vendor?: string
events: CalendarEvent[];
Expand Down
21 changes: 12 additions & 9 deletions utils/formatSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ type formatRunsheetProps = {
events: NotionRunsheetEvent[]
}

const formatSchedule = (props: formatRunsheetProps) =>
const formatSchedule = (props: formatRunsheetProps):
{
events: CalendarEvent[]
startDate: Date
endDate: Date
guests: Record<string, {
id: string
name: string
}>
type: 'guest' | 'vendor'
} =>
{
const { guests, events, type, guestName } = props
let formattedEvents: CalendarEvent[] = []
Expand Down Expand Up @@ -46,19 +56,12 @@ const formatSchedule = (props: formatRunsheetProps) =>
.filter((value, index, self) => self.indexOf(value) === index)
.forEach((id: string) =>
{
// console.log({ id })
if (guests[id])
{
eventData.guests.push(guests[id].name)
}
})
}
// else if (type === 'vendor')
// {
// const vendor = sheets[0].id
// formattedEvents[vendor].events.push(eventData)
// formattedEvents[vendor].eventIds.push(event.id)
// }

if (eventData.guests.length === Object.entries(guests).length - 1)
{
Expand All @@ -68,7 +71,7 @@ const formatSchedule = (props: formatRunsheetProps) =>
formattedEvents.push({
...eventData,
title: eventData.name
})
} as CalendarEvent)
})

return {
Expand Down

0 comments on commit fbfb90c

Please sign in to comment.