feat: enhance accessibility and testing with data-test attributes and improve error handling
This commit is contained in:
@@ -47,19 +47,21 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
|
||||
const events = await api.listEvents(acct.id, { page });
|
||||
|
||||
// Fetch registration counts for all events on this page
|
||||
const eventIds = events.data.map((e: Record<string, unknown>) =>
|
||||
String(e.id),
|
||||
const eventIds = events.data.map((eventItem: Record<string, unknown>) =>
|
||||
String(eventItem.id),
|
||||
);
|
||||
const registrationCounts = await api.getRegistrationCounts(eventIds);
|
||||
|
||||
// Pre-compute stats before rendering
|
||||
const uniqueLocationCount = new Set(
|
||||
events.data.map((e: Record<string, unknown>) => e.location).filter(Boolean),
|
||||
events.data
|
||||
.map((eventItem: Record<string, unknown>) => eventItem.location)
|
||||
.filter(Boolean),
|
||||
).size;
|
||||
|
||||
const totalCapacity = events.data.reduce(
|
||||
(sum: number, e: Record<string, unknown>) =>
|
||||
sum + (Number(e.capacity) || 0),
|
||||
(sum: number, eventItem: Record<string, unknown>) =>
|
||||
sum + (Number(eventItem.capacity) || 0),
|
||||
0,
|
||||
);
|
||||
|
||||
@@ -74,7 +76,7 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
|
||||
</div>
|
||||
|
||||
<Link href={`/home/${account}/events/new`}>
|
||||
<Button>
|
||||
<Button data-test="events-new-btn">
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
{t('newEvent')}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user