"use client"; import { useI18n } from "@/lib/i18n/useI18n"; import type { RecapRangeMode } from "@/lib/recap/types"; type Props = { oeeAvg: number | null; goodParts: number; totalStops: number; scrapParts: number; rangeMode?: RecapRangeMode; }; export default function RecapKpiRow({ oeeAvg, goodParts, totalStops, scrapParts, rangeMode = "24h" }: Props) { const { t } = useI18n(); const oeeLabel = rangeMode === "shift" ? t("recap.kpi.oeeShift") : rangeMode === "yesterday" ? t("recap.kpi.oeeYesterday") : rangeMode === "custom" ? t("recap.kpi.oeeCustom") : t("recap.kpi.oee24h"); const items = [ { label: t("recap.kpi.good"), value: String(goodParts), valueClass: "text-white" }, { label: t("recap.kpi.stops"), value: String(totalStops), valueClass: totalStops > 0 ? "text-amber-300" : "text-white" }, { label: t("recap.kpi.scrap"), value: String(scrapParts), valueClass: scrapParts > 0 ? "text-red-300" : "text-white" }, ]; return (
{oeeAvg == null || Number.isNaN(oeeAvg) ? "—" : `${oeeAvg.toFixed(1)}%`}
{oeeLabel}
{oeeAvg == null || Number.isNaN(oeeAvg) ? (
{t("recap.kpi.noData")}
) : null}
{items.map((item) => (
{item.value}
{item.label}
))}
); }