ConceptPortal-public/rsconcept/frontend/src/features/rsform/components/select-constituenta.tsx

33 lines
908 B
TypeScript
Raw Normal View History

2025-04-11 20:00:42 +03:00
import { ComboBox } from '@/components/ui/combo-box';
2025-02-12 21:36:25 +03:00
import { describeConstituenta, describeConstituentaTerm } from '../labels';
import { type IConstituenta } from '../models/rsform';
2025-04-11 20:00:42 +03:00
interface SelectConstituentaProps {
id?: string;
value: IConstituenta | null;
onChange: (newValue: IConstituenta | null) => void;
2024-07-26 21:09:16 +03:00
2025-04-11 20:00:42 +03:00
className?: string;
items?: IConstituenta[];
2024-05-27 20:42:34 +03:00
placeholder?: string;
2024-07-26 21:09:16 +03:00
noBorder?: boolean;
}
export function SelectConstituenta({
2024-05-27 20:42:34 +03:00
items,
placeholder = 'Выберите конституенту',
...restProps
}: SelectConstituentaProps) {
return (
2025-04-11 20:00:42 +03:00
<ComboBox
items={items}
2024-05-27 20:42:34 +03:00
placeholder={placeholder}
2025-04-11 20:00:42 +03:00
idFunc={cst => String(cst.id)}
labelValueFunc={cst => `${cst.alias}: ${describeConstituentaTerm(cst)}`}
labelOptionFunc={cst => `${cst.alias}${cst.is_inherited ? '*' : ''}: ${describeConstituenta(cst)}`}
{...restProps}
/>
);
}