Use React’s cache to avoid some queries to the database

This commit is contained in:
Sebastien Castiel
2024-01-29 22:37:13 -05:00
parent 3847a67a19
commit 9e300e0ff0
8 changed files with 40 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
import { cached } from '@/app/cached-functions'
import { ExpenseForm } from '@/components/expense-form'
import { createExpense, getCategories, getGroup } from '@/lib/api'
import { createExpense, getCategories } from '@/lib/api'
import { expenseFormSchema } from '@/lib/schemas'
import { Metadata } from 'next'
import { notFound, redirect } from 'next/navigation'
@@ -15,7 +16,7 @@ export default async function ExpensePage({
params: { groupId: string }
}) {
const categories = await getCategories()
const group = await getGroup(groupId)
const group = await cached.getGroup(groupId)
if (!group) notFound()
async function createExpenseAction(values: unknown) {