2023-12-13 14:32:57 +03:00
|
|
|
|
import ConceptTooltip from '@/components/Common/ConceptTooltip';
|
|
|
|
|
import ConstituentaTooltip from '@/components/Help/ConstituentaTooltip';
|
|
|
|
|
import { IConstituenta } from '@/models/rsform';
|
|
|
|
|
import { isMockCst } from '@/models/rsformAPI';
|
|
|
|
|
import { colorfgCstStatus,IColorTheme } from '@/utils/color';
|
|
|
|
|
import { describeExpressionStatus } from '@/utils/labels';
|
2023-11-06 18:03:23 +03:00
|
|
|
|
|
|
|
|
|
interface ConstituentaBadgeProps {
|
|
|
|
|
prefixID?: string
|
|
|
|
|
shortTooltip?: boolean
|
|
|
|
|
value: IConstituenta
|
|
|
|
|
theme: IColorTheme
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ConstituentaBadge({ value, prefixID, shortTooltip, theme }: ConstituentaBadgeProps) {
|
2023-12-05 01:22:44 +03:00
|
|
|
|
return (
|
|
|
|
|
<div className='w-fit'>
|
2023-11-06 18:03:23 +03:00
|
|
|
|
<div
|
|
|
|
|
id={`${prefixID}${value.alias}`}
|
|
|
|
|
className='min-w-[3.1rem] max-w-[3.1rem] px-1 text-center rounded-md whitespace-nowrap'
|
|
|
|
|
style={{
|
|
|
|
|
borderWidth: '1px',
|
|
|
|
|
borderColor: colorfgCstStatus(value.status, theme),
|
|
|
|
|
color: colorfgCstStatus(value.status, theme),
|
|
|
|
|
backgroundColor: isMockCst(value) ? theme.bgWarning : theme.bgInput,
|
|
|
|
|
fontWeight: 600
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{value.alias}
|
|
|
|
|
</div>
|
2023-11-27 11:33:34 +03:00
|
|
|
|
{!shortTooltip ?
|
|
|
|
|
<ConstituentaTooltip
|
|
|
|
|
anchor={`#${prefixID}${value.alias}`}
|
|
|
|
|
data={value}
|
|
|
|
|
/> : null}
|
|
|
|
|
{shortTooltip ?
|
2023-11-06 18:03:23 +03:00
|
|
|
|
<ConceptTooltip
|
|
|
|
|
anchorSelect={`#${prefixID}${value.alias}`}
|
|
|
|
|
place='right'
|
|
|
|
|
>
|
|
|
|
|
<p><span className='font-semibold'>Статус</span>: {describeExpressionStatus(value.status)}</p>
|
2023-11-27 11:33:34 +03:00
|
|
|
|
</ConceptTooltip> : null}
|
2023-11-06 18:03:23 +03:00
|
|
|
|
</div>);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ConstituentaBadge;
|