Files
zemion 492ab7711a fix(ui): centralize contextual help and navigation presentation
Verified with the coordinated workspace changes by devkit full run
2026-09-08T225814-186389-0000-3e3ed7cd (all seven phases passed).
This shared UI pass does not mark the individual module reviews complete.
2026-09-09 02:03:55 +02:00

76 lines
2.3 KiB
TypeScript

import { MetricGrid } from "@govoplan/core-webui";
import { Link } from "react-router";
import {
DismissibleAlert,
LoadingFrame,
MetricCard,
adminErrorMessage,
i18nMessage,
type ApiSettings,
type DashboardWidgetConfiguration,
useSharedNotificationSummary
} from "@govoplan/core-webui";
export default function NotificationSummaryWidget({
settings,
refreshKey,
configuration,
showCenterLink
}: {
settings: ApiSettings;
refreshKey: number;
configuration: DashboardWidgetConfiguration;
showCenterLink: boolean;
}) {
const showDeliveryState = configuration.showDeliveryState !== false;
const state = useSharedNotificationSummary(settings, {
enabled: true,
scopeKey: "current-session",
intervalMs: 30_000,
refreshKey
});
const summary = state.summary;
const error = state.error ? adminErrorMessage(state.error) : "";
return (
<LoadingFrame loading={state.loading} label="i18n:govoplan-notifications.loading_summary">
{error && (
<DismissibleAlert tone="warning" resetKey={error}>
{error}
</DismissibleAlert>
)}
<MetricGrid columns={3} spacing="none">
<MetricCard
label="i18n:govoplan-notifications.unread"
value={summary?.unread ?? 0}
tone={summary?.unread ? "info" : "good"}
detail={i18nMessage("i18n:govoplan-notifications.value_total", { value0: summary?.total ?? 0 })}
/>
{showDeliveryState && (
<MetricCard
label="i18n:govoplan-notifications.pending"
value={summary?.pending ?? 0}
tone={summary?.pending ? "warning" : "good"}
detail="i18n:govoplan-notifications.awaiting_delivery"
/>
)}
{showDeliveryState && (
<MetricCard
label="i18n:govoplan-notifications.failed"
value={summary?.failed ?? 0}
tone={summary?.failed ? "danger" : "good"}
detail="i18n:govoplan-notifications.delivery_failures"
/>
)}
</MetricGrid>
<div className="notifications-widget-actions">
{showCenterLink && (
<Link className="btn btn-secondary" to="/notifications">
i18n:govoplan-notifications.open_center
</Link>
)}
</div>
</LoadingFrame>
);
}