2024-09-25 19:48:28 +02:00
|
|
|
import { CustomPreference, defaultPreferences, mergePreferences } from "~/lib/api/user";
|
2024-09-24 20:56:10 +02:00
|
|
|
import { OverlayTrigger, Tooltip } from "react-bootstrap";
|
|
|
|
import Icon from "~/components/KeyedIcon";
|
|
|
|
|
|
|
|
export default function StatusIcon({
|
|
|
|
preferences,
|
|
|
|
status,
|
|
|
|
}: {
|
|
|
|
preferences: Record<string, CustomPreference>;
|
|
|
|
status: string;
|
|
|
|
}) {
|
2024-09-25 19:48:28 +02:00
|
|
|
const mergedPrefs = mergePreferences(preferences);
|
2024-09-24 20:56:10 +02:00
|
|
|
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>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|