mirror of
https://github.com/spliit-app/spliit.git
synced 2025-12-06 09:29:39 +01:00
Add Expense Date (#26)
* add expense date * Improve date formatting * Prettier * Change field description --------- Co-authored-by: Sebastien Castiel <sebastien@castiel.me>
This commit is contained in:
@@ -47,6 +47,7 @@ export async function createExpense(
|
||||
data: {
|
||||
id: randomId(),
|
||||
groupId,
|
||||
expenseDate: expenseFormValues.expenseDate,
|
||||
amount: expenseFormValues.amount,
|
||||
title: expenseFormValues.title,
|
||||
paidById: expenseFormValues.paidBy,
|
||||
@@ -120,6 +121,7 @@ export async function updateExpense(
|
||||
return prisma.expense.update({
|
||||
where: { id: expenseId },
|
||||
data: {
|
||||
expenseDate: expenseFormValues.expenseDate,
|
||||
amount: expenseFormValues.amount,
|
||||
title: expenseFormValues.title,
|
||||
paidById: expenseFormValues.paidBy,
|
||||
@@ -210,7 +212,7 @@ export async function getGroupExpenses(groupId: string) {
|
||||
return prisma.expense.findMany({
|
||||
where: { groupId },
|
||||
include: { paidFor: { include: { participant: true } }, paidBy: true },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
orderBy: { expenseDate: 'desc' },
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ export type GroupFormValues = z.infer<typeof groupFormSchema>
|
||||
|
||||
export const expenseFormSchema = z
|
||||
.object({
|
||||
expenseDate: z.coerce.date(),
|
||||
title: z
|
||||
.string({ required_error: 'Please enter a title.' })
|
||||
.min(2, 'Enter at least two characters.'),
|
||||
|
||||
Reference in New Issue
Block a user