Portal/rsconcept/frontend/src/components/info/BadgeConstituenta.tsx

50 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
import clsx from 'clsx';
import { CstClass, IConstituenta } from '@/models/rsform';
import { useTooltipsStore } from '@/stores/tooltips';
import { APP_COLORS, colorFgCstStatus } from '@/styling/color';
2024-12-20 14:36:20 +03:00
import { globals } from '@/utils/constants';
2024-06-07 20:17:03 +03:00
import { CProps } from '../props';
interface BadgeConstituentaProps extends CProps.Styling {
/** Prefix for tooltip ID. */
2024-06-07 20:17:03 +03:00
prefixID?: string;
/** Constituenta to display. */
2024-06-07 20:17:03 +03:00
value: IConstituenta;
}
/**
* Displays a badge with a constituenta alias and information tooltip.
*/
function BadgeConstituenta({ value, prefixID, className, style }: BadgeConstituentaProps) {
const setActiveCst = useTooltipsStore(state => state.setActiveCst);
2024-12-20 14:36:20 +03:00
2024-06-07 20:17:03 +03:00
return (
<div
2024-09-18 15:09:17 +03:00
id={`${prefixID}${value.id}`}
2024-06-07 20:17:03 +03:00
className={clsx(
'min-w-[3.1rem] max-w-[3.1rem]',
2024-06-07 20:17:03 +03:00
'px-1',
'border rounded-md',
2024-08-01 00:35:49 +03:00
value.is_inherited && 'border-dashed',
'text-center font-medium whitespace-nowrap',
className
2024-06-07 20:17:03 +03:00
)}
style={{
borderColor: colorFgCstStatus(value.status),
color: colorFgCstStatus(value.status),
backgroundColor: value.cst_class === CstClass.BASIC ? APP_COLORS.bgGreen25 : APP_COLORS.bgInput,
...style
2024-06-07 20:17:03 +03:00
}}
2024-12-20 14:36:20 +03:00
data-tooltip-id={globals.constituenta_tooltip}
onMouseEnter={() => setActiveCst(value)}
2024-06-07 20:17:03 +03:00
>
{value.alias}
</div>
);
}
export default BadgeConstituenta;