feat(api): create template

Add template table to the database
Create controller function to check if user has template, and create it
in the database
Made universal jwt.Claims of user data retrieval function
This commit is contained in:
Leons Aleksandrovs
2025-07-09 23:19:31 +03:00
parent 3376043428
commit 938c9a66e5
10 changed files with 209 additions and 14 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ const Template = withForm({
<div className="mt-4 flex flex-col gap-4">
<form.AppField
name="name"
children={(f) => <f.TextField label="Name" placeholder="Template name" />}
children={(f) => <f.TextField maxLength={50} label="Name" placeholder="Template name" />}
/>
<form.AppField name="template" children={(f) => <f.RichTextEdit />} />
@@ -7,6 +7,7 @@ interface TextFieldProps {
placeholder?: string;
label?: string;
type?: React.ComponentProps<"input">["type"];
maxLength?: React.ComponentProps<"input">["maxLength"];
className?: string;
}
@@ -15,6 +16,7 @@ export default function TextField({
type = "text",
className = "",
label = "",
maxLength = 255,
}: TextFieldProps) {
// Get field with predefined text type
const field = useFieldContext<string>();
@@ -30,6 +32,7 @@ export default function TextField({
<Input
id={field.name}
maxLength={maxLength}
name={field.name}
value={field.state.value}
onBlur={field.handleBlur}
+5 -1
View File
@@ -11,7 +11,11 @@ export const Route = createFileRoute("/templates/create")({
});
const TemplateSchema = z.object({
name: z.string().nonempty("Name is required"),
name: z
.string()
.nonempty("Name is required")
.min(2, "Name is too short")
.max(50, "Name is too long (max 50)"),
template: z.string().nonempty("Template is required"),
});