From 6f077f141edcc45f2d7467b7c796e62a8f0316f8 Mon Sep 17 00:00:00 2001 From: Sebastien Castiel Date: Thu, 7 Dec 2023 20:12:40 -0500 Subject: Prevent removing participants with expenses --- src/lib/api.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/lib/api.ts') diff --git a/src/lib/api.ts b/src/lib/api.ts index 4ae88ef..2968cae 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -66,6 +66,18 @@ export async function deleteExpense(expenseId: string) { }) } +export async function getGroupExpensesParticipants(groupId: string) { + const expenses = await getGroupExpenses(groupId) + return Array.from( + new Set( + expenses.flatMap((e) => [ + e.paidById, + ...e.paidFor.map((pf) => pf.participantId), + ]), + ), + ) +} + export async function updateExpense( groupId: string, expenseId: string, -- cgit v1.3