import { useNavigation } from "react-router"; import clsx from "clsx"; import { useTranslation } from "react-i18next"; import { Stat } from "~/application/dtos/stats/Stat"; import { StatChange } from "~/application/dtos/stats/StatChange"; import { ArrowUpIcon, ArrowDownIcon } from "~/components/ui/icons/vendor"; interface Props { items: Stat[]; } function getStatChangeScreenReaderKey(changeType: StatChange | undefined) { if (changeType === StatChange.Increase) { return "components.stats.change.increasedBy"; } if (changeType === StatChange.Decrease) { return "components.stats.change.decreasedBy"; } return "components.stats.change.noChange"; } export function EntitiesStats({ items }: Props) { const { t } = useTranslation(); const navigation = useNavigation(); const loading = navigation.state === "loading"; return (

{t("app.shared.periods.LAST_30_DAYS")}

{items.map((item) => ( // Subframe StatsCard layout: px-4 py-4 cell padding, body-default label, subtitle value
{t(item.name)}
{item.hint &&
({t(item.hint)})
}
{loading ? "..." : item.stat}
{!loading && item.previousStat !== undefined && {t("shared.statComparison", { 0: item.previousStat })}}
{!loading && (
{item.changeType === StatChange.Increase ? ( ) : item.changeType === StatChange.Decrease ? ( ) : (
-
)} {t(getStatChangeScreenReaderKey(item.changeType))} {item.change}
)}
))}
); }