@@ -7,12 +7,14 @@ import { z } from "zod";
77import { Button } from "@/components/ui/button" ;
88import { Input } from "@/components/ui/input" ;
99import { Label } from "@/components/ui/label" ;
10+ import { Select , SelectContent , SelectItem , SelectTrigger , SelectValue } from "@/components/ui/select" ;
1011import { toast } from "sonner" ;
1112
1213const schema = z . object ( {
1314 firstName : z . string ( ) . min ( 1 , "Required" ) ,
1415 lastName : z . string ( ) . min ( 1 , "Required" ) ,
1516 email : z . string ( ) . email ( ) ,
17+ graduated : z . enum ( [ "true" , "false" ] ) ,
1618} ) ;
1719
1820type FormData = z . infer < typeof schema > ;
@@ -24,6 +26,7 @@ export function InviteForm({ onSuccess }: { onSuccess?: () => void }) {
2426 register,
2527 handleSubmit,
2628 reset,
29+ setValue,
2730 formState : { errors } ,
2831 } = useForm < FormData > ( { resolver : zodResolver ( schema ) } ) ;
2932
@@ -33,7 +36,7 @@ export function InviteForm({ onSuccess }: { onSuccess?: () => void }) {
3336 const res = await fetch ( "/api/invitations" , {
3437 method : "POST" ,
3538 headers : { "Content-Type" : "application/json" } ,
36- body : JSON . stringify ( data ) ,
39+ body : JSON . stringify ( { ... data , graduated : data . graduated === "true" } ) ,
3740 } ) ;
3841 if ( ! res . ok ) {
3942 const body = await res . json ( ) ;
@@ -84,6 +87,21 @@ export function InviteForm({ onSuccess }: { onSuccess?: () => void }) {
8487 < p className = "text-sm text-destructive" > { errors . email . message } </ p >
8588 ) }
8689 </ div >
90+ < div className = "space-y-1" >
91+ < Label > Status</ Label >
92+ < Select onValueChange = { ( v ) => setValue ( "graduated" , v as "true" | "false" ) } >
93+ < SelectTrigger >
94+ < SelectValue placeholder = "Select…" />
95+ </ SelectTrigger >
96+ < SelectContent >
97+ < SelectItem value = "true" > Alumni (graduated)</ SelectItem >
98+ < SelectItem value = "false" > Student (current)</ SelectItem >
99+ </ SelectContent >
100+ </ Select >
101+ { errors . graduated && (
102+ < p className = "text-sm text-destructive" > Required</ p >
103+ ) }
104+ </ div >
87105 < Button type = "submit" disabled = { loading } >
88106 { loading ? "Sending…" : "Send invite" }
89107 </ Button >
0 commit comments