refactor(webui): centralize notification selection
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Bell, Check, ExternalLink, RefreshCw, Send, XCircle } from "lucide-react";
|
||||
import { AdminIconButton, Button, DismissibleAlert, SegmentedControl, StatusBadge, hasScope, type ApiSettings, type AuthInfo } from "@govoplan/core-webui";
|
||||
import { AdminIconButton, Button, DismissibleAlert, SegmentedControl, SelectionList, SelectionListItem, StatusBadge, hasScope, type ApiSettings, type AuthInfo } from "@govoplan/core-webui";
|
||||
import { deliverPendingNotifications, listNotifications, updateNotification, type NotificationMessage } from "../../api/notifications";
|
||||
import { safeNotificationActionUrl } from "../../security/actionUrl";
|
||||
|
||||
@@ -112,23 +112,27 @@ export default function NotificationCenterPage({ settings, auth }: { settings: A
|
||||
<div className="notifications-list">
|
||||
{loading ? <div className="notifications-note">Loading notifications</div> : null}
|
||||
{!loading && notifications.length === 0 ? <div className="notifications-note">No notifications in this view.</div> : null}
|
||||
{notifications.map((notification) => (
|
||||
<button
|
||||
key={notification.id}
|
||||
type="button"
|
||||
className={`notifications-list-item ${selected?.id === notification.id ? "is-selected" : ""} ${notification.read_at ? "is-read" : ""}`}
|
||||
onClick={() => setSelectedId(notification.id)}
|
||||
>
|
||||
<span className="notifications-list-heading">
|
||||
<strong>{notification.subject || notification.event_kind}</strong>
|
||||
<small>{formatStatus(notification.status)}</small>
|
||||
</span>
|
||||
<span className="notifications-list-meta">
|
||||
<span>{notification.source_module}</span>
|
||||
<span>{formatDate(notification.created_at)}</span>
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
{notifications.length > 0 ? (
|
||||
<SelectionList label="Notifications" className="notifications-selection-list">
|
||||
{notifications.map((notification) => (
|
||||
<SelectionListItem
|
||||
key={notification.id}
|
||||
selected={selected?.id === notification.id}
|
||||
className={`notifications-list-item ${notification.read_at ? "is-read" : ""}`}
|
||||
onClick={() => setSelectedId(notification.id)}
|
||||
>
|
||||
<span className="notifications-list-heading">
|
||||
<strong>{notification.subject || notification.event_kind}</strong>
|
||||
<small>{formatStatus(notification.status)}</small>
|
||||
</span>
|
||||
<span className="notifications-list-meta">
|
||||
<span>{notification.source_module}</span>
|
||||
<span>{formatDate(notification.created_at)}</span>
|
||||
</span>
|
||||
</SelectionListItem>
|
||||
))}
|
||||
</SelectionList>
|
||||
) : null}
|
||||
</div>
|
||||
</aside>
|
||||
<section className="notifications-workspace">
|
||||
|
||||
Reference in New Issue
Block a user