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

46 lines
1.3 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 { APP_COLORS, colorFgCstStatus } from '@/styling/color';
2024-06-07 20:17:03 +03:00
import { CProps } from '../props';
import TooltipConstituenta from './TooltipConstituenta';
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) {
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
}}
>
{value.alias}
2024-09-18 15:09:17 +03:00
<TooltipConstituenta anchor={`#${prefixID}${value.id}`} data={value} />
2024-06-07 20:17:03 +03:00
</div>
);
}
export default BadgeConstituenta;