Skip to content

Commit 7956156

Browse files
committed
Upgrade Next.js to 14.1.0
1 parent 2f58e46 commit 7956156

File tree

10 files changed

+1047
-173
lines changed

10 files changed

+1047
-173
lines changed

package-lock.json

+970-114
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@
3737
"dayjs": "^1.11.10",
3838
"lucide-react": "^0.290.0",
3939
"nanoid": "^5.0.4",
40-
"next": "^14.0.4",
40+
"next": "^14.1.0",
4141
"next-themes": "^0.2.1",
4242
"next13-progressbar": "^1.1.1",
4343
"pg": "^8.11.3",
4444
"react": "^18.2.0",
4545
"react-dom": "^18.2.0",
4646
"react-hook-form": "^7.47.0",
47+
"sharp": "^0.33.2",
4748
"tailwind-merge": "^1.14.0",
4849
"tailwindcss-animate": "^1.0.7",
4950
"ts-pattern": "^5.0.6",
@@ -56,13 +57,13 @@
5657
"@types/content-disposition": "^0.5.8",
5758
"@types/node": "^20",
5859
"@types/pg": "^8.10.9",
59-
"@types/react": "^18",
60-
"@types/react-dom": "^18",
60+
"@types/react": "^18.2.48",
61+
"@types/react-dom": "^18.2.18",
6162
"@types/uuid": "^9.0.6",
6263
"autoprefixer": "^10",
6364
"dotenv": "^16.3.1",
6465
"eslint": "^8",
65-
"eslint-config-next": "^14.0.4",
66+
"eslint-config-next": "^14.1.0",
6667
"postcss": "^8",
6768
"prettier": "^3.0.3",
6869
"prettier-plugin-organize-imports": "^3.2.3",

src/app/groups/[groupId]/expenses/[expenseId]/edit/page.tsx

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { expenseFormSchema } from '@/lib/schemas'
1010
import { Metadata } from 'next'
1111
import { notFound, redirect } from 'next/navigation'
12+
import { Suspense } from 'react'
1213

1314
export const metadata: Metadata = {
1415
title: 'Edit expense',
@@ -39,12 +40,14 @@ export default async function EditExpensePage({
3940
}
4041

4142
return (
42-
<ExpenseForm
43-
group={group}
44-
expense={expense}
45-
categories={categories}
46-
onSubmit={updateExpenseAction}
47-
onDelete={deleteExpenseAction}
48-
/>
43+
<Suspense>
44+
<ExpenseForm
45+
group={group}
46+
expense={expense}
47+
categories={categories}
48+
onSubmit={updateExpenseAction}
49+
onDelete={deleteExpenseAction}
50+
/>
51+
</Suspense>
4952
)
5053
}

src/app/groups/[groupId]/expenses/create/page.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createExpense, getCategories, getGroup } from '@/lib/api'
33
import { expenseFormSchema } from '@/lib/schemas'
44
import { Metadata } from 'next'
55
import { notFound, redirect } from 'next/navigation'
6+
import { Suspense } from 'react'
67

