diff --git a/messages/en-US.json b/messages/en-US.json index 4b3505ab..2e53198e 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -75,6 +75,10 @@ "placeholder": "Summer vacations", "description": "Enter a name for your group." }, + "InformationField": { + "label": "Group information", + "placeholder": "What information is relevant to group participants?" + }, "CurrencyField": { "label": "Currency symbol", "placeholder": "$, €, £…", @@ -273,6 +277,11 @@ "older": "Older" } }, + "Information": { + "title": "Information", + "description": "Use this place to add any information that can be relevant to the group participants.", + "empty": "No group information yet." + }, "Settings": { "title": "Settings" }, diff --git a/messages/fi.json b/messages/fi.json index 6df9056b..b2965f4b 100644 --- a/messages/fi.json +++ b/messages/fi.json @@ -75,6 +75,10 @@ "placeholder": "Kesälomareissu", "description": "Syötä ryhmäsi nimi." }, + "InformationField": { + "label": "Ryhmän tiedot", + "placeholder": "Mitkä tiedot ovat merkityksellisiä ryhmän osallistujille?" + }, "CurrencyField": { "label": "Valuuttamerkki", "placeholder": "$, €, £…", @@ -273,6 +277,11 @@ "older": "Vanhemmat" } }, + "Information": { + "title": "Tiedot", + "description": "Käytä tätä paikkaa lisätäksesi kaikki tiedot, joilla voi olla merkitystä ryhmän osallistujille.", + "empty": "Ryhmätietoja ei vielä ole." + }, "Settings": { "title": "Asetukset" }, diff --git a/prisma/migrations/20240531154748_add_group_information/migration.sql b/prisma/migrations/20240531154748_add_group_information/migration.sql new file mode 100644 index 00000000..c2037834 --- /dev/null +++ b/prisma/migrations/20240531154748_add_group_information/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Group" ADD COLUMN "information" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2989f3c9..d7b071dd 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -14,6 +14,7 @@ datasource db { model Group { id String @id name String + information String? @db.Text currency String @default("$") participants Participant[] expenses Expense[] diff --git a/src/app/groups/[groupId]/group-tabs.tsx b/src/app/groups/[groupId]/group-tabs.tsx index d400dcb3..2c77efbc 100644 --- a/src/app/groups/[groupId]/group-tabs.tsx +++ b/src/app/groups/[groupId]/group-tabs.tsx @@ -25,6 +25,7 @@ export function GroupTabs({ groupId }: Props) { {t('Expenses.title')} {t('Balances.title')} + {t('Information.title')} {t('Stats.title')} {t('Activity.title')} {t('Settings.title')} diff --git a/src/app/groups/[groupId]/information/page.tsx b/src/app/groups/[groupId]/information/page.tsx new file mode 100644 index 00000000..4d5cb985 --- /dev/null +++ b/src/app/groups/[groupId]/information/page.tsx @@ -0,0 +1,54 @@ +import { cached } from '@/app/cached-functions' +import { Button } from '@/components/ui/button' +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from '@/components/ui/card' +import { Pencil } from 'lucide-react' +import { Metadata } from 'next' +import { getTranslations } from 'next-intl/server' +import Link from 'next/link' +import { notFound } from 'next/navigation' + +export const metadata: Metadata = { + title: 'Totals', +} + +export default async function InformationPage({ + params: { groupId }, +}: { + params: { groupId: string } +}) { + const group = await cached.getGroup(groupId) + if (!group) notFound() + + const t = await getTranslations('Information') + + return ( + <> + + + + {t('title')} + + + + {t('description')} + + + + {group.information || ( +

{t('empty')}

+ )} +
+
+ + ) +} diff --git a/src/components/group-form.tsx b/src/components/group-form.tsx index 65ec593d..fe9869ac 100644 --- a/src/components/group-form.tsx +++ b/src/components/group-form.tsx @@ -39,6 +39,7 @@ import { useTranslations } from 'next-intl' import Link from 'next/link' import { useEffect, useState } from 'react' import { useFieldArray, useForm } from 'react-hook-form' +import { Textarea } from './ui/textarea' export type Props = { group?: NonNullable>> @@ -60,11 +61,13 @@ export function GroupForm({ defaultValues: group ? { name: group.name, + information: group.information ?? '', currency: group.currency, participants: group.participants, } : { name: '', + information: '', currency: '', participants: [ { name: t('Participants.John') }, @@ -162,6 +165,27 @@ export function GroupForm({ )} /> + +
+ ( + + {t('InformationField.label')} + +