Skip to content

Commit 9867493

Browse files
committed
Add published at to article form
1 parent a6417cf commit 9867493

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

frontend/src/pages/organiser/article/article-form.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { FloppyDisk } from '@phosphor-icons/react';
1919
const FormSchema = z.object({
2020
title: z.string().min(1, "Title is required"),
2121
content: z.string().min(1, "Content is required"),
22+
published_at: z.string().nullable(),
2223
});
2324

2425
type FormData = z.infer<typeof FormSchema>;
@@ -37,6 +38,7 @@ export function ArticleForm() {
3738
defaultValues: {
3839
title: '',
3940
content: '',
41+
published_at: null,
4042
},
4143
});
4244

@@ -65,7 +67,7 @@ export function ArticleForm() {
6567
const articleData = {
6668
...data,
6769
content: content,
68-
published_at: new Date().toISOString(),
70+
published_at: data.published_at || new Date().toISOString(),
6971
slug: slugify(data.title),
7072
};
7173

@@ -137,6 +139,26 @@ export function ArticleForm() {
137139
}}
138140
/>
139141

142+
<FormField
143+
control={form.control}
144+
name="published_at"
145+
render={({ field }) => (
146+
<FormItem>
147+
<FormLabel>
148+
{t('article.form.published_at.label')}
149+
</FormLabel>
150+
<FormControl>
151+
<Input
152+
type="datetime-local"
153+
{...field}
154+
value={field.value || ''}
155+
onChange={(e) => field.onChange(e.target.value || null)}
156+
/>
157+
</FormControl>
158+
<FormMessage />
159+
</FormItem>
160+
)}
161+
/>
140162
</div>
141163

142164
<div className="flex justify-end space-x-4">

0 commit comments

Comments
 (0)