From 470366b8f6bf877f8e4f074fb603ad9432bdf3a2 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 17 Nov 2024 16:32:10 +0100 Subject: [PATCH 1/8] Extract a guests API --- app/api/guests.tsx | 49 +++++++++++++++++++++++++++ app/dashboard/guests/page.tsx | 41 +++++----------------- app/ui/components/creation-dialog.tsx | 27 +++++---------- 3 files changed, 66 insertions(+), 51 deletions(-) create mode 100644 app/api/guests.tsx diff --git a/app/api/guests.tsx b/app/api/guests.tsx new file mode 100644 index 0000000..0eff296 --- /dev/null +++ b/app/api/guests.tsx @@ -0,0 +1,49 @@ +import { Guest } from '@/app/lib/definitions'; +import { getCsrfToken } from '@/app/lib/utils'; + +export function loadGuests(onLoad?: (guests: Guest[]) => void) { + fetch("/api/guests.json") + .then((response) => response.json()) + .then((data) => { + onLoad && onLoad(data.map((record: any) => { + return ({ + id: record.id, + name: record.name, + status: record.status, + group_name: record.group.name, + }); + })); + }, (error) => { + return []; + }); +}; + +export function updateGuestStatus(id: string, status: string) { + fetch("/api/guests/bulk_update.json", + { + method: 'POST', + body: JSON.stringify({ properties: { status: status }, guest_ids: [id] }), + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-TOKEN': getCsrfToken(), + } + }) + .then(() => loadGuests((guests) => null)) + .catch((error) => console.error(error)); +} + +export function createGuest(name: string, group_id: string, onCreate?: () => void) { + fetch("/api/guests", { + method: 'POST', + body: JSON.stringify({ name: name, group_id: group_id }), + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-TOKEN': getCsrfToken(), + } + }) + .then((response) => response.json()) + .then((data) => { + onCreate && onCreate(); + }) + .catch((error) => console.error(error)); +} \ No newline at end of file diff --git a/app/dashboard/guests/page.tsx b/app/dashboard/guests/page.tsx index 67bb05f..d8f9736 100644 --- a/app/dashboard/guests/page.tsx +++ b/app/dashboard/guests/page.tsx @@ -3,7 +3,6 @@ 'use client'; import { Group, Guest } from '@/app/lib/definitions'; -import { getCsrfToken } from '@/app/lib/utils'; import CreationDialog from '@/app/ui/components/creation-dialog'; import GroupsTable from '@/app/ui/groups/table'; import AffinityGroupsTree from '@/app/ui/guests/affinity-groups-tree'; @@ -11,6 +10,7 @@ import SkeletonTable from '@/app/ui/guests/skeleton-row'; import GuestsTable from '@/app/ui/guests/table'; import { TabPanel, TabView } from 'primereact/tabview'; import { Suspense, useState } from 'react'; +import {loadGuests, updateGuestStatus} from '@/app/api/guests'; export default function Page() { function loadGroups() { @@ -38,36 +38,11 @@ export default function Page() { }); } - function loadGuests() { - fetch("/api/guests.json") - .then((response) => response.json()) - .then((data) => { - setGuests(data.map((record: any) => { - return ({ - id: record.id, - name: record.name, - status: record.status, - group_name: record.group.name, - }); - })); - setGuestsLoaded(true); - }, (error) => { - return []; - }); - }; - - const updateGuestStatus = (id: string, status: string) => { - fetch("/api/guests/bulk_update.json", - { - method: 'POST', - body: JSON.stringify({ properties: { status: status }, guest_ids: [id] }), - headers: { - 'Content-Type': 'application/json', - 'X-CSRF-TOKEN': getCsrfToken(), - } - }) - .then(() => loadGuests()) - .catch((error) => console.error(error)); + function refreshGuests() { + loadGuests((guests) => { + setGuests(guests); + setGuestsLoaded(true); + }); } const [groupsLoaded, setGroupsLoaded] = useState(false); @@ -77,7 +52,7 @@ export default function Page() { const [guests, setGuests] = useState>([]); !groupsLoaded && loadGroups(); - !guestsLoaded && loadGuests(); + !guestsLoaded && refreshGuests(); return (
@@ -86,7 +61,7 @@ export default function Page() {
- ; + }> diff --git a/app/ui/components/creation-dialog.tsx b/app/ui/components/creation-dialog.tsx index ed69937..01b169e 100644 --- a/app/ui/components/creation-dialog.tsx +++ b/app/ui/components/creation-dialog.tsx @@ -2,8 +2,8 @@ 'use client'; +import { createGuest } from '@/app/api/guests'; import { Group } from '@/app/lib/definitions'; -import { getCsrfToken } from '@/app/lib/utils'; import { classNames } from '@/app/ui/components/button'; import { Dialog } from 'primereact/dialog'; import { Dropdown } from 'primereact/dropdown'; @@ -16,22 +16,13 @@ export default function CreationDialog({ groups, onCreate }: { groups: Group[], const [name, setName] = useState(''); const [group, setGroup] = useState(null); - function createGuest() { - fetch("/api/guests", { - method: 'POST', - body: JSON.stringify({ name: name, group_id: group }), - headers: { - 'Content-Type': 'application/json', - 'X-CSRF-TOKEN': getCsrfToken(), - } - }) - .then((response) => response.json()) - .then((data) => { - console.log(data); - setVisible(false); - onCreate && onCreate(); - }) - .catch((error) => console.error(error)); + function submitGuest() { + name && group && createGuest(name, group, () => { + setVisible(false); + setName(''); + setGroup(null); + onCreate && onCreate(); + }); } return ( @@ -52,7 +43,7 @@ export default function CreationDialog({ groups, onCreate }: { groups: Group[], } /> - +
From 53c4938e925869e501ca73e4cb21b30140424c7d Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 17 Nov 2024 16:34:58 +0100 Subject: [PATCH 2/8] Extract groups API --- app/api/groups.tsx | 25 +++++++++++++++++++++++ app/dashboard/guests/page.tsx | 37 ++++++++++------------------------- 2 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 app/api/groups.tsx diff --git a/app/api/groups.tsx b/app/api/groups.tsx new file mode 100644 index 0000000..aeafc4d --- /dev/null +++ b/app/api/groups.tsx @@ -0,0 +1,25 @@ +import { Group } from '@/app/lib/definitions'; + +export function loadGroups(onLoad?: (groups: Group[]) => void) { + fetch("/api/groups.json") + .then((response) => response.json()) + .then((data) => { + onLoad && onLoad(data.map((record: any) => { + return ({ + id: record.id, + name: record.name, + color: record.color, + attendance: { + considered: record.considered, + invited: record.invited, + confirmed: record.confirmed, + tentative: record.tentative, + declined: record.declined, + total: record.total, + } + }); + })); + }, (error) => { + return []; + }); +} \ No newline at end of file diff --git a/app/dashboard/guests/page.tsx b/app/dashboard/guests/page.tsx index d8f9736..c9d7203 100644 --- a/app/dashboard/guests/page.tsx +++ b/app/dashboard/guests/page.tsx @@ -10,34 +10,10 @@ import SkeletonTable from '@/app/ui/guests/skeleton-row'; import GuestsTable from '@/app/ui/guests/table'; import { TabPanel, TabView } from 'primereact/tabview'; import { Suspense, useState } from 'react'; -import {loadGuests, updateGuestStatus} from '@/app/api/guests'; +import { loadGuests, updateGuestStatus } from '@/app/api/guests'; +import { loadGroups } from '@/app/api/groups'; export default function Page() { - function loadGroups() { - fetch("/api/groups") - .then((response) => response.json()) - .then((data) => { - setGroups(data.map((record: any) => { - return ({ - id: record.id, - name: record.name, - color: record.color, - attendance: { - considered: record.considered, - invited: record.invited, - confirmed: record.confirmed, - tentative: record.tentative, - declined: record.declined, - total: record.total, - } - }); - })); - setGroupsLoaded(true); - }, (error) => { - return []; - }); - } - function refreshGuests() { loadGuests((guests) => { setGuests(guests); @@ -45,13 +21,20 @@ export default function Page() { }); } + function refreshGroups() { + loadGroups((groups) => { + setGroups(groups); + setGroupsLoaded(true); + }); + } + const [groupsLoaded, setGroupsLoaded] = useState(false); const [groups, setGroups] = useState>([]); const [guestsLoaded, setGuestsLoaded] = useState(false); const [guests, setGuests] = useState>([]); - !groupsLoaded && loadGroups(); + !groupsLoaded && refreshGroups(); !guestsLoaded && refreshGuests(); return ( From 92d929c8e18d6eff7e709622f11270ea14626d4f Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 17 Nov 2024 16:41:53 +0100 Subject: [PATCH 3/8] Extract expenses API --- app/api/expenses.tsx | 38 ++++++++++++++++ app/ui/expenses/table.tsx | 92 ++++++++++++++------------------------- 2 files changed, 70 insertions(+), 60 deletions(-) create mode 100644 app/api/expenses.tsx diff --git a/app/api/expenses.tsx b/app/api/expenses.tsx new file mode 100644 index 0000000..7cfb3a3 --- /dev/null +++ b/app/api/expenses.tsx @@ -0,0 +1,38 @@ +import { Expense } from '@/app/lib/definitions'; +import { getCsrfToken } from '@/app/lib/utils'; + +export function loadExpenses(onLoad?: (expenses: Expense[]) => void) { + fetch("/api/expenses") + .then((response) => response.json()) + .then((data) => { + onLoad && onLoad(data.map((record: any) => { + return ({ + id: record.id, + name: record.name, + amount: record.amount, + pricingType: record.pricing_type + }); + })); + }, (error) => { + return []; + }); +} + +export function updateExpense(expense: Expense) { + fetch(`/api/expenses/${expense.id}`, + { + method: 'PUT', + body: JSON.stringify({ + expense: { + name: expense.name, + amount: expense.amount, + pricing_type: expense.pricingType, + } + }), + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-TOKEN': getCsrfToken(), + } + }) + .catch((error) => console.error(error)); +} \ No newline at end of file diff --git a/app/ui/expenses/table.tsx b/app/ui/expenses/table.tsx index 5161cfe..121990c 100644 --- a/app/ui/expenses/table.tsx +++ b/app/ui/expenses/table.tsx @@ -2,71 +2,43 @@ 'use client' -import React, { useState } from "react" +import { loadExpenses, updateExpense } from '@/app/api/expenses'; import { Expense } from '@/app/lib/definitions'; -import TableOfContents from "../components/table-of-contents"; +import { useState } from "react"; import InlineTextField from "../components/form/inlineTextField"; -import { getCsrfToken } from '@/app/lib/utils'; +import TableOfContents from "../components/table-of-contents"; export default function ExpensesTable() { - const [expenses, setExpenses] = useState>([]); + const [expenses, setExpenses] = useState>([]); + const [expensesLoaded, setExpensesLoaded] = useState(false); - const handleExpenseUpdate = (expense: Expense) => { - fetch(`/api/expenses/${expense.id}`, - { - method: 'PUT', - body: JSON.stringify({ - expense: { - name: expense.name, - amount: expense.amount, - pricing_type: expense.pricingType, - } - }), - headers: { - 'Content-Type': 'application/json', - 'X-CSRF-TOKEN': getCsrfToken(), - } - }) - .catch((error) => console.error(error)); - } + function refreshExpenses() { + loadExpenses((expenses) => { + setExpenses(expenses); + setExpensesLoaded(true); + }); + } - function loadExpenses() { - fetch("/api/expenses") - .then((response) => response.json()) - .then((data) => { - setExpenses(data.map((record: any) => { - return ({ - id: record.id, - name: record.name, - amount: record.amount, - pricingType: record.pricing_type - }); - })); - }, (error) => { - return []; - }); - } + !expensesLoaded && refreshExpenses(); - expenses.length === 0 && loadExpenses(); - - return ( - ( - - - { expense.name = value; handleExpenseUpdate(expense) }} /> - - - { expense.amount = parseFloat(value); handleExpenseUpdate(expense) }} /> - - - {expense.pricingType} - - - )} - /> - ); + return ( + ( + + + { expense.name = value; updateExpense(expense) }} /> + + + { expense.amount = parseFloat(value); updateExpense(expense) }} /> + + + {expense.pricingType} + + + )} + /> + ); } \ No newline at end of file From 28abb23a771aa908cd713084dfdc8c5d192bc92c Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 17 Nov 2024 16:45:42 +0100 Subject: [PATCH 4/8] Extract a table simulations API --- app/api/tableSimulations.tsx | 17 ++++++++++++++++ app/ui/arrangements/arrangements-table.tsx | 23 ++++++++-------------- 2 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 app/api/tableSimulations.tsx diff --git a/app/api/tableSimulations.tsx b/app/api/tableSimulations.tsx new file mode 100644 index 0000000..51e1fff --- /dev/null +++ b/app/api/tableSimulations.tsx @@ -0,0 +1,17 @@ +import { TableArrangement } from '@/app/lib/definitions'; + +export function loadTableSimulations(onLoad?: (tableSimulations: TableArrangement[]) => void) { + fetch('/api/tables_arrangements') + .then((response) => response.json()) + .then((data) => { + onLoad && onLoad(data.map((record: any) => { + return ({ + id: record.id, + name: record.name, + discomfort: record.discomfort, + }); + })); + }, (error) => { + return []; + }); +} \ No newline at end of file diff --git a/app/ui/arrangements/arrangements-table.tsx b/app/ui/arrangements/arrangements-table.tsx index 66e41d4..57dd67d 100644 --- a/app/ui/arrangements/arrangements-table.tsx +++ b/app/ui/arrangements/arrangements-table.tsx @@ -6,31 +6,24 @@ import React, { useState } from "react" import { TableArrangement } from '@/app/lib/definitions'; import { classNames } from "../components/button"; import TableOfContents from "../components/table-of-contents"; +import { loadTableSimulations } from "@/app/api/tableSimulations"; export default function ArrangementsTable ({onArrangementSelected}: {onArrangementSelected: (arrangementId: string) => void}) { const [arrangements, setArrangements] = useState>([]); + const [arrangementsLoaded, setArrangementsLoaded] = useState(false); - function loadArrangements() { - fetch("/api/tables_arrangements") - .then((response) => response.json()) - .then((data) => { - setArrangements(data.map((record: any) => { - return ({ - id: record.id, - name: record.name, - discomfort: record.discomfort - }); - })); - }, (error) => { - return []; - }); + function refreshSimulations() { + loadTableSimulations((arrangements) => { + setArrangements(arrangements); + setArrangementsLoaded(true); + }); } function arrangementClicked(e: React.MouseEvent) { onArrangementSelected(e.currentTarget.getAttribute('data-arrangement-id') || ''); } - arrangements.length === 0 && loadArrangements(); + !arrangementsLoaded && refreshSimulations(); return( Date: Sun, 17 Nov 2024 16:59:16 +0100 Subject: [PATCH 5/8] Refactor guests API --- app/api/guests.tsx | 9 ++++---- app/dashboard/guests/page.tsx | 4 ++-- app/lib/definitions.ts | 3 ++- app/ui/guests/table.tsx | 42 +++++++++-------------------------- 4 files changed, 19 insertions(+), 39 deletions(-) diff --git a/app/api/guests.tsx b/app/api/guests.tsx index 0eff296..549356c 100644 --- a/app/api/guests.tsx +++ b/app/api/guests.tsx @@ -18,17 +18,16 @@ export function loadGuests(onLoad?: (guests: Guest[]) => void) { }); }; -export function updateGuestStatus(id: string, status: string) { - fetch("/api/guests/bulk_update.json", +export function updateGuest(guest: Guest) { + fetch(`/api/guests/${guest.id}`, { - method: 'POST', - body: JSON.stringify({ properties: { status: status }, guest_ids: [id] }), + method: 'PUT', + body: JSON.stringify({ guest: { name: guest.name, status: guest.status } }), headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': getCsrfToken(), } }) - .then(() => loadGuests((guests) => null)) .catch((error) => console.error(error)); } diff --git a/app/dashboard/guests/page.tsx b/app/dashboard/guests/page.tsx index c9d7203..d575715 100644 --- a/app/dashboard/guests/page.tsx +++ b/app/dashboard/guests/page.tsx @@ -10,7 +10,7 @@ import SkeletonTable from '@/app/ui/guests/skeleton-row'; import GuestsTable from '@/app/ui/guests/table'; import { TabPanel, TabView } from 'primereact/tabview'; import { Suspense, useState } from 'react'; -import { loadGuests, updateGuestStatus } from '@/app/api/guests'; +import { loadGuests } from '@/app/api/guests'; import { loadGroups } from '@/app/api/groups'; export default function Page() { @@ -46,7 +46,7 @@ export default function Page() {
}> - +
diff --git a/app/lib/definitions.ts b/app/lib/definitions.ts index f1d3641..8e7e6ae 100644 --- a/app/lib/definitions.ts +++ b/app/lib/definitions.ts @@ -18,12 +18,13 @@ export type Customer = { image_url: string; }; +export type GuestStatus = 'considered' | 'invited' | 'confirmed' | 'declined' | 'tentative'; export type Guest = { id: string; name: string; group_name?: string; color?: string; - status?: 'considered' | 'invited' | 'confirmed' | 'declined' | 'tentative'; + status?: GuestStatus } export type Expense = { diff --git a/app/ui/guests/table.tsx b/app/ui/guests/table.tsx index 7b6d427..2e6dfae 100644 --- a/app/ui/guests/table.tsx +++ b/app/ui/guests/table.tsx @@ -2,39 +2,19 @@ 'use client'; -import { Guest } from '@/app/lib/definitions'; -import { getCsrfToken } from '@/app/lib/utils'; +import { updateGuest } from '@/app/api/guests'; +import { Guest, GuestStatus } from '@/app/lib/definitions'; import { classNames } from '@/app/ui/components/button'; import clsx from 'clsx'; -import React from 'react'; import InlineTextField from '../components/form/inlineTextField'; import TableOfContents from '../components/table-of-contents'; -export default function guestsTable({ guests, updateGuestStatus }: { guests: Guest[], updateGuestStatus: (id: string, status: string) => void }) { - const handleInviteGuest = (e: React.MouseEvent) => handleGuestChange(e, 'invited'); - const handleConfirmGuest = (e: React.MouseEvent) => handleGuestChange(e, 'confirmed'); - const handleDeclineGuest = (e: React.MouseEvent) => handleGuestChange(e, 'declined'); - const handleTentativeGuest = (e: React.MouseEvent) => handleGuestChange(e, 'tentative'); - - const handleGuestUpdate = (guest: Guest) => { - fetch(`/api/guests/${guest.id}`, - { - method: 'PUT', - body: JSON.stringify({ guest: { name: guest.name } }), - headers: { - 'Content-Type': 'application/json', - 'X-CSRF-TOKEN': getCsrfToken(), - } - }) - .catch((error) => console.error(error)); +export default function guestsTable({ guests }: { guests: Guest[] }) { + const handleGuestChange = (guest: Guest, status: GuestStatus) => { + guest.status = status; + updateGuest(guest); } - - const handleGuestChange = (e: React.MouseEvent, status: string) => { - updateGuestStatus(e.currentTarget.getAttribute('data-guest-id') || '', status); - } - - return ( ( - { guest.name = newName; handleGuestUpdate(guest) }} /> + { guest.name = newName; updateGuest(guest) }} /> {guest.group_name} @@ -65,14 +45,14 @@ export default function guestsTable({ guests, updateGuestStatus }: { guests: Gue - {guest.status === 'considered' && ()} {(guest.status === 'invited' || guest.status === 'tentative') && ( <> - - {guest.status != 'tentative' && } - + + {guest.status != 'tentative' && } + )} From 01bce277a89a90e0c9a5dfb62ae64ad343bdc2c8 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 17 Nov 2024 16:00:30 +0000 Subject: [PATCH 6/8] Add copyright notice --- app/api/expenses.tsx | 2 ++ app/api/groups.tsx | 2 ++ app/api/guests.tsx | 2 ++ app/api/tableSimulations.tsx | 2 ++ 4 files changed, 8 insertions(+) diff --git a/app/api/expenses.tsx b/app/api/expenses.tsx index 7cfb3a3..f73f6b7 100644 --- a/app/api/expenses.tsx +++ b/app/api/expenses.tsx @@ -1,3 +1,5 @@ +/* Copyright (C) 2024 Manuel Bustillo*/ + import { Expense } from '@/app/lib/definitions'; import { getCsrfToken } from '@/app/lib/utils'; diff --git a/app/api/groups.tsx b/app/api/groups.tsx index aeafc4d..e765761 100644 --- a/app/api/groups.tsx +++ b/app/api/groups.tsx @@ -1,3 +1,5 @@ +/* Copyright (C) 2024 Manuel Bustillo*/ + import { Group } from '@/app/lib/definitions'; export function loadGroups(onLoad?: (groups: Group[]) => void) { diff --git a/app/api/guests.tsx b/app/api/guests.tsx index 549356c..6314338 100644 --- a/app/api/guests.tsx +++ b/app/api/guests.tsx @@ -1,3 +1,5 @@ +/* Copyright (C) 2024 Manuel Bustillo*/ + import { Guest } from '@/app/lib/definitions'; import { getCsrfToken } from '@/app/lib/utils'; diff --git a/app/api/tableSimulations.tsx b/app/api/tableSimulations.tsx index 51e1fff..4e28688 100644 --- a/app/api/tableSimulations.tsx +++ b/app/api/tableSimulations.tsx @@ -1,3 +1,5 @@ +/* Copyright (C) 2024 Manuel Bustillo*/ + import { TableArrangement } from '@/app/lib/definitions'; export function loadTableSimulations(onLoad?: (tableSimulations: TableArrangement[]) => void) { From 1fdac88c756121c1271b6f8ccfd0787f324a21e0 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 17 Nov 2024 17:50:06 +0100 Subject: [PATCH 7/8] Fix race condition updating guests --- app/api/guests.tsx | 2 +- app/dashboard/guests/page.tsx | 2 +- app/ui/guests/table.tsx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/guests.tsx b/app/api/guests.tsx index 6314338..4d91fac 100644 --- a/app/api/guests.tsx +++ b/app/api/guests.tsx @@ -21,7 +21,7 @@ export function loadGuests(onLoad?: (guests: Guest[]) => void) { }; export function updateGuest(guest: Guest) { - fetch(`/api/guests/${guest.id}`, + return fetch(`/api/guests/${guest.id}`, { method: 'PUT', body: JSON.stringify({ guest: { name: guest.name, status: guest.status } }), diff --git a/app/dashboard/guests/page.tsx b/app/dashboard/guests/page.tsx index d575715..fe46b0e 100644 --- a/app/dashboard/guests/page.tsx +++ b/app/dashboard/guests/page.tsx @@ -46,7 +46,7 @@ export default function Page() {
}> - +
diff --git a/app/ui/guests/table.tsx b/app/ui/guests/table.tsx index 2e6dfae..143147b 100644 --- a/app/ui/guests/table.tsx +++ b/app/ui/guests/table.tsx @@ -9,10 +9,10 @@ import clsx from 'clsx'; import InlineTextField from '../components/form/inlineTextField'; import TableOfContents from '../components/table-of-contents'; -export default function guestsTable({ guests }: { guests: Guest[] }) { +export default function guestsTable({ guests, onUpdate }: { guests: Guest[], onUpdate: () => void }) { const handleGuestChange = (guest: Guest, status: GuestStatus) => { guest.status = status; - updateGuest(guest); + updateGuest(guest).then(() => onUpdate()); } return ( From c1d199f08d5d23d1bf29bfbced4d53d4178cd599 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 17 Nov 2024 17:58:08 +0100 Subject: [PATCH 8/8] Remove extension from the API's URLs --- app/api/groups.tsx | 2 +- app/api/guests.tsx | 2 +- tests/guests.spec.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/groups.tsx b/app/api/groups.tsx index e765761..aa0e4db 100644 --- a/app/api/groups.tsx +++ b/app/api/groups.tsx @@ -3,7 +3,7 @@ import { Group } from '@/app/lib/definitions'; export function loadGroups(onLoad?: (groups: Group[]) => void) { - fetch("/api/groups.json") + fetch("/api/groups") .then((response) => response.json()) .then((data) => { onLoad && onLoad(data.map((record: any) => { diff --git a/app/api/guests.tsx b/app/api/guests.tsx index 4d91fac..37d0126 100644 --- a/app/api/guests.tsx +++ b/app/api/guests.tsx @@ -4,7 +4,7 @@ import { Guest } from '@/app/lib/definitions'; import { getCsrfToken } from '@/app/lib/utils'; export function loadGuests(onLoad?: (guests: Guest[]) => void) { - fetch("/api/guests.json") + fetch("/api/guests") .then((response) => response.json()) .then((data) => { onLoad && onLoad(data.map((record: any) => { diff --git a/tests/guests.spec.ts b/tests/guests.spec.ts index 5fc76bc..734f623 100644 --- a/tests/guests.spec.ts +++ b/tests/guests.spec.ts @@ -1,7 +1,7 @@ import { test, expect, Page } from '@playwright/test' const mockGuestsAPI = ({ page }: { page: Page }) => { - page.route('*/**/api/guests.json', async route => { + page.route('*/**/api/guests', async route => { const json = [ { "id": "f4a09c28-40ea-4553-90a5-96935a59cac6",