feat(frontend): add flags to user page

This commit is contained in:
sam 2024-09-29 20:24:47 +02:00
parent f539902711
commit dc18ab60d2
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
10 changed files with 68 additions and 5 deletions

View file

@ -0,0 +1,34 @@
import { CustomPreference, defaultPreferences, mergePreferences } from "~/lib/api/user";
import { OverlayTrigger, Tooltip } from "react-bootstrap";
import Icon from "~/components/KeyedIcon";
export default function StatusIcon({
preferences,
status,
}: {
preferences: Record<string, CustomPreference>;
status: string;
}) {
const mergedPrefs = mergePreferences(preferences);
const currentPref = status in mergedPrefs ? mergedPrefs[status] : defaultPreferences.missing;
const id = crypto.randomUUID();
return (
<>
<OverlayTrigger
key={id}
placement="top"
overlay={
<Tooltip id={id} aria-hidden={true}>
{currentPref.tooltip}
</Tooltip>
}
>
<span className="d-inline-block">
<Icon iconName={currentPref.icon} aria-hidden={true} style={{ pointerEvents: "none" }} />
</span>
</OverlayTrigger>
<span className="visually-hidden">{currentPref.tooltip}:</span>
</>
);
}