File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
frontend/src/pages/organiser/article Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { FloppyDisk } from '@phosphor-icons/react';
19
19
const FormSchema = z . object ( {
20
20
title : z . string ( ) . min ( 1 , "Title is required" ) ,
21
21
content : z . string ( ) . min ( 1 , "Content is required" ) ,
22
+ published_at : z . string ( ) . nullable ( ) ,
22
23
} ) ;
23
24
24
25
type FormData = z . infer < typeof FormSchema > ;
@@ -37,6 +38,7 @@ export function ArticleForm() {
37
38
defaultValues : {
38
39
title : '' ,
39
40
content : '' ,
41
+ published_at : null ,
40
42
} ,
41
43
} ) ;
42
44
@@ -65,7 +67,7 @@ export function ArticleForm() {
65
67
const articleData = {
66
68
...data ,
67
69
content : content ,
68
- published_at : new Date ( ) . toISOString ( ) ,
70
+ published_at : data . published_at || new Date ( ) . toISOString ( ) ,
69
71
slug : slugify ( data . title ) ,
70
72
} ;
71
73
@@ -137,6 +139,26 @@ export function ArticleForm() {
137
139
} }
138
140
/>
139
141
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
+ />
140
162
</ div >
141
163
142
164
< div className = "flex justify-end space-x-4" >
You can’t perform that action at this time.
0 commit comments