diff options
| author | Sebastien Castiel <sebastien@castiel.me> | 2023-12-07 20:12:40 -0500 |
|---|---|---|
| committer | Sebastien Castiel <sebastien@castiel.me> | 2023-12-07 20:12:40 -0500 |
| commit | 6f077f141edcc45f2d7467b7c796e62a8f0316f8 (patch) | |
| tree | 617f8883be6140eac9827bde5c600f85606d85f9 /src/lib/api.ts | |
| parent | fb6cff2fe3101e80d2932285c0b03e0d5be872f8 (diff) | |
Prevent removing participants with expenses
Diffstat (limited to 'src/lib/api.ts')
| -rw-r--r-- | src/lib/api.ts | 12 |
1 files changed, 12 insertions, 0 deletions
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, |
