feat: add plan title field with data migration

This commit is contained in:
2026-01-12 22:32:45 +01:00
parent 9db5466fb2
commit 3de2661f46
8 changed files with 72 additions and 7 deletions

View File

@@ -33,6 +33,9 @@ export function CreatePlanForm({ dict, lang }: CreatePlanFormProps) {
const router = useRouter()
const formSchema = z.object({
title: z.string().min(2, {
message: dict.titleError,
}),
dateRange: z.object({
from: z.date(),
to: z.date(),
@@ -46,6 +49,7 @@ export function CreatePlanForm({ dict, lang }: CreatePlanFormProps) {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
title: "",
password: "",
instructions: "",
},
@@ -59,6 +63,7 @@ export function CreatePlanForm({ dict, lang }: CreatePlanFormProps) {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
title: values.title,
startDate: values.dateRange.from,
endDate: values.dateRange.to,
password: values.password,
@@ -81,7 +86,21 @@ export function CreatePlanForm({ dict, lang }: CreatePlanFormProps) {
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
<FormField
control={form.control}
name="title"
render={({ field }) => (
<FormItem>
<FormLabel>{dict.title}</FormLabel>
<FormControl>
<Input placeholder={dict.titlePlaceholder} {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="dateRange"
@@ -150,7 +169,7 @@ export function CreatePlanForm({ dict, lang }: CreatePlanFormProps) {
</FormItem>
)}
/>
<Button type="submit">{dict.submit}</Button>
<Button type="submit" className="w-full">{dict.submit}</Button>
</form>
</Form>
)