33import { useForm } from "react-hook-form" ;
44import { zodResolver } from "@hookform/resolvers/zod" ;
55import { format } from "date-fns" ;
6- import { CalendarIcon , Save , X } from "lucide-react" ;
6+ import { CalendarIcon , Save , X , Upload } from "lucide-react" ;
77import { useTranslations } from "next-intl" ;
88import { Button } from "@/components/ui/Button" ;
99import { Input } from "@/components/ui/Input" ;
@@ -12,11 +12,10 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
1212import { Popover , PopoverContent , PopoverTrigger } from "@/components/ui/Popover" ;
1313import { Calendar } from "@/components/ui/Calendar" ;
1414import { Select , SelectContent , SelectItem , SelectTrigger , SelectValue } from "@/components/ui/Select" ;
15- import { Switch } from "@/components/ui/Switch" ;
1615import TextEditor from "@/components/common/TextEditor/TextEditor" ;
1716import { cn , generateSlug } from "@/lib/utils" ;
1817import { createEventFormSchema , EventFormType } from "@/domains/Events" ;
19- import { eventTypes , eventStatuses } from "../constants" ;
18+ import { eventTypes , eventStatuses , sessionTypes } from "../constants" ;
2019import { useState , useEffect } from "react" ;
2120import Badge from "@/components/ui/Badge" ;
2221
@@ -39,21 +38,21 @@ const EventForm = ({ onSubmit, isLoading = false, initialData, mode = "create" }
3938 defaultValues : initialData || {
4039 title : "" ,
4140 description : "" ,
42- file_name : "" ,
4341 slug : "" ,
44- is_online : false ,
4542 date : "" ,
4643 type : "" ,
44+ session_type : "" ,
4745 location : "" ,
4846 duration : "" ,
49- status : "coming soon" ,
47+ status : "soon" ,
5048 capacity : 0 ,
5149 price : 0 ,
5250 registration_link : "" ,
5351 tags : [ ] ,
5452 speakers : [ ] ,
5553 reservation_start_date : "" ,
5654 reservation_end_date : "" ,
55+ image : "" ,
5756 } ,
5857 } ) ;
5958
@@ -99,7 +98,6 @@ const EventForm = ({ onSubmit, isLoading = false, initialData, mode = "create" }
9998 } ;
10099
101100 const handleSubmit = ( data : EventFormType ) => {
102- console . log ( "dataaaa" , data ) ;
103101 onSubmit ( data ) ;
104102 } ;
105103
@@ -159,7 +157,32 @@ const EventForm = ({ onSubmit, isLoading = false, initialData, mode = "create" }
159157 ) }
160158 />
161159
162- < div className = "grid grid-cols-1 gap-4 md:grid-cols-2" >
160+ < FormField
161+ control = { form . control }
162+ name = "image"
163+ render = { ( { field } ) => (
164+ < FormItem >
165+ < FormLabel aria-required > { t ( "labels.image" ) } </ FormLabel >
166+ < FormControl >
167+ < div className = "flex items-center gap-4" >
168+ < Input
169+ type = "file"
170+ accept = "image/*"
171+ onChange = { ( e ) => {
172+ const file = e . target . files ?. [ 0 ] ;
173+ field . onChange ( file ) ;
174+ } }
175+ className = "file:bg-primary file:text-primary-foreground hover:file:bg-primary/90 file:mr-4 file:rounded-md file:border-0 file:px-4 file:py-2 file:text-sm file:font-medium"
176+ />
177+ < Upload className = "text-muted-foreground h-4 w-4" />
178+ </ div >
179+ </ FormControl >
180+ < FormMessage />
181+ </ FormItem >
182+ ) }
183+ />
184+
185+ < div className = "grid grid-cols-1 gap-4 md:grid-cols-3" >
163186 < FormField
164187 control = { form . control }
165188 name = "type"
@@ -185,6 +208,31 @@ const EventForm = ({ onSubmit, isLoading = false, initialData, mode = "create" }
185208 ) }
186209 />
187210
211+ < FormField
212+ control = { form . control }
213+ name = "session_type"
214+ render = { ( { field } ) => (
215+ < FormItem >
216+ < FormLabel aria-required > { t ( "labels.session-type" ) } </ FormLabel >
217+ < Select onValueChange = { field . onChange } defaultValue = { field . value } >
218+ < FormControl >
219+ < SelectTrigger >
220+ < SelectValue placeholder = { t ( "placeholders.session-type" ) } />
221+ </ SelectTrigger >
222+ </ FormControl >
223+ < SelectContent >
224+ { sessionTypes . map ( ( sessionType ) => (
225+ < SelectItem key = { sessionType . value } value = { sessionType . value } >
226+ { sessionType . label }
227+ </ SelectItem >
228+ ) ) }
229+ </ SelectContent >
230+ </ Select >
231+ < FormMessage />
232+ </ FormItem >
233+ ) }
234+ />
235+
188236 < FormField
189237 control = { form . control }
190238 name = "status"
@@ -465,22 +513,6 @@ const EventForm = ({ onSubmit, isLoading = false, initialData, mode = "create" }
465513 ) }
466514 />
467515
468- < FormField
469- control = { form . control }
470- name = "is_online"
471- render = { ( { field } ) => (
472- < FormItem className = "flex flex-row items-center justify-between rounded-lg border p-4" >
473- < div className = "space-y-0.5" >
474- < FormLabel className = "text-base" > { t ( "labels.online-event" ) } </ FormLabel >
475- < div className = "text-muted-foreground text-sm" > { t ( "labels.online-description" ) } </ div >
476- </ div >
477- < FormControl >
478- < Switch checked = { field . value } onCheckedChange = { field . onChange } />
479- </ FormControl >
480- </ FormItem >
481- ) }
482- />
483-
484516 < div className = "flex gap-4 pt-4" >
485517 < Button type = "submit" className = "bg-hmc-base-blue hover:bg-hmc-base-blue/90" disabled = { isLoading } >
486518 < Save className = "mr-2 h-4 w-4" />
0 commit comments