diff --git a/src/actions/common-server.tsx b/src/actions/common-server.tsx
index cf5ba41..ea43954 100644
--- a/src/actions/common-server.tsx
+++ b/src/actions/common-server.tsx
@@ -56,68 +56,51 @@ export async function markPayment(
);
}
-export type BasicRegistrationInfo = {
+export type RegistrationInfo = {
eventId: number;
participant: ParticipantState;
comments: string | null;
+ additionalInfos?: FacultyDinnerInfo | HelloWorldInfo;
};
export type FacultyDinnerInfo = {
- meal;
- allergies;
- plus_ones;
- guest;
+ meal: number;
+ allergies: string;
+ plusOnes: number;
+ guest: boolean;
};
export type HelloWorldInfo = {
- team;
+ team: string;
};
-export type RegistrationInfo = BasicRegistrationInfo &
- (FacultyDinnerInfo | HelloWorldInfo | {});
-
-export async function sendRegistration(
- { eventId, participant, comments }: RegistrationInfo,
- { meal, allergies, plus_ones, guest }: FacultyDinnerInfo = {
- meal: null,
- allergies: null,
- plus_ones: null,
- guest: null,
- },
- { team }: HelloWorldInfo = { team: null }
-) {
- const event = await directus().request(readItem('events', eventId));
+export async function sendRegistration(info: RegistrationInfo) {
+ const event = await directus().request(readItem('events', info.eventId));
if (!event.opened) {
throw new Error('Not opened');
}
- const eventRegistration = {
- event: eventId,
- email: participant.email.toLowerCase(),
- first_name: participant.firstName,
- family_name: participant.lastName,
- year: participant.year,
- section: participant.section,
- comments,
- // Faculty Dinner
- meal,
- allergies,
- plusOnes: plus_ones,
- guest,
- // Hello World
- team,
- // ICBD
- checked_in: false,
- retreived_deposit: false,
- can_retreive_deposit: false,
- registration_complete: false,
- // Clothes
- order_complete: false,
- };
-
const createdRegistration = await directus().request(
- createItems('registrations', [eventRegistration])
+ createItems('registrations', [
+ {
+ event: info.eventId,
+ email: info.participant.email.toLowerCase(),
+ first_name: info.participant.firstName,
+ family_name: info.participant.lastName,
+ year: info.participant.year,
+ section: info.participant.section,
+ comments: info.comments,
+ // ICBD
+ checked_in: false,
+ retreived_deposit: false,
+ can_retreive_deposit: false,
+ registration_complete: false,
+ // Clothes
+ order_complete: false,
+ ...(info.additionalInfos || {}),
+ },
+ ])
);
return createdRegistration[0].id;
diff --git a/src/app/[eventSlug]/guest/page.tsx b/src/app/[eventSlug]/guest/page.tsx
index d7421c4..da7a3f7 100644
--- a/src/app/[eventSlug]/guest/page.tsx
+++ b/src/app/[eventSlug]/guest/page.tsx
@@ -44,9 +44,7 @@ export default async function GuestForm({ params }) {
switch (event.type) {
case 'faculty_dinner':
- return (
-
- );
+ return ;
default:
return notFound();
}
diff --git a/src/app/[eventSlug]/page.tsx b/src/app/[eventSlug]/page.tsx
index dbdbc88..57dc1fb 100644
--- a/src/app/[eventSlug]/page.tsx
+++ b/src/app/[eventSlug]/page.tsx
@@ -32,7 +32,7 @@ export default async function Home({ params }) {
'background_color',
'icbd_event',
'location',
- //@ts-expect-error
+ //@ts-expect-error
{ translations: ['*'] },
],
filter: {
@@ -54,9 +54,7 @@ export default async function Home({ params }) {
case 'icbd':
return ;
case 'faculty_dinner':
- return (
-
- );
+ return ;
case 'hello_world':
return ;
case 'faculty_clothes_sale':
diff --git a/src/components/forms/FacultyDinnerForm.tsx b/src/components/forms/FacultyDinnerForm.tsx
index 31a0580..fdc8571 100644
--- a/src/components/forms/FacultyDinnerForm.tsx
+++ b/src/components/forms/FacultyDinnerForm.tsx
@@ -346,10 +346,13 @@ function Form({
section: guest ? 'Guest' : s.participant.section,
year: guest ? 'Guest' : s.participant.year,
},
- meal: s.mealId,
comments: s.comments,
- plus_ones: guest ? s.plus_ones : 0,
- guest,
+ additionalInfos: {
+ meal: s.mealId,
+ allergies: s.comments,
+ plusOnes: guest ? s.plus_ones : 0,
+ guest,
+ },
});
setField('formState', FormStates.Confirmation);
} catch (error) {
diff --git a/src/components/forms/HelloWorldForm.tsx b/src/components/forms/HelloWorldForm.tsx
index 2521ae4..10511c7 100644
--- a/src/components/forms/HelloWorldForm.tsx
+++ b/src/components/forms/HelloWorldForm.tsx
@@ -263,8 +263,10 @@ function Form({
await sendRegistration({
eventId,
participant: member,
- team: s.team,
comments: s.comments,
+ additionalInfos: {
+ team: s.team,
+ },
});
}
setField('formState', FormStates.Confirmation);
diff --git a/src/components/forms/ICBDForm.tsx b/src/components/forms/ICBDForm.tsx
index 27b244d..21a6ffd 100644
--- a/src/components/forms/ICBDForm.tsx
+++ b/src/components/forms/ICBDForm.tsx
@@ -108,10 +108,7 @@ export default function ICBDForm({
interviews: { title: string; time: string; id: number }[];
}) {
// Info items
- const infoItems: [ElementType, ReactNode][] = makeInfoItems(
- event,
- true
- );
+ const infoItems: [ElementType, ReactNode][] = makeInfoItems(event, true);
// Define initial state
const initialState: State = {
diff --git a/src/components/forms/PullFacForm.tsx b/src/components/forms/PullFacForm.tsx
index ec7281f..3c273e3 100644
--- a/src/components/forms/PullFacForm.tsx
+++ b/src/components/forms/PullFacForm.tsx
@@ -95,9 +95,7 @@ export default function FacultyClothesForm({
}) {
// Info items
// Skip the date, since this is just an order
- const infoItems: [ElementType, ReactNode][] = makeInfoItems(
- event,
- ).slice(1);
+ const infoItems: [ElementType, ReactNode][] = makeInfoItems(event).slice(1);
// Define initial state
const initialState: State = {