diff --git a/src/app/runsheet/page.tsx b/src/app/runsheet/page.tsx index 40769c6..4c23018 100644 --- a/src/app/runsheet/page.tsx +++ b/src/app/runsheet/page.tsx @@ -1,10 +1,9 @@ import { SignOutButton } from "@clerk/nextjs"; -import FetchData from "@components/parts/fetchRunsheet"; +import FetchData from "@components/parts/fetchGuestRunsheet"; export default async function Runsheet () { - return ( <>

Runsheets

diff --git a/src/app/runsheet/vendor/[vendor]/page.tsx b/src/app/runsheet/vendor/[vendor]/page.tsx new file mode 100644 index 0000000..91d88d6 --- /dev/null +++ b/src/app/runsheet/vendor/[vendor]/page.tsx @@ -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 ( + <> +

Runsheets

+

You can print these off for easy reference.

+ + + Log Out + + + ) +} \ No newline at end of file diff --git a/src/components/parts/fetchGuestRunsheet/index.tsx b/src/components/parts/fetchGuestRunsheet/index.tsx new file mode 100644 index 0000000..f45c61e --- /dev/null +++ b/src/components/parts/fetchGuestRunsheet/index.tsx @@ -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() && } + + + ) +} + +export default FetchData \ No newline at end of file diff --git a/src/components/parts/fetchRunsheet/index.tsx b/src/components/parts/fetchRunsheet/index.tsx index f45c61e..74be976 100644 --- a/src/components/parts/fetchRunsheet/index.tsx +++ b/src/components/parts/fetchRunsheet/index.tsx @@ -1,56 +1,43 @@ 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'; +import { NotionRunsheetEvent } from '@ts/runsheet'; +import VendorRunsheets from '@parts/vendorRunsheet'; -const FetchData = async () => +const FetchData = async (props) => { 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() + let filter = undefined + + if (props.vendor && props.vendor !== 'all') + { + filter = { + property: 'Vendor Slugs', + formula: { + string: { + contains: props.vendor + } } } - }) - 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 - } - } + filter }) + console.log({ ...runsheetEvents }) + return ( <> {emailAddresses[0].emailAddress.toLowerCase() && } - ) diff --git a/src/components/parts/guestRunsheets/index.tsx b/src/components/parts/guestRunsheets/index.tsx index d0ca1c5..d4bd708 100644 --- a/src/components/parts/guestRunsheets/index.tsx +++ b/src/components/parts/guestRunsheets/index.tsx @@ -14,8 +14,6 @@ const GuestRunsheets = (props: GuestRunsheetsProps) => runsheetEvents.forEach(event => { - console.log({ ...event }) - events[event.id] = { name: event.properties.Name.title[0].plain_text, tags: event.properties.Tags.multi_select.map(tag => tag.name), diff --git a/src/components/parts/runsheet/index.tsx b/src/components/parts/runsheet/index.tsx index ca49b25..554865e 100644 --- a/src/components/parts/runsheet/index.tsx +++ b/src/components/parts/runsheet/index.tsx @@ -44,6 +44,9 @@ const Runsheet = (props: RunsheetProps) =>

{day}

+ + + diff --git a/src/components/parts/runsheet/styles.module.css b/src/components/parts/runsheet/styles.module.css index fd035ac..359f688 100644 --- a/src/components/parts/runsheet/styles.module.css +++ b/src/components/parts/runsheet/styles.module.css @@ -41,15 +41,21 @@ font-family: $font_headings; background: $green; color: $white; + + & :global(.spacing) { + display: none; + } } & td, & th { padding: 0.7em; } - & tr { - &:nth-child(2n) { - background: $green_light; - } + & tbody { + & tr { + &:nth-child(2n) { + background: $green_light; + } + } } } \ No newline at end of file diff --git a/src/components/parts/vendorRunsheet/index.tsx b/src/components/parts/vendorRunsheet/index.tsx new file mode 100644 index 0000000..229c2a6 --- /dev/null +++ b/src/components/parts/vendorRunsheet/index.tsx @@ -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 = {} + + 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 ( + a.start.getTime() - b.start.getTime()) + }} + /> + ) +} + +export default VendorRunsheets + diff --git a/src/styles/global/print.css b/src/styles/global/print.css index f25dd89..4e37d92 100644 --- a/src/styles/global/print.css +++ b/src/styles/global/print.css @@ -1,6 +1,6 @@ @page { size: A5; - margin: 0; + margin: 0 0 50px 0; } body { @@ -36,6 +36,7 @@ article[class*="runsheet"] { & span[class*="person_name"] { display: block; + margin-bottom: 0; } & .frame { @@ -43,8 +44,20 @@ article[class*="runsheet"] { } } - &:has(+ section[data-page="true"]) { - padding-bottom: var(--page_margins); + & h4 { + margin-bottom: calc(-50px + 0.5em); + } + + & thead { + & .spacing { + height: 50px; + background: $white; + display: block; + + & th { + padding: 0; + } + } } } diff --git a/src/types/runsheet.d.ts b/src/types/runsheet.d.ts index 63a7605..78224a5 100644 --- a/src/types/runsheet.d.ts +++ b/src/types/runsheet.d.ts @@ -34,6 +34,11 @@ export type NotionRunsheetEvent = { plain_text: string }[] } + 'Vendor Slugs': { + formula: { + string: string + } + } } } @@ -45,6 +50,10 @@ export type RunsheetEvent = { notes: string; } +export type VendorRunsheetEvent = RunsheetEvent & { + vendors: string[] +} + export type NotionStakeholder = { id: string properties: {
Start End