"use client"; /** * MobileWaterSuccessScreen — confirmation after a successful submit. * * Visual structure: * - Centered success illustration: a green ring that draws on, * with a checkmark that draws on ~280ms later (the same staggered * reveal UIKit's success feedback uses). * - Headline: "Reading logged." * - Recap card: headgate name + measurement + unit + timestamp. * - Two large primary actions, stacked: * - "Log Another Entry" (green primary, refresh icon) * - "Back to Headgates" (white secondary with thin border) * - Subtle thank-you micro-copy at the bottom. * * The animations use the global `water-ring` + `water-draw` keyframes * from `src/app/globals.css`. */ import { useEffect, useState } from "react"; import { Grid, Refresh } from "./icons"; import { formatClockTime, formatLongTimestamp, formatMeasurement } from "./format"; type Props = { headgateName: string; measurement: number; unit: string; timestamp: Date; /** Name of the irrigator who logged the entry — shown in the recap * so the operator can confirm the reading is attributed to them. */ irrigatorName?: string; onLogAnother: () => void; onBackToHeadgates: () => void; }; export function MobileWaterSuccessScreen({ headgateName, measurement, unit, timestamp, irrigatorName, onLogAnother, onBackToHeadgates, }: Props) { // Reveal animation — staggered for ring → checkmark → content. const [ringDone, setRingDone] = useState(false); const [contentShown, setContentShown] = useState(false); useEffect(() => { const ringTimer = window.setTimeout(() => setRingDone(true), 380); const contentTimer = window.setTimeout(() => setContentShown(true), 480); return () => { window.clearTimeout(ringTimer); window.clearTimeout(contentTimer); }; }, []); return (
{/* Brand strip — same as PIN screen for visual continuity. */}
TUXEDO WATER LOG
{/* Success ring + checkmark */}
{/* Ring — circumference ~264px for r=42 */} {/* Checkmark — ~62px long */} {/* Soft glow behind the ring — sells the celebration. */}
{/* Headline */}

Reading logged

{/* Recap card */}
{headgateName} {formatClockTime(timestamp)}
{formatMeasurement(measurement)} {unit}
{formatLongTimestamp(timestamp)}
{irrigatorName ? (
{initials(irrigatorName)} Logged by {irrigatorName}
) : null}
{/* Action buttons */}

Thanks for keeping the records flowing.

); } export default MobileWaterSuccessScreen; /** * Two-letter initials for the avatar chip in the recap. * Mirrors the same helper used in the log form header so the avatar * stays consistent across the two screens. */ function initials(name: string): string { const parts = name.trim().split(/\s+/).filter(Boolean); if (parts.length === 0) return "?"; if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase(); return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase(); }