From 2fd38aadd91ee5678088b00450b638086307b169 Mon Sep 17 00:00:00 2001 From: Deep Golani <54791570+deepgolani4@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:08:38 +0530 Subject: [PATCH] Add notes in expense (#126) * Feature: Added notes in expense * Add missing notes in form values * Prettier --------- Co-authored-by: deep.golani Co-authored-by: Sebastien Castiel --- .../migration.sql | 2 ++ prisma/schema.prisma | 1 + src/components/expense-form.tsx | 16 ++++++++++++++++ src/lib/api.ts | 2 ++ src/lib/schemas.ts | 1 + 5 files changed, 22 insertions(+) create mode 100644 prisma/migrations/20240310194006_add_notes_in_expense/migration.sql diff --git a/prisma/migrations/20240310194006_add_notes_in_expense/migration.sql b/prisma/migrations/20240310194006_add_notes_in_expense/migration.sql new file mode 100644 index 00000000..2a12ce7e --- /dev/null +++ b/prisma/migrations/20240310194006_add_notes_in_expense/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Expense" ADD COLUMN "notes" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 394342de..f7389472 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -52,6 +52,7 @@ model Expense { splitMode SplitMode @default(EVENLY) createdAt DateTime @default(now()) documents ExpenseDocument[] + notes String? } model ExpenseDocument { diff --git a/src/components/expense-form.tsx b/src/components/expense-form.tsx index 86267916..df5563da 100644 --- a/src/components/expense-form.tsx +++ b/src/components/expense-form.tsx @@ -50,6 +50,7 @@ import { useForm } from 'react-hook-form' import { match } from 'ts-pattern' import { DeletePopup } from './delete-popup' import { extractCategoryFromTitle } from './expense-form-actions' +import { Textarea } from './ui/textarea' export type Props = { group: NonNullable>> @@ -180,6 +181,7 @@ export function ExpenseForm({ saveDefaultSplittingOptions: false, isReimbursement: expense.isReimbursement, documents: expense.documents, + notes: expense.notes ?? '', } : searchParams.get('reimbursement') ? { @@ -202,6 +204,7 @@ export function ExpenseForm({ splitMode: defaultSplittingOptions.splitMode, saveDefaultSplittingOptions: false, documents: [], + notes: '', } : { title: searchParams.get('title') ?? '', @@ -228,6 +231,7 @@ export function ExpenseForm({ }, ] : [], + notes: '', }, }) const [isCategoryLoading, setCategoryLoading] = useState(false) @@ -400,6 +404,18 @@ export function ExpenseForm({ )} /> + ( + + Notes + +