78
export const metadata: Metadata = {
89
title: 'Create expense',
@@ -25,10 +26,12 @@ export default async function ExpensePage({
2526
}
2627

2728
return (
28-
<ExpenseForm
29-
group={group}
30-
categories={categories}
31-
onSubmit={createExpenseAction}
32-
/>
29+
<Suspense>
30+
<ExpenseForm
31+
group={group}
32+
categories={categories}
33+
onSubmit={createExpenseAction}
34+
/>
35+
</Suspense>
3336
)
3437
}

src/app/groups/[groupId]/expenses/export/json/route.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export async function GET(
66
req: Request,
77
{ params: { groupId } }: { params: { groupId: string } },
88
) {
9-
console.log({ groupId })
109
const prisma = await getPrisma()
1110
const group = await prisma.group.findUnique({
1211
where: { id: groupId },

src/app/groups/[groupId]/layout.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getGroup } from '@/lib/api'
55
import { Metadata } from 'next'
66
import Link from 'next/link'
77
import { notFound } from 'next/navigation'
8-
import { PropsWithChildren } from 'react'
8+
import { PropsWithChildren, Suspense } from 'react'
99

1010
type Props = {
1111
params: {
@@ -41,7 +41,9 @@ export default async function GroupLayout({
4141
</h1>
4242

4343
<div className="flex gap-2 justify-between">
44-
<GroupTabs groupId={groupId} />
44+
<Suspense>
45+
<GroupTabs groupId={groupId} />
46+
</Suspense>
4547
<ShareButton group={group} />
4648
</div>
4749
</div>

src/app/groups/layout.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { PropsWithChildren } from 'react'
1+
import { PropsWithChildren, Suspense } from 'react'
22

33
export default function GroupsLayout({ children }: PropsWithChildren<{}>) {
44
return (
5-
<>
5+
<Suspense>
66
<main className="flex-1 max-w-screen-md w-full mx-auto px-4 py-6 flex flex-col gap-6">
77
{children}
88
</main>
9-
</>
9+
</Suspense>
1010
)
1111
}

src/app/layout.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { env } from '@/lib/env'
77
import type { Metadata, Viewport } from 'next'
88
import Image from 'next/image'
99
import Link from 'next/link'
10+
import { Suspense } from 'react'
1011
import './globals.css'
1112

1213
export const metadata: Metadata = {
@@ -71,7 +72,9 @@ export default function RootLayout({
7172
enableSystem
7273
disableTransitionOnChange
7374
>
74-
<ProgressBar />
75+
<Suspense>
76+
<ProgressBar />
77+
</Suspense>
7578
<header className="fixed top-0 left-0 right-0 h-16 flex justify-between bg-white dark:bg-gray-950 bg-opacity-50 dark:bg-opacity-50 p-2 border-b backdrop-blur-sm z-50">
7679
<Link
7780
className="flex items-center gap-2 hover:scale-105 transition-transform"

src/app/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Github } from 'lucide-react'
33
import Link from 'next/link'
44

55
// FIX for https://github.com/vercel/next.js/issues/58615
6-
export const dynamic = 'force-dynamic'
6+
// export const dynamic = 'force-dynamic'
77

88
export default function HomePage() {
99
return (

src/components/group-form.tsx

+42-35
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { getGroup } from '@/lib/api'
3535
import { GroupFormValues, groupFormSchema } from '@/lib/schemas'
3636
import { zodResolver } from '@hookform/resolvers/zod'
3737
import { Save, Trash2 } from 'lucide-react'
38+
import { useEffect, useState } from 'react'
3839
import { useFieldArray, useForm } from 'react-hook-form'
3940

4041
export type Props = {
@@ -68,15 +69,25 @@ export function GroupForm({
6869
keyName: 'key',
6970
})
7071

71-
let activeUser = 'None'
72+
const [activeUser, setActiveUser] = useState<string | null>(null)
73+
useEffect(() => {
74+
if (activeUser === null) {
75+
const currentActiveUser =
76+
fields.find(
77+
(f) => f.id === localStorage.getItem(`${group?.id}-activeUser`),
78+
)?.name || 'None'
79+
setActiveUser(currentActiveUser)
80+
}
81+
}, [activeUser, fields, group?.id])
7282

7383
const updateActiveUser = () => {
84+
if (!activeUser) return
7485
if (group?.id) {
7586
const participant = group.participants.find((p) => p.name === activeUser)
7687
if (participant?.id) {
7788
localStorage.setItem(`${group.id}-activeUser`, participant.id)
7889
} else {
79-
localStorage.setItem(`${group.id}-newUser`, activeUser)
90+
localStorage.setItem(`${group.id}-activeUser`, activeUser)
8091
}
8192
} else {
8293
localStorage.setItem('newGroup-activeUser', activeUser)
@@ -228,39 +239,35 @@ export function GroupForm({
228239
</CardHeader>
229240
<CardContent>
230241
<div className="grid sm:grid-cols-2 gap-4">
231-
<FormItem>
232-
<FormLabel>Active user</FormLabel>
233-
<FormControl>
234-
<Select
235-
onValueChange={(value) => {
236-
activeUser = value
237-
}}
238-
defaultValue={
239-
fields.find(
240-
(f) =>
241-
f.id ===
242-
localStorage.getItem(`${group?.id}-activeUser`),
243-
)?.name || 'None'
244-
}
245-
>
246-
<SelectTrigger>
247-
<SelectValue placeholder="Select a participant" />
248-
</SelectTrigger>
249-
<SelectContent>
250-
{[{ name: 'None' }, ...form.watch('participants')]
251-
.filter((item) => item.name.length > 0)
252-
.map(({ name }) => (
253-
<SelectItem key={name} value={name}>
254-
{name}
255-
</SelectItem>
256-
))}
257-
</SelectContent>
258-
</Select>
259-
</FormControl>
260-
<FormDescription>
261-
User used as default for paying expenses.
262-
</FormDescription>
263-
</FormItem>
242+
{activeUser !== null && (
243+
<FormItem>
244+
<FormLabel>Active user</FormLabel>
245+
<FormControl>
246+
<Select
247+
onValueChange={(value) => {
248+
setActiveUser(value)
249+
}}
250+
defaultValue={activeUser}
251+
>
252+
<SelectTrigger>
253+
<SelectValue placeholder="Select a participant" />
254+
</SelectTrigger>
255+
<SelectContent>
256+
{[{ name: 'None' }, ...form.watch('participants')]
257+
.filter((item) => item.name.length > 0)
258+
.map(({ name }) => (
259+
<SelectItem key={name} value={name}>
260+
{name}
261+
</SelectItem>
262+
))}
263+
</SelectContent>
264+
</Select>
265+
</FormControl>
266+
<FormDescription>
267+
User used as default for paying expenses.
268+
</FormDescription>
269+
</FormItem>
270+
)}
264271
</div>
265272
</CardContent>
266273
</Card>

0 commit comments

Comments
 (0)