MCPcopy Create free account
hub / github.com/Open-Dev-Society/OpenStock / SelectField

Function SelectField

components/forms/SelectField.tsx:12–41  ·  view source on GitHub ↗
({name, label, placeholder, options, control, error, required = false}: SelectFieldProps)

Source from the content-addressed store, hash-verified

10} from "@/components/ui/select"
11
12const SelectField = ({name, label, placeholder, options, control, error, required = false}: SelectFieldProps) => {
13 return (
14 <div className="space-y-2">
15 <Label htmlFor={name}>{label}</Label>
16
17 <Controller
18 name={name}
19 control={control}
20 rules={{
21 required: required ? `Please select ${label.toLowerCase()}`:false,
22 }}
23 render={({field}) => (
24 <Select value={field.value} onValueChange={field.onChange}>
25 <SelectTrigger className="select-trigger">
26 <SelectValue placeholder={placeholder} />
27 </SelectTrigger>
28 <SelectContent className="bg-gray-800 border-gray-600 text-white">
29 {options.map((option) => (
30 <SelectItem key={option.value} value={option.value} className="focus:bg-gray-600 focus: text-white">
31 {option.label}
32 </SelectItem>
33 ))}
34 </SelectContent>
35 {error && <p className="text-red-600">{error.message}</p>}
36 </Select>
37 )}
38 />
39 </div>
40 )
41}
42export default SelectField

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected