diff --git a/app/lib/definitions.ts b/app/lib/definitions.ts index 572914b..f1d3641 100644 --- a/app/lib/definitions.ts +++ b/app/lib/definitions.ts @@ -23,7 +23,7 @@ export type Guest = { name: string; group_name?: string; color?: string; - status?: 'Considered' | 'Invited' | 'Confirmed' | 'Declined' | 'Tentative'; + status?: 'considered' | 'invited' | 'confirmed' | 'declined' | 'tentative'; } export type Expense = { diff --git a/app/ui/guests/table.tsx b/app/ui/guests/table.tsx index 6e8d5ad..6d93e3b 100644 --- a/app/ui/guests/table.tsx +++ b/app/ui/guests/table.tsx @@ -17,12 +17,12 @@ export default function guestsTable() { fetch("/api/guests.json") .then((response) => response.json()) .then((data) => { - setGuests(data.data.map((record: any) => { + setGuests(data.map((record: any) => { return ({ id: record.id, - name: record.attributes.name, - group_name: record.attributes.group_name, - status: record.attributes.status + name: record.name, + status: record.status, + group_name: record.group.name, }); })); }, (error) => { @@ -82,11 +82,11 @@ export default function guestsTable() { @@ -94,13 +94,13 @@ export default function guestsTable() { - {guest.status === 'Considered' && ()} - {(guest.status === 'Invited' || guest.status === 'Tentative') && ( + {(guest.status === 'invited' || guest.status === 'tentative') && ( <> - {guest.status != 'Tentative' && } + {guest.status != 'tentative' && } )} diff --git a/tests/guests.spec.ts b/tests/guests.spec.ts index d34ab37..5fc76bc 100644 --- a/tests/guests.spec.ts +++ b/tests/guests.spec.ts @@ -2,32 +2,26 @@ import { test, expect, Page } from '@playwright/test' const mockGuestsAPI = ({ page }: { page: Page }) => { page.route('*/**/api/guests.json', async route => { - const json = { - data: [ - { - "id": "f4a09c28-40ea-4553-90a5-96935a59cac6", - "type": "guest", - "attributes": { - "id": "f4a09c28-40ea-4553-90a5-96935a59cac6", - "group_id": "2fcb8b22-6b07-4c34-92e3-a2535dbc5b14", - "status": "Tentative", - "name": "Kristofer Rohan DVM", - "group_name": "Childhood friends" - } - }, - { - "id": "bd585c40-0937-4cde-960a-bb23acfd6f18", - "type": "guest", - "attributes": { - "id": "bd585c40-0937-4cde-960a-bb23acfd6f18", - "group_id": "da8edf26-3e1e-4cbb-b985-450c49fffe01", - "status": "Invited", - "name": "Olevia Quigley Jr.", - "group_name": "Work" - } - }, - ] - }; + const json = [ + { + "id": "f4a09c28-40ea-4553-90a5-96935a59cac6", + "status": "tentative", + "name": "Kristofer Rohan DVM", + "group": { + "id": "2fcb8b22-6b07-4c34-92e3-a2535dbc5b14", + "name": "Childhood friends", + } + }, + { + "id": "bd585c40-0937-4cde-960a-bb23acfd6f18", + "status": "invited", + "name": "Olevia Quigley Jr.", + "group": { + "id": "da8edf26-3e1e-4cbb-b985-450c49fffe01", + "name": "Work", + } + }, + ]; await route.fulfill({ json }) })