From 6611e3a187e5398f686449938b7cf1ddbfcb5392 Mon Sep 17 00:00:00 2001
From: Sebastien Castiel <sebastien@castiel.me>
Date: Thu, 7 Dec 2023 11:11:53 -0500
Subject: Store amounts as cents

---
 src/components/expense-form.tsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'src/components/expense-form.tsx')

diff --git a/src/components/expense-form.tsx b/src/components/expense-form.tsx
index 3f6490f..d6a8049 100644
--- a/src/components/expense-form.tsx
+++ b/src/components/expense-form.tsx
@@ -47,7 +47,7 @@ export function ExpenseForm({ group, expense, onSubmit, onDelete }: Props) {
     defaultValues: expense
       ? {
           title: expense.title,
-          amount: expense.amount,
+          amount: String(expense.amount / 100) as unknown as number, // hack
           paidBy: expense.paidById,
           paidFor: expense.paidFor.map(({ participantId }) => participantId),
           isReimbursement: expense.isReimbursement,
@@ -55,7 +55,9 @@ export function ExpenseForm({ group, expense, onSubmit, onDelete }: Props) {
       : searchParams.get('reimbursement')
       ? {
           title: 'Reimbursement',
-          amount: Number(searchParams.get('amount')) || 0,
+          amount: String(
+            (Number(searchParams.get('amount')) || 0) / 100,
+          ) as unknown as number, // hack
           paidBy: searchParams.get('from') ?? undefined,
           paidFor: [searchParams.get('to') ?? undefined],
           isReimbursement: true,
-- 
cgit v1.3

