From 72fe19987957e78cbd1d97ccfd8b87d85fea5c88 Mon Sep 17 00:00:00 2001 From: Sebastien Castiel Date: Wed, 6 Dec 2023 15:23:18 -0500 Subject: [PATCH] Add currency --- .../20231206201409_add_currency/migration.sql | 2 ++ prisma/schema.prisma | 1 + src/app/groups/[groupId]/page.tsx | 4 +-- src/components/expense-form.tsx | 23 +++++++++------- src/components/group-form.tsx | 26 ++++++++++++++++++- src/lib/api.ts | 2 ++ src/lib/schemas.ts | 4 +++ 7 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 prisma/migrations/20231206201409_add_currency/migration.sql diff --git a/prisma/migrations/20231206201409_add_currency/migration.sql b/prisma/migrations/20231206201409_add_currency/migration.sql new file mode 100644 index 0000000..4dd81b3 --- /dev/null +++ b/prisma/migrations/20231206201409_add_currency/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Group" ADD COLUMN "currency" TEXT NOT NULL DEFAULT '$'; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index d073378..5ee1575 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -14,6 +14,7 @@ datasource db { model Group { id String @id name String + currency String @default("$") participants Participant[] expenses Expense[] } diff --git a/src/app/groups/[groupId]/page.tsx b/src/app/groups/[groupId]/page.tsx index b7dc93f..83fc3ef 100644 --- a/src/app/groups/[groupId]/page.tsx +++ b/src/app/groups/[groupId]/page.tsx @@ -86,8 +86,8 @@ export default async function GroupPage({ ))} - - $ {expense.amount.toFixed(2)} + + {group.currency} {expense.amount.toFixed(2)}