2025-04-13 22:29:23 +03:00
|
|
|
import { ComboBox } from '@/components/input/combo-box';
|
2024-03-01 18:19:33 +03:00
|
|
|
|
2025-02-12 21:36:25 +03:00
|
|
|
import { describeConstituenta, describeConstituentaTerm } from '../labels';
|
2025-02-21 21:15:05 +03:00
|
|
|
import { type IConstituenta } from '../models/rsform';
|
2025-02-10 01:32:55 +03:00
|
|
|
|
2025-04-11 20:00:42 +03:00
|
|
|
interface SelectConstituentaProps {
|
|
|
|
id?: string;
|
2025-02-19 22:33:09 +03:00
|
|
|
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;
|
2025-02-04 20:35:55 +03:00
|
|
|
items?: IConstituenta[];
|
2024-05-27 20:42:34 +03:00
|
|
|
placeholder?: string;
|
2024-07-26 21:09:16 +03:00
|
|
|
noBorder?: boolean;
|
2024-03-01 18:19:33 +03:00
|
|
|
}
|
|
|
|
|
2025-02-19 22:33:09 +03:00
|
|
|
export function SelectConstituenta({
|
2024-05-27 20:42:34 +03:00
|
|
|
items,
|
|
|
|
placeholder = 'Выберите конституенту',
|
|
|
|
...restProps
|
|
|
|
}: SelectConstituentaProps) {
|
2024-03-01 18:19:33 +03:00
|
|
|
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)}`}
|
2024-03-21 17:48:42 +03:00
|
|
|
{...restProps}
|
2024-03-01 18:19:33 +03:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|