diff options
| author | Sebastien Castiel <sebastien@castiel.me> | 2023-12-06 12:22:24 -0500 |
|---|---|---|
| committer | Sebastien Castiel <sebastien@castiel.me> | 2023-12-06 12:22:24 -0500 |
| commit | 6c4ced0f79f801d85da5e4973ae4154f01b04dba (patch) | |
| tree | dbb8eab58ef6d3e8cec6f3c7187e2a4596134d4a /src/app | |
| parent | ed55c696cd083bfaa5429082a9c5edd4ebde0cd8 (diff) | |
Loading screens & layouts
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/groups/[groupId]/expenses/[expenseId]/edit/loading.tsx | 3 | ||||
| -rw-r--r-- | src/app/groups/[groupId]/layout.tsx | 37 | ||||
| -rw-r--r-- | src/app/groups/[groupId]/loading.tsx | 3 | ||||
| -rw-r--r-- | src/app/groups/[groupId]/page.tsx | 21 | ||||
| -rw-r--r-- | src/app/groups/loading.tsx | 3 | ||||
| -rw-r--r-- | src/app/loading.tsx | 3 |
6 files changed, 52 insertions, 18 deletions
diff --git a/src/app/groups/[groupId]/expenses/[expenseId]/edit/loading.tsx b/src/app/groups/[groupId]/expenses/[expenseId]/edit/loading.tsx new file mode 100644 index 0000000..2b6ca56 --- /dev/null +++ b/src/app/groups/[groupId]/expenses/[expenseId]/edit/loading.tsx @@ -0,0 +1,3 @@ +export default function Loading() { + return <p>Loading…</p> +} diff --git a/src/app/groups/[groupId]/layout.tsx b/src/app/groups/[groupId]/layout.tsx new file mode 100644 index 0000000..f8030c6 --- /dev/null +++ b/src/app/groups/[groupId]/layout.tsx @@ -0,0 +1,37 @@ +import { Button } from '@/components/ui/button' +import { getGroup } from '@/lib/api' +import { ChevronLeft, Edit } from 'lucide-react' +import Link from 'next/link' +import { notFound } from 'next/navigation' +import { PropsWithChildren } from 'react' + +export default async function GroupLayout({ + children, + params: { groupId }, +}: PropsWithChildren<{ + params: { groupId: string } +}>) { + const group = await getGroup(groupId) + if (!group) notFound() + + return ( + <main> + <div className="mb-4 flex justify-between"> + <Button variant="ghost" asChild> + <Link href="/groups"> + <ChevronLeft className="w-4 h-4 mr-2" /> Back to recent groups + </Link> + </Button> + <Button variant="secondary" asChild> + <Link href={`/groups/${groupId}/edit`}> + <Edit className="w-4 h-4 mr-2" /> Edit group settings + </Link> + </Button> + </div> + + <h1 className="font-bold mb-4">{group.name}</h1> + + {children} + </main> + ) +} diff --git a/src/app/groups/[groupId]/loading.tsx b/src/app/groups/[groupId]/loading.tsx new file mode 100644 index 0000000..2b6ca56 --- /dev/null +++ b/src/app/groups/[groupId]/loading.tsx @@ -0,0 +1,3 @@ +export default function Loading() { + return <p>Loading…</p> +} diff --git a/src/app/groups/[groupId]/page.tsx b/src/app/groups/[groupId]/page.tsx index 1577d7a..9547fcc 100644 --- a/src/app/groups/[groupId]/page.tsx +++ b/src/app/groups/[groupId]/page.tsx @@ -17,7 +17,7 @@ import { TableRow, } from '@/components/ui/table' import { getGroup, getGroupExpenses } from '@/lib/api' -import { ChevronLeft, ChevronRight, Edit, Plus } from 'lucide-react' +import { ChevronRight, Plus } from 'lucide-react' import Link from 'next/link' import { notFound } from 'next/navigation' @@ -32,22 +32,7 @@ export default async function GroupPage({ const expenses = await getGroupExpenses(groupId) return ( - <main> - <div className="mb-4 flex justify-between"> - <Button variant="ghost" asChild> - <Link href="/groups"> - <ChevronLeft className="w-4 h-4 mr-2" /> Back to recent groups - </Link> - </Button> - <Button variant="secondary" asChild> - <Link href={`/groups/${groupId}/edit`}> - <Edit className="w-4 h-4 mr-2" /> Edit group settings - </Link> - </Button> - </div> - - <h1 className="font-bold mb-4">{group.name}</h1> - + <> <Card className="mb-4"> <div className="flex flex-1"> <CardHeader className="flex-1"> @@ -136,6 +121,6 @@ export default async function GroupPage({ </CardContent> </Card> <SaveGroupLocally group={{ id: group.id, name: group.name }} /> - </main> + </> ) } diff --git a/src/app/groups/loading.tsx b/src/app/groups/loading.tsx new file mode 100644 index 0000000..2b6ca56 --- /dev/null +++ b/src/app/groups/loading.tsx @@ -0,0 +1,3 @@ +export default function Loading() { + return <p>Loading…</p> +} diff --git a/src/app/loading.tsx b/src/app/loading.tsx new file mode 100644 index 0000000..2b6ca56 --- /dev/null +++ b/src/app/loading.tsx @@ -0,0 +1,3 @@ +export default function Loading() { + return <p>Loading…</p> +} |
