krishna_sales/src/components/forms/fields/SelectField.tsx
2026-07-24 12:56:03 +05:30

30 lines
676 B
TypeScript

import { Select } from '../../reusable/Select';
export function SelectField({
label,
required,
value,
options,
onChange,
}: {
label: string;
required?: boolean;
value: string;
options: any[];
onChange: (val: string, fullRow?: any) => void;
}) {
return (
<Select
label={label}
required={required}
value={value ?? ''}
onChange={(e) => {
const val = e.target.value;
const opt = options.find((o: any) => String(o.value) === val);
onChange(val, opt?._raw);
}}
options={[{ value: '', label: 'Select...' }, ...options.map((o: any) => ({ value: String(o.value), label: o.label }))]}
/>
);
}