diff --git a/components/icons.tsx b/components/icons.tsx
index ad71d8099..d5797ce64 100644
--- a/components/icons.tsx
+++ b/components/icons.tsx
@@ -62,6 +62,7 @@ export { QuoteIcon, QuoteIcon as Quote } from "@solar-icons/react/bold-duotone/q
export { Dialog2Icon as LanguagesIcon, Dialog2Icon as Languages } from "@solar-icons/react/bold-duotone/dialog-2";
export { Chart2Icon as AnalyticsIcon, Chart2Icon as BarChart3 } from "@solar-icons/react/bold-duotone/chart-2";
export { LinkIcon, LinkIcon as Link2 } from "@solar-icons/react/bold-duotone/link";
+export { VideocameraIcon as Video } from "@solar-icons/react/bold-duotone/videocamera";
export { Plane2Icon as PublishIcon, Plane2Icon as Send } from "@solar-icons/react/bold-duotone/plane-2";
export { TrashBinTrashIcon as TrashIcon, TrashBinTrashIcon as Trash2 } from "@solar-icons/react/bold-duotone/trash-bin-trash";
export { Book2Icon as BookIcon, Book2Icon as BookOpen } from "@solar-icons/react/bold-duotone/book-2";
diff --git a/components/icons/meeting-icons.tsx b/components/icons/meeting-icons.tsx
new file mode 100644
index 000000000..a5fea2a80
--- /dev/null
+++ b/components/icons/meeting-icons.tsx
@@ -0,0 +1,49 @@
+// The services a meeting link can be on, by its address: their own marks, and a camera for any other.
+
+import { Video } from "@/components/icons";
+
+export type MeetingService = "zoom" | "meet" | "teams" | "other";
+
+/** Which service a meeting link is on. */
+export function serviceOf(url: string): MeetingService {
+ let host = "";
+ try {
+ host = new URL(url).hostname.toLowerCase();
+ } catch {
+ return "other";
+ }
+ if (host === "zoom.us" || host.endsWith(".zoom.us") || host.endsWith(".zoomgov.com")) return "zoom";
+ if (host === "meet.google.com") return "meet";
+ if (host === "teams.microsoft.com" || host === "teams.live.com" || host.endsWith(".teams.microsoft.com")) return "teams";
+ return "other";
+}
+
+/** Whether a link is a sign-up page rather than the call: Zoom's registration for a meeting or a webinar. */
+export const isSignUp = (url: string) => serviceOf(url) === "zoom" && /\/(meeting|webinar)\/register\//.test(url);
+
+/** Zoom's app mark: its camera, white on its blue. */
+function ZoomMark({ className }: { className?: string }) {
+ return (
+
+ );
+}
+
+/** Google Meet's mark (Simple Icons). */
+function MeetMark({ className }: { className?: string }) {
+ return (
+
+ );
+}
+
+/** The mark for a meeting link's service. Teams has no mark it lets others draw, so it takes the camera. */
+export function MeetingMark({ url, className }: { url: string; className?: string }) {
+ const service = serviceOf(url);
+ if (service === "zoom") return ;
+ if (service === "meet") return ;
+ return ;
+}
diff --git a/components/reports/intake-notice.tsx b/components/reports/intake-notice.tsx
index 05a29569c..4275fcfaf 100644
--- a/components/reports/intake-notice.tsx
+++ b/components/reports/intake-notice.tsx
@@ -5,11 +5,13 @@
import { createContext, useContext, useSyncExternalStore } from "react";
import { useFormatter, useTranslations } from "next-intl";
-import { Ban, CalendarClock, FileText, Hourglass } from "@/components/icons";
+import { ArrowUpRight, Ban, CalendarClock, Clock3, FileText, Hourglass } from "@/components/icons";
+import { MeetingMark, serviceOf, type MeetingService } from "@/components/icons/meeting-icons";
import { ListEmpty } from "@/components/evidence-libraries/list-controls";
import { StatusChip } from "@/components/evidence-libraries/configuration/status-chip";
import { Button } from "@/components/ui/button";
-import type { IntakeState } from "@/lib/reports/intake";
+import { TooltipHint } from "@/components/ui/tooltip";
+import { hoursAt, type IntakeState, type Meeting } from "@/lib/reports/intake";
import { cn } from "@/lib/utils";
type Closed = Exclude;
@@ -33,18 +35,34 @@ export const IntakeOpen = createContext({ open: true });
export const IntakeShut = createContext(null);
export const useShutNext = () => useContext(IntakeShut);
+/** The call authors can join while new reports are open, if the admin gave one. */
+export const IntakeMeeting = createContext(null);
+
/** The timezone the admin set new reports' dates and calendar periods in (Settings > Admin > Publications). */
export const IntakeClock = createContext("UTC");
+// A zone named by its offset ("GMT", "GMT+1"): every reader knows it, where "WET" or "CAT" leaves most guessing.
+// next-intl types only the older names; Intl takes it as it is.
+const OFFSET = "shortOffset" as "short";
+
+// The reader's own timezone, from their browser. None on the server, where the admin's stands in until the page is here.
+const noSubscribe = () => () => {};
+const browserZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
+
+/** The timezone times are shown in on the Publish page: the reader's own, or the admin's before the browser says. */
+function useReaderZone(given?: string) {
+ const read = useContext(IntakeClock);
+ return useSyncExternalStore(noSubscribe, browserZone, () => null) ?? given ?? read;
+}
+
/**
- * A date on that clock, with its name: the time the admin set, the same for every author wherever they are. Left to
- * itself the formatter reads the server's clock, and says nothing of it.
+ * A date in the reader's own time, with the zone's name, so it reads right wherever they are. Left to itself the
+ * formatter reads the server's clock, and says nothing of it.
*/
const useWhen = (given?: string) => {
const format = useFormatter();
- const read = useContext(IntakeClock);
- const timeZone = given ?? read;
- return (at: number) => format.dateTime(at, { weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit", timeZone, timeZoneName: "short" });
+ const timeZone = useReaderZone(given);
+ return (at: number) => format.dateTime(at, { weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit", timeZone, timeZoneName: OFFSET });
};
/** Why a new report can't start or a draft go on now, in a few words for beside the button; null while they can. `given` and `timeZone` are for the page that provides them. */
@@ -56,6 +74,7 @@ export function useIntakeShut(given?: IntakeState, timeZone?: string): string |
if (state.open) return null;
if (state.why === "off") return t("off");
if (state.why === "notYet") return t("notYet", { date: when(state.at) });
+ if (state.why === "between") return t("between", { date: when(state.at) });
if (state.why === "full" && state.reopensAt !== null) return t("next", { date: when(state.reopensAt) });
return t("over");
}
@@ -64,6 +83,22 @@ export function useIntakeShut(given?: IntakeState, timeZone?: string): string |
function useIntakeWords(state: Closed) {
const t = useTranslations("publishReports.flow.intake");
const when = useWhen();
+ const format = useFormatter();
+ const admin = useContext(IntakeClock);
+ const timeZone = useReaderZone();
+ if (state.why === "between") {
+ const time = (at: number, zone: boolean) => format.dateTime(at, { hour: "2-digit", minute: "2-digit", timeZone, timeZoneName: zone ? OFFSET : undefined });
+ // The hours as they fall next, on the admin's clock: their true end across a clock change, and the reader's
+ // weekdays from the days they really fall on, which hours near midnight can move.
+ const to = hoursAt(state.hours, state.at, admin)?.end ?? state.at;
+ const weekday = (at: number) => ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].indexOf(new Intl.DateTimeFormat("en-US", { weekday: "short", timeZone }).format(at));
+ const starts: number[] = [];
+ for (let next = hoursAt(state.hours, state.at, admin); next && starts.length < state.hours.days.length; next = hoursAt(state.hours, next.end, admin)) starts.push(next.start);
+ starts.sort((a, b) => weekday(a) - weekday(b));
+ const days = starts.map((at) => format.dateTime(at, { weekday: "long", timeZone }));
+ const words = { from: time(state.at, false), to: time(to, true), days: format.list(days) };
+ return { icon: Clock3, title: t("between.title"), body: t(days.length === 7 ? "between.everyDay" : "between.someDays", words), chip: t("opens", { date: when(state.at) }) };
+ }
if (state.why === "off") return { icon: Ban, title: t("off.title"), body: t("off.body"), chip: null };
if (state.why === "notYet") return { icon: CalendarClock, title: t("notYet.title"), body: t("notYet.body"), chip: t("opens", { date: when(state.at) }) };
if (state.why === "ended") return { icon: Hourglass, title: t("over.title"), body: t("ended.body"), chip: t("closed", { date: when(state.at) }) };
@@ -80,7 +115,7 @@ export function IntakeNotice({ className }: { className?: string }) {
function ClosedNotice({ state, className }: { state: Closed; className?: string }) {
const { icon: Icon, title, body, chip } = useIntakeWords(state);
return (
-
+ );
+}
+
+/** The way into the call, while new reports wait for their hours or their opening: there, and shut until then. */
+function WaitingJoin({ state }: { state: Closed }) {
+ const t = useTranslations("publishReports.flow.intake.meeting");
+ const meeting = useContext(IntakeMeeting);
+ const when = useWhen();
+ if (!meeting) return null;
+ // A sign-up page is open whenever there is a session still to come: signing up before it is the point.
+ if (meeting.kind === "register") return state.why === "between" || state.why === "notYet" || (state.why === "full" && state.reopensAt !== null) ? : null;
+ if (state.why !== "between" && state.why !== "notYet") return null;
+ return (
+
+
+
+
+
+ );
+}
+
+/** A service's name for a button, where it has one: people know where the button takes them. */
+const SERVICE_NAME: Partial> = { zoom: "Zoom", meet: "Google Meet", teams: "Teams" };
+
+/** The way to a sign-up page, named for its service. */
+function SignUp({ meeting, variant }: { meeting: Meeting; variant?: "outline" }) {
+ const t = useTranslations("publishReports.flow.intake.meeting");
+ const name = SERVICE_NAME[serviceOf(meeting.url)];
+ return (
+
+ );
+}
+
+/** While new reports are open, the session the admin gave: what it is, until when or how to get in, and the way there. */
+export function MeetingBar({ className }: { className?: string }) {
+ const t = useTranslations("publishReports.flow.intake.meeting");
+ const state = useContext(IntakeOpen);
+ const meeting = useContext(IntakeMeeting);
+ const format = useFormatter();
+ const timeZone = useReaderZone();
+ if (!meeting || !state.open) return null;
+ const service = serviceOf(meeting.url);
+ const until = state.until == null ? null : format.dateTime(state.until, { hour: "2-digit", minute: "2-digit", timeZone, timeZoneName: OFFSET });
+ return (
+ // The mark sits at the title's top, as far from the box's top as from its side: 12px both ways.
+
+
+ {/* Zoom's mark is a tile of its own; the others get one the same size. */}
+ {service === "zoom" ? (
+
+ ) : (
+
+
+
+ )}
+
+ {meeting.name || t(`service.${service}`)}
+
+ {meeting.kind === "register" ? (SERVICE_NAME[service] ? t("emailed", { service: SERVICE_NAME[service] }) : t("emailedAny")) : until ? t("onUntil", { time: until }) : t("on")}
+
+
+
+ {meeting.kind === "register" ? (
+
+ ) : (
+
+ )}
+ );
+}
+
+/** Each day between the dates, two weeks at most: whether it opens, and how far through its hours now is. */
+function Days({ hours, start, end, now, timeZone }: { hours: Hours; start: number; end: number; now: number; timeZone: string }) {
+ const t = useTranslations("publishReports.settings.intake.hours");
+ const format = useFormatter();
+ const days = drawnDays(hours, start, end, timeZone);
+ if (!days) return null;
+ const sessions = days.filter((day) => day.open);
+ const left = sessions.filter((day) => day.end > now).length;
+ const time = (at: number, zone = false) => format.dateTime(at, { hour: "2-digit", minute: "2-digit", timeZone, timeZoneName: zone ? "short" : undefined });
+ return (
+
+ {/* A week a row at most, and no day narrower than its words: two weeks take two rows, a phone four days a row. */}
+
+ {days.map((day) => {
+ const live = day.open && now >= day.start && now < day.end;
+ const done = day.open && now >= day.end;
+ return (
+
+ {format.dateTime(day.day, { weekday: "short", timeZone })}
+ {format.dateTime(day.day, { day: "numeric", timeZone })}
+ {/* Where the day stands: over, on now, when it opens, or not a day it opens. */}
+
+ {done ? : null}
+ {!day.open ? t("dayClosed") : done ? t("dayDone") : live ? t("dayLive") : time(day.start)}
+
+
+ ) : null}
+ >
+ );
+}
diff --git a/components/reports/publish-flow.tsx b/components/reports/publish-flow.tsx
index a70360080..73a06dfc6 100644
--- a/components/reports/publish-flow.tsx
+++ b/components/reports/publish-flow.tsx
@@ -43,7 +43,7 @@ import { AutoHeight } from "@/components/ui/auto-height";
import { SaveControl } from "@/components/library/save-control";
import { Button } from "@/components/ui/button";
import { NextButton } from "@/components/reports/next-button";
-import { IntakeClock, IntakeClosedPage, IntakeNotice, IntakeOpen, IntakeShut, useIntakeShut, useNow } from "@/components/reports/intake-notice";
+import { IntakeClock, IntakeClosedPage, IntakeMeeting, IntakeNotice, IntakeOpen, IntakeShut, MeetingBar, useIntakeShut, useNow } from "@/components/reports/intake-notice";
import { intakeAt, type IntakeState } from "@/lib/reports/intake";
import { FieldMessage, StepNav, useStepForm } from "@/components/reports/form";
import { Checkbox } from "@/components/ui/checkbox";
@@ -457,6 +457,7 @@ export function PublishFlow() {
const clock = useNow();
const intake: IntakeState = basics ? intakeAt(basics.intake, basics.nths, clock) : { open: true };
const intakeShut = useIntakeShut(intake, basics?.intake.timezone);
+ const meeting = basics?.open ? (basics.intake.meeting ?? null) : null;
const signedOut = isLoaded && !isSignedIn;
// A link to a report or to the list is its workspace's to open: signing in comes back to it.
if (signedOut && (view === "reports" || (asked !== null && asked !== "new"))) return ;
@@ -529,6 +530,7 @@ export function PublishFlow() {
return (
+ {basics.open && waits ?
: null}
+ {/* The admin's call, while new reports are open: help at hand on every step. Opens by height as the hours start. */}
+ {intake.open && meeting && report?.status !== "live" ?