feat: pagination + hide fields in settings

This commit is contained in:
Vasily Zubarev
2025-03-27 08:48:47 +01:00
parent a80684c3fb
commit 61da617f68
25 changed files with 813 additions and 220 deletions

View File

@@ -1,6 +1,7 @@
import { addFieldAction, deleteFieldAction, editFieldAction } from "@/app/settings/actions"
import { CrudTable } from "@/components/settings/crud"
import { getFields } from "@/models/fields"
import { Prisma } from "@prisma/client"
export default async function FieldsSettingsPage() {
const fields = await getFields()
@@ -12,38 +13,50 @@ export default async function FieldsSettingsPage() {
return (
<div className="container">
<h1 className="text-2xl font-bold mb-6">Custom Fields</h1>
<h1 className="text-2xl font-bold mb-2">Custom Fields</h1>
<p className="text-sm text-gray-500 mb-6 max-w-prose">
You can add new fields to your transactions. Standard fields can't be removed but you can tweak their prompts or
hide them. If you don't want a field to be analyzed by AI but filled in by hand, leave the "LLM prompt" empty.
</p>
<CrudTable
items={fieldsWithActions}
columns={[
{ key: "name", label: "Name", editable: true },
{ key: "type", label: "Type", defaultValue: "string", editable: true },
{
key: "type",
label: "Type",
type: "select",
options: ["string", "number", "boolean"],
defaultValue: "string",
editable: true,
},
{ key: "llm_prompt", label: "LLM Prompt", editable: true },
{
key: "isVisibleInList",
label: "Show in transactions table",
type: "checkbox",
defaultValue: false,
editable: true,
},
{
key: "isVisibleInAnalysis",
label: "Show in analysis form",
type: "checkbox",
defaultValue: false,
editable: true,
},
]}
onDelete={async (code) => {
"use server"
await deleteFieldAction(code)
return await deleteFieldAction(code)
}}
onAdd={async (data) => {
"use server"
await addFieldAction(
data as {
name: string
type: string
llm_prompt?: string
}
)
return await addFieldAction(data as Prisma.FieldCreateInput)
}}
onEdit={async (code, data) => {
"use server"
await editFieldAction(
code,
data as {
name: string
type: string
llm_prompt?: string
}
)
return await editFieldAction(code, data as Prisma.FieldUpdateInput)
}}
/>
</div>