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:
@@ -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}
|
||||
|
||||
@@ -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"),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user