ConceptPortal-public/rsconcept/frontend/src/features/rsform/components/select-constituenta.tsx
2025-04-13 22:29:23 +03:00

33 lines
911 B
TypeScript

import { ComboBox } from '@/components/input/combo-box';
import { describeConstituenta, describeConstituentaTerm } from '../labels';
import { type IConstituenta } from '../models/rsform';
interface SelectConstituentaProps {
id?: string;
value: IConstituenta | null;
onChange: (newValue: IConstituenta | null) => void;
className?: string;
items?: IConstituenta[];
placeholder?: string;
noBorder?: boolean;
}
export function SelectConstituenta({
items,
placeholder = 'Выберите конституенту',
...restProps
}: SelectConstituentaProps) {
return (
<ComboBox
items={items}
placeholder={placeholder}
idFunc={cst => String(cst.id)}
labelValueFunc={cst => `${cst.alias}: ${describeConstituentaTerm(cst)}`}
labelOptionFunc={cst => `${cst.alias}${cst.is_inherited ? '*' : ''}: ${describeConstituenta(cst)}`}
{...restProps}
/>
);
}