import { raw } from "hono/html"; import type { Child } from "hono/jsx"; import type { AgendaDay, AgendaItem } from "./agenda.js"; import { formatDayHeading, formatTime, LOCALES, type Locale, type MessageKey, t } from "./i18n.js"; import { styles } from "./styles.js"; type LayoutProps = { locale: Locale; showExamples: boolean; children?: Child }; function Layout({ locale, showExamples, children }: LayoutProps) { return ( {t(locale, "app.name")}
{t(locale, "app.name")}
{showExamples && (

{t(locale, "mock.banner")}

)}
{children}
); } export const NOTICES = ["denied", "failed", "setup", "browser", "consent"] as const; export type Notice = (typeof NOTICES)[number]; /** Календарь не подключён: что это, что сделать и что будет дальше. */ export function ConnectPage(props: { locale: Locale; isMock: boolean; notice?: Notice | null; /** Подключение не удалось уже не в первый раз: подсказка другая. */ repeated?: boolean; /** Образец списка (у мока): показывается под кнопкой и помечен как образец. */ sample?: { days: AgendaDay[]; timeZone: string } | null; }) { const { locale, notice } = props; return (

{t(locale, "connect.title")}

{t(locale, "connect.lead")}

{t(locale, "connect.steps")}

{t(locale, "connect.readonly")}

{notice && ( )} {notice && props.repeated && notice === "setup" ? ( {t(locale, "reconnect.anyway")} ) : ( {t(locale, notice ? "reconnect.button" : "connect.button")} )}
{props.sample && (

{t(locale, "sample.title")}

{t(locale, "sample.lead")}

)}
); } /** Сообщение из двух фраз и одно действие. */ export function MessagePage(props: { locale: Locale; isMock: boolean; title: MessageKey; message: MessageKey; action: { href: string; label: MessageKey }; }) { const { locale } = props; return (

{t(locale, props.title)}

{t(locale, props.message)}

{t(locale, props.action.label)}
); } function Item({ item, locale, timeZone }: { item: AgendaItem; locale: Locale; timeZone: string }) { const when = item.kind === "timed" && item.start ? formatTime(locale, item.start, timeZone) : t(locale, item.kind === "ongoing" ? "agenda.ongoing" : "agenda.allDay"); return (
  • {when} {item.title ?? t(locale, "agenda.untitled")}
  • ); } function DayList({ days, locale, timeZone, }: { days: AgendaDay[]; locale: Locale; timeZone: string; }) { return ( <> {days.map((day) => (

    {formatDayHeading(locale, day.key, day.offset)}

    ))} ); } /** Календарь подключён: список на 7 дней или сообщение о пустой неделе. Только просмотр. */ export function AgendaPage(props: { locale: Locale; isMock: boolean; days: AgendaDay[]; timeZone: string; }) { const { locale, days, timeZone } = props; return ( 0}>

    {t(locale, "agenda.title")}

    {t(locale, "agenda.connected")}

    {t(locale, "agenda.lead")}

    {days.length === 0 ? (
    {t(locale, "agenda.empty")} {t(locale, "agenda.emptyHint")}
    ) : ( )}
    ); }