1- import { Checkbox , DatePicker , Input , Select , SelectItem } from '@heroui/react' ;
1+ import {
2+ Checkbox ,
3+ DatePicker ,
4+ Input ,
5+ Radio ,
6+ RadioGroup ,
7+ Select ,
8+ SelectItem ,
9+ } from '@heroui/react' ;
210import { fromDate , getLocalTimeZone } from '@internationalized/date' ;
311import { Controller } from 'react-hook-form' ;
412
13+ import { Supporter } from '@/components/event-form/event-form-types' ;
514import { cities } from '@/data/cities' ;
615
716import type { UseFormReturn } from 'react-hook-form' ;
@@ -15,7 +24,7 @@ interface EventFormControlsProps {
1524export const EventFormControls = ( {
1625 form : { control, setValue, watch } ,
1726} : EventFormControlsProps ) => {
18- const withPartners = watch ( 'withPartners ' ) ;
27+ const withSupporters = watch ( 'withSupporters ' ) ;
1928
2029 return (
2130 < >
@@ -84,30 +93,50 @@ export const EventFormControls = ({
8493 />
8594 < Controller
8695 control = { control }
87- name = "withPartners "
96+ name = "withSupporters "
8897 render = { ( { field : { value, onChange, ...field } } ) => (
8998 < Checkbox isSelected = { value } onValueChange = { onChange } { ...field } >
90- Partner
99+ Supporter
91100 </ Checkbox >
92101 ) }
93102 />
94- { withPartners && (
95- < Controller
96- control = { control }
97- name = "partners"
98- render = { ( { field : { onChange } } ) => (
99- < Input
100- type = "file"
101- accept = "image/*"
102- multiple
103- label = "Partners' logos"
104- isRequired
105- onChange = { ( { target : { files } } ) =>
106- files && onChange ( [ ...files ] )
107- }
108- />
109- ) }
110- />
103+ { withSupporters && (
104+ < >
105+ < Controller
106+ control = { control }
107+ name = "supporterImages"
108+ render = { ( { field : { onChange } } ) => (
109+ < Input
110+ type = "file"
111+ accept = "image/*"
112+ multiple
113+ label = "Supporters' logos"
114+ isRequired
115+ onChange = { ( { target : { files } } ) =>
116+ files && onChange ( [ ...files ] )
117+ }
118+ />
119+ ) }
120+ />
121+ < Controller
122+ control = { control }
123+ name = "supporter"
124+ render = { ( { field : { value, onChange, ...field } } ) => (
125+ < RadioGroup
126+ isRequired
127+ label = "Select supporter type"
128+ orientation = "horizontal"
129+ value = { value === null ? '' : value }
130+ onValueChange = { value => onChange ( value === '' ? null : value ) }
131+ { ...field }
132+ >
133+ < Radio value = { Supporter . EventPartner } > Event partner</ Radio >
134+ < Radio value = { Supporter . Sponsor } > Sponsor</ Radio >
135+ < Radio value = "" > Logo only</ Radio >
136+ </ RadioGroup >
137+ ) }
138+ />
139+ </ >
111140 ) }
112141 </ >
113142 ) ;
0 commit comments