mirror of
https://github.com/spliit-app/spliit.git
synced 2025-12-06 01:19:29 +01:00
Improve Next.js caching for some routes
This commit is contained in:
@@ -12,6 +12,8 @@ import { getBalances, getSuggestedReimbursements } from '@/lib/balances'
|
||||
import { Metadata } from 'next'
|
||||
import { notFound } from 'next/navigation'
|
||||
|
||||
export const dynamic = 'force-static'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Balances',
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ import { GroupForm } from '@/components/group-form'
|
||||
import { getGroup, getGroupExpensesParticipants, updateGroup } from '@/lib/api'
|
||||
import { groupFormSchema } from '@/lib/schemas'
|
||||
import { Metadata } from 'next'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { notFound, redirect } from 'next/navigation'
|
||||
|
||||
export const dynamic = 'force-static'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Settings',
|
||||
}
|
||||
@@ -20,7 +23,11 @@ export default async function EditGroupPage({
|
||||
'use server'
|
||||
const groupFormValues = groupFormSchema.parse(values)
|
||||
const group = await updateGroup(groupId, groupFormValues)
|
||||
redirect(`/groups/${group.id}`)
|
||||
revalidatePath(`/groups/${group.id}/expenses`)
|
||||
revalidatePath(`/groups/${group.id}/expenses/create`)
|
||||
revalidatePath(`/groups/${group.id}/balances`)
|
||||
revalidatePath(`/groups/${group.id}/edit`)
|
||||
redirect(`/groups/${group.id}/expenses`)
|
||||
}
|
||||
|
||||
const protectedParticipantIds = await getGroupExpensesParticipants(groupId)
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from '@/lib/api'
|
||||
import { expenseFormSchema } from '@/lib/schemas'
|
||||
import { Metadata } from 'next'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { notFound, redirect } from 'next/navigation'
|
||||
import { Suspense } from 'react'
|
||||
|
||||
@@ -30,7 +31,9 @@ export default async function EditExpensePage({
|
||||
'use server'
|
||||
const expenseFormValues = expenseFormSchema.parse(values)
|
||||
await updateExpense(groupId, expenseId, expenseFormValues)
|
||||
redirect(`/groups/${groupId}`)
|
||||
revalidatePath(`/groups/${groupId}/expenses`)
|
||||
revalidatePath(`/groups/${groupId}/balances`)
|
||||
redirect(`/groups/${groupId}/expenses`)
|
||||
}
|
||||
|
||||
async function deleteExpenseAction() {
|
||||
|
||||
@@ -5,6 +5,8 @@ import { Metadata } from 'next'
|
||||
import { notFound, redirect } from 'next/navigation'
|
||||
import { Suspense } from 'react'
|
||||
|
||||
export const dynamic = 'force-static'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Create expense',
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import Link from 'next/link'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { Suspense } from 'react'
|
||||
|
||||
export const dynamic = 'force-static'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Expenses',
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { redirect } from 'next/navigation'
|
||||
|
||||
export const dynamic = 'force-static'
|
||||
|
||||
export default async function GroupPage({
|
||||
params: { groupId },
|
||||
}: {
|
||||
|
||||
Reference in New Issue
Block a user