mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-26 09:26:12 +01:00
Use tRPC in other group pages (#249)
* Use tRPC in group edition + group layout * Use tRPC in group modals * Use tRPC in group stats * Use tRPC in group activity
This commit is contained in:
committed by
GitHub
parent
66e15e419e
commit
210c12b7ef
@@ -310,11 +310,34 @@ export async function getExpense(groupId: string, expenseId: string) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function getActivities(groupId: string) {
|
||||
return prisma.activity.findMany({
|
||||
export async function getActivities(
|
||||
groupId: string,
|
||||
options?: { offset?: number; length?: number },
|
||||
) {
|
||||
const activities = await prisma.activity.findMany({
|
||||
where: { groupId },
|
||||
orderBy: [{ time: 'desc' }],
|
||||
skip: options?.offset,
|
||||
take: options?.length,
|
||||
})
|
||||
|
||||
const expenseIds = activities
|
||||
.map((activity) => activity.expenseId)
|
||||
.filter(Boolean)
|
||||
const expenses = await prisma.expense.findMany({
|
||||
where: {
|
||||
groupId,
|
||||
id: { in: expenseIds },
|
||||
},
|
||||
})
|
||||
|
||||
return activities.map((activity) => ({
|
||||
...activity,
|
||||
expense:
|
||||
activity.expenseId !== null
|
||||
? expenses.find((expense) => expense.id === activity.expenseId)
|
||||
: undefined,
|
||||
}))
|
||||
}
|
||||
|
||||
export async function logActivity(
|
||||
|
||||
Reference in New Issue
Block a user