Skip to content

Commit

Permalink
logging more errors
Browse files Browse the repository at this point in the history
  • Loading branch information
amykapernick committed Jul 5, 2024
1 parent 1c6ef17 commit aa71e44
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 45 deletions.
8 changes: 8 additions & 0 deletions src/components/guest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ const Guest = ({ people, guest }: GuestProps) => {
const pastDate = new Date("2024-08-05") <= new Date();
const rsvpOpen = openSection || pastDate;

console.log({
people,
guest,
status,
pastDate,
rsvpOpen,
});

return (
<section>
<h2 id="rsvp">RSVP</h2>
Expand Down
91 changes: 46 additions & 45 deletions src/components/rsvpForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,56 @@
'use client'
"use client";

import { Fragment } from 'react';
import Adult from './adult';
import Child from './child';
import styles from './styles.module.css'
import { SubmitButton } from './submit';
import { submit } from '@app/actions'
import type { Guest, NotionPerson, Person } from '@ts/people';
import { Fragment } from "react";
import Adult from "./adult";
import Child from "./child";
import styles from "./styles.module.css";
import { SubmitButton } from "./submit";
import { submit } from "@app/actions";
import type { Guest, NotionPerson, Person } from "@ts/people";

type FormTypes = {
people: NotionPerson[]
guest: Guest
closeModal: () => void
open: boolean
}
people: NotionPerson[];
guest: Guest;
closeModal: () => void;
open: boolean;
};

const RSVPForm = ({ people, closeModal, guest, open }: FormTypes) =>
{
const handleSubmit = submit.bind(null, guest.id)
const RSVPForm = ({ people, closeModal, guest, open }: FormTypes) => {
const handleSubmit = submit.bind(null, guest.id);

return (
console.log({ people });

return (
<form action={handleSubmit} className={styles.form} data-open={open}>
{people?.toSorted((a, b) => Number(a.properties.Child.checkbox) - Number(b.properties.Child.checkbox)).map(({ id, properties }) =>
{
const data: Person = {
id: id,
name: {
full: properties.Name.title?.[0]?.plain_text,
first: properties['First Name'].rich_text?.[0]?.plain_text,
last: properties['Last Name'].rich_text?.[0]?.plain_text
},
attending: properties.Attending?.select?.name,
meal: properties.Meal?.select?.name,
dietary: properties['Dietary Requirements']?.rich_text?.[0]?.text.content,
age: parseInt(properties.Age?.rich_text?.[0]?.plain_text),
child: properties.Child?.checkbox,
song: properties['Song']?.rich_text?.[0]?.text.content,
}

return (
<Fragment key={data.id}>
{data.child && <Child {...data} />}

{!data.child && <Adult {...data} />}
</Fragment>
)
})}
{people
?.toSorted((a, b) => Number(a?.properties?.Child?.checkbox) - Number(b?.properties?.Child?.checkbox))
?.map(({ id, properties }) => {
const data: Person = {
id: id,
name: {
full: properties.Name.title?.[0]?.plain_text,
first: properties["First Name"].rich_text?.[0]?.plain_text,
last: properties["Last Name"].rich_text?.[0]?.plain_text,
},
attending: properties.Attending?.select?.name,
meal: properties.Meal?.select?.name,
dietary: properties["Dietary Requirements"]?.rich_text?.[0]?.text.content,
age: parseInt(properties.Age?.rich_text?.[0]?.plain_text),
child: properties.Child?.checkbox,
song: properties["Song"]?.rich_text?.[0]?.text.content,
};

return (
<Fragment key={data.id}>
{data.child && <Child {...data} />}

{!data.child && <Adult {...data} />}
</Fragment>
);
})}
<SubmitButton closeModal={closeModal} />
</form>
)
}
);
};

export default RSVPForm
export default RSVPForm;

0 comments on commit aa71e44

Please sign in to comment.