peppa/apps/web/components/LocalTime.tsx
Асель d3a54fc845 PEP-38: runners console — filter counters, search, limit resume time, details panel
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 16:40:27 +05:00

25 lines
1002 B
TypeScript

"use client";
import { useEffect, useRef } from "react";
/** HH:MM (with the date when not today) in the viewer's time zone; the server renders its own zone first. */
export function LocalTime({ iso }: { iso: string }) {
const d = new Date(iso);
const today = new Date().toDateString() === d.toDateString();
const time = d.toLocaleTimeString("ru-RU", { hour: "2-digit", minute: "2-digit" });
return (
<time dateTime={iso} suppressHydrationWarning>
{today ? time : `${d.toLocaleDateString("ru-RU", { day: "2-digit", month: "2-digit" })} ${time}`}
</time>
);
}
/** On narrow screens the side panel sits under the list: bring the chosen runner into view. */
export function ScrollIntoViewOnNarrow({ id }: { id: string | number }) {
const ref = useRef<HTMLSpanElement>(null);
useEffect(() => {
if (window.matchMedia("(max-width: 1279px)").matches) ref.current?.scrollIntoView({ block: "start" });
}, [id]);
return <span ref={ref} className="block scroll-mt-16" />;
}