-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2700c1a
commit 1127f0f
Showing
10 changed files
with
174 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { SignOutButton } from "@clerk/nextjs"; | ||
import FetchData from "@components/parts/fetchRunsheet"; | ||
|
||
export default async function Runsheet (props) | ||
{ | ||
const { vendor } = props.params | ||
|
||
return ( | ||
<> | ||
<h2 id="runsheet">Runsheets</h2> | ||
<p>You can print these off for easy reference.</p> | ||
<FetchData vendor={vendor} /> | ||
<span className="signout"> | ||
<SignOutButton>Log Out</SignOutButton> | ||
</span> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Client } from '@notionhq/client' | ||
import { currentUser } from '@clerk/nextjs'; | ||
import type { NotionGuest } from "@ts/people"; | ||
import type { User } from "@clerk/nextjs/server"; | ||
import { TrackEvent } from "@parts/fathom"; | ||
import GuestRunsheets from "@parts/guestRunsheets"; | ||
import { NotionRunsheetEvent, NotionStakeholder } from '@ts/runsheet'; | ||
|
||
const FetchData = async () => | ||
{ | ||
const { emailAddresses } = await currentUser() as User; | ||
const notion = new Client({ | ||
auth: process.env.NOTION_API_KEY | ||
}) | ||
const data = await notion.databases.query({ | ||
database_id: process.env.GUEST_DB ?? '', | ||
filter: { | ||
property: 'GokD', | ||
email: { | ||
equals: emailAddresses[0].emailAddress.toLowerCase() | ||
} | ||
} | ||
}) | ||
const guest = data.results?.[0] as unknown as NotionGuest | ||
const runsheetEvents: any = await notion.databases.query({ | ||
database_id: process.env.RUNSHEET_DB ?? '', | ||
filter: { | ||
property: 'Guests', | ||
rollup: { | ||
any: { | ||
relation: { | ||
contains: guest.id | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
const stakeholders = await notion.databases.query({ | ||
database_id: process.env.STAKEHOLDER_DB ?? '', | ||
filter: { | ||
property: 'Invitations', | ||
relation: { | ||
contains: guest.id | ||
} | ||
} | ||
}) | ||
|
||
return ( | ||
<> | ||
{emailAddresses[0].emailAddress.toLowerCase() && <TrackEvent name="Signed In" />} | ||
<GuestRunsheets | ||
runsheetEvents={runsheetEvents?.results as any as NotionRunsheetEvent[]} | ||
stakeholders={stakeholders?.results as any as NotionStakeholder[]} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default FetchData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { NotionRunsheetEvent, RunsheetEvent, NotionStakeholder, VendorRunsheetEvent } from "@ts/runsheet" | ||
import Runsheet from "@parts/runsheet" | ||
import { parseISO } from "date-fns" | ||
|
||
type VendorRunsheetsProps = { | ||
runsheetEvents: NotionRunsheetEvent[] | ||
vendor: string | null | ||
} | ||
|
||
const VendorRunsheets = (props: VendorRunsheetsProps) => | ||
{ | ||
const { runsheetEvents = [] } = props | ||
const events: Record<string, VendorRunsheetEvent> = {} | ||
|
||
runsheetEvents.forEach(event => | ||
{ | ||
events[event.id] = { | ||
name: event.properties.Name.title[0].plain_text, | ||
tags: event.properties.Tags.multi_select.map(tag => tag.name), | ||
start: parseISO(event.properties.Date.date.start), | ||
end: event.properties.Date.date.end ? parseISO(event.properties.Date.date.end) : null, | ||
notes: event.properties.Notes.rich_text.map(note => note.plain_text).join('\n'), | ||
vendors: event.properties['Vendor Slugs'].formula.string?.split(',') | ||
} | ||
}) | ||
|
||
return ( | ||
<Runsheet | ||
stakeholder={{ | ||
name: props.vendor ?? "Runsheet", | ||
events: Object.values(events).sort((a, b) => a.start.getTime() - b.start.getTime()) | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
export default VendorRunsheets | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters