@@ -21,6 +21,7 @@ import {
2121 SelectTrigger ,
2222 SelectValue ,
2323} from "@/components/ui/select" ;
24+ import { Checkbox } from "@/components/ui/checkbox" ;
2425import { Textarea } from "@/components/ui/textarea" ;
2526import { Card , CardContent , CardHeader , CardTitle } from "@/components/ui/card" ;
2627import { CloudflareTurnstileWidget } from "@/components/cloudflare-turnstile" ;
@@ -71,7 +72,9 @@ const formSchema = z.object({
7172 message : "Please enter a valid email address." ,
7273 } ) ,
7374 companyName : z . string ( ) . optional ( ) ,
74- sponsorshipTier : z . string ( ) . min ( 1 , "Please select a sponsorship tier." ) ,
75+ sponsorshipTier : z . array ( z . string ( ) ) . refine ( ( value ) => value . some ( ( item ) => item ) , {
76+ message : "You have to select at least one item." ,
77+ } ) ,
7578 message : z . string ( ) . optional ( ) ,
7679 honeypot : z . string ( ) . optional ( ) , // Honeypot field
7780 "cf-turnstile-response" : z . string ( ) . min ( 1 , { message : "Please complete the CAPTCHA." } ) ,
@@ -84,7 +87,7 @@ export default function SponsorshipsPage() {
8487 fullName : "" ,
8588 email : "" ,
8689 companyName : "" ,
87- sponsorshipTier : undefined ,
90+ sponsorshipTier : [ ] ,
8891 message : "" ,
8992 honeypot : "" ,
9093 "cf-turnstile-response" : "" ,
@@ -207,26 +210,47 @@ export default function SponsorshipsPage() {
207210 < FormField
208211 control = { form . control }
209212 name = "sponsorshipTier"
210- render = { ( { field } ) => (
213+ render = { ( ) => (
211214 < FormItem >
212- < FormLabel > Sponsorship Tier of Interest</ FormLabel >
213- < Select
214- onValueChange = { field . onChange }
215- defaultValue = { field . value }
216- >
217- < FormControl >
218- < SelectTrigger >
219- < SelectValue placeholder = "Select a tier" />
220- </ SelectTrigger >
221- </ FormControl >
222- < SelectContent >
223- { sponsorshipTiers . map ( ( tier ) => (
224- < SelectItem key = { tier . value } value = { tier . value } >
225- { tier . name }
226- </ SelectItem >
227- ) ) }
228- </ SelectContent >
229- </ Select >
215+ < div className = "mb-4" >
216+ < FormLabel className = "text-base" > Sponsorship Tiers of Interest</ FormLabel >
217+ < FormDescription >
218+ Select all that apply.
219+ </ FormDescription >
220+ </ div >
221+ { sponsorshipTiers . map ( ( item ) => (
222+ < FormField
223+ key = { item . value }
224+ control = { form . control }
225+ name = "sponsorshipTier"
226+ render = { ( { field } ) => {
227+ return (
228+ < FormItem
229+ key = { item . value }
230+ className = "flex flex-row items-start space-x-3 space-y-0"
231+ >
232+ < FormControl >
233+ < Checkbox
234+ checked = { field . value ?. includes ( item . value ) }
235+ onCheckedChange = { ( checked ) => {
236+ return checked
237+ ? field . onChange ( [ ...field . value , item . value ] )
238+ : field . onChange (
239+ field . value ?. filter (
240+ ( value ) => value !== item . value ,
241+ ) ,
242+ ) ;
243+ } }
244+ />
245+ </ FormControl >
246+ < FormLabel className = "font-normal" >
247+ { item . name }
248+ </ FormLabel >
249+ </ FormItem >
250+ ) ;
251+ } }
252+ />
253+ ) ) }
230254 < FormMessage />
231255 </ FormItem >
232256 ) }
0 commit comments