import { Link } from "react-router"; import { useTranslation } from "react-i18next"; import { FeatherArrowLeft, FeatherPin } from "@subframe/core"; import type { ChatPinnedMessagesVM } from "@hivegrid/view-models"; import { useLocaleFormatters } from "~/locale/format"; import { Alert } from "~/ui/components/Alert"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { ButtonGroup } from "~/ui/components/ButtonGroup"; import { Card } from "~/ui/components/Card"; import { EmptyState } from "~/ui/components/EmptyState"; import { LoadingIndicatorSkeleton } from "~/ui/components/LoadingIndicatorSkeleton"; import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell"; import { ChatMessageFeatureCard } from "./ChatMessageFeatureCard"; export function ChatPinnedMessagesPage({ vm, busyMessageId, errorKey, featureErrorKeys, actions, }: { readonly vm: ChatPinnedMessagesVM; readonly busyMessageId: string | null; readonly errorKey: string | null; readonly featureErrorKeys?: Readonly>; readonly actions: { readonly onBack: (href: string) => void; readonly onUnpin: (messageId: string) => void; readonly onRetryFeature?: (messageId: string) => void; readonly onRetry: () => void; }; }): React.JSX.Element { const { t } = useTranslation(); const formatters = useLocaleFormatters(); const data = vm.status === "ready" ? vm.data : null; return ( } title={data ? t("chat.pinned.title", { channel: data.channelTitle }) : t("chat.pinned.titleFallback")} actions={ } /> {vm.status === "loading" || vm.status === "idle" ? ( ) : vm.status === "error" ? ( {t("shared.retry")}} /> ) : !data || data.rows.length === 0 ? ( ) : ( {errorKey ? : null} {data.rows.map((row) => ( {t("chat.pinned.by", { user: row.pinnedByLabel })} {formatters.date(row.pinnedAtIso, { dateStyle: "medium", timeStyle: "short" })} {row.note ? {row.note} : null} undefined, onTogglePin: (messageId, pinned) => pinned || actions.onUnpin(messageId), onRetryFeature: actions.onRetryFeature, }} /> {t("chat.pinned.openMessage")} {row.canUnpin ? ( ) : null} ))} )} ); }