mirror of
https://github.com/spliit-app/spliit.git
synced 2025-12-06 01:19:29 +01:00
* Move prisma to runtime dependencies * Optimize Dockerfile and build script * Fix: remove mention of generated next-env.d.ts in Dockerfile * Add missing reset.d.ts file to Dockerfile * Remove compression steps from Dockerfile and entrypoint script * Add an env file with mocked env vars added for Docker production builds * Use server actions to get runtime env vars * Refactor types and names * Rollback serverActions, use parsed Zod object for runtime env * Reintroduce featureFlags object to avoid passing secret envs to the frontend * Improve string to boolean coercion Co-authored-by: Sebastien Castiel <sebastien@castiel.me> * Run prettier autoformat * Fix type issue, rename function to match behaviour better --------- Co-authored-by: Lauri Vuorela <lauri.vuorela@gmail.com> Co-authored-by: Sebastien Castiel <sebastien@castiel.me>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { cached } from '@/app/cached-functions'
|
|
import { ExpenseForm } from '@/components/expense-form'
|
|
import { createExpense, getCategories } from '@/lib/api'
|
|
import { getRuntimeFeatureFlags } from '@/lib/featureFlags'
|
|
import { expenseFormSchema } from '@/lib/schemas'
|
|
import { Metadata } from 'next'
|
|
import { notFound, redirect } from 'next/navigation'
|
|
import { Suspense } from 'react'
|
|
|
|
export const metadata: Metadata = {
|
|
title: 'Create expense',
|
|
}
|
|
|
|
export default async function ExpensePage({
|
|
params: { groupId },
|
|
}: {
|
|
params: { groupId: string }
|
|
}) {
|
|
const categories = await getCategories()
|
|
const group = await cached.getGroup(groupId)
|
|
if (!group) notFound()
|
|
|
|
async function createExpenseAction(values: unknown) {
|
|
'use server'
|
|
const expenseFormValues = expenseFormSchema.parse(values)
|
|
await createExpense(expenseFormValues, groupId)
|
|
redirect(`/groups/${groupId}`)
|
|
}
|
|
|
|
return (
|
|
<Suspense>
|
|
<ExpenseForm
|
|
group={group}
|
|
categories={categories}
|
|
onSubmit={createExpenseAction}
|
|
runtimeFeatureFlags={await getRuntimeFeatureFlags()}
|
|
/>
|
|
</Suspense>
|
|
)
|
|
}
|