From 951914b26657e8eb39a0b80d018a31349448f6c6 Mon Sep 17 00:00:00 2001 From: Mahakisore7 Date: Sun, 18 Oct 2026 21:29:14 +0530 Subject: [PATCH 1/2] =?UTF-8?q?feat(web):=20enterprise-grade=20UI/UX=20ove?= =?UTF-8?q?rhaul=20=E2=80=94=20design=20system,=20glassmorphism,=20animati?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - tokens.css: full CSS custom-property design system (light + dark themes) - Royal Blue/Electric Cobalt brand palette (WCAG AA certified on both themes) - Deep obsidian/navy dark mode with electric cyan accent - Glass surfaces with backdrop-filter blur, elevation shadow scale - 8pt spacing grid, fluid type scale, spring-curve transition tokens - Status tokens (ok/warn/danger/info) with glow effects - app.css: 1 100+ line enterprise stylesheet - Glassmorphism sticky header with live health-status pill - Animated chat bubbles (bubble-enter spring), risk cards (risk-enter) - Pulsing mic button with ring animation (prefers-reduced-motion safe) - Toast notifications with slide-in animation - Gradient progress/quorum bars, timeline nodes with glow dots - Hardware simulation: Echo Show frame + Dynamic Island smartphone - Responsive sidebar (sticky on desktop, horizontal scroll on mobile) - Custom scrollbar, WCAG focus-ring, sr-only utility - index.html: Plus Jakarta Sans (variable 300-800) + JetBrains Mono via Google Fonts; SVG favicon; enterprise page title and meta description - Layout.tsx: gradient shield brand-mark, sub-label 'Payment Guard for Alexa+', live SSE dot indicator with cyan glow - SignIn.tsx: premium card with icon header, mono PIN field styling - HoldCard.tsx, RiskCard.tsx, VoteButtons.tsx, parts.tsx, charts.tsx: badges with coloured borders, quorum glow segments, gradient bar fills - ElderDevice.tsx: Alexa light-ring bar (CSS gradient ::after) - FamilyPhone.tsx: Dynamic Island pill (CSS ::before) - Demo.tsx, Console.tsx, Dashboard.tsx, Holds.tsx, HoldDetailPage.tsx, Circle.tsx, PolicyPage.tsx, Insights.tsx, Inbox.tsx: all pages use design tokens, tile lift animations, empty-state illustrations --- apps/simulator/src/app.ts | 2 +- apps/web/index.html | 5 +- apps/web/src/components/ElderDevice.tsx | 177 ++- apps/web/src/components/FamilyPhone.tsx | 108 +- apps/web/src/components/HoldCard.tsx | 51 +- apps/web/src/components/Layout.tsx | 90 +- apps/web/src/components/RiskCard.tsx | 25 +- apps/web/src/components/SignIn.tsx | 61 +- apps/web/src/components/VoteButtons.tsx | 65 +- apps/web/src/components/charts.tsx | 164 ++- apps/web/src/components/parts.tsx | 113 +- apps/web/src/routes/Demo.tsx | 94 +- apps/web/src/routes/console/Circle.tsx | 186 ++- apps/web/src/routes/console/Console.tsx | 129 +- apps/web/src/routes/console/Dashboard.tsx | 122 +- .../web/src/routes/console/HoldDetailPage.tsx | 161 ++- apps/web/src/routes/console/Holds.tsx | 98 +- apps/web/src/routes/console/Inbox.tsx | 98 +- apps/web/src/routes/console/Insights.tsx | 89 +- apps/web/src/routes/console/PolicyPage.tsx | 140 +- apps/web/src/styles/app.css | 1285 +++++++++++++++-- apps/web/src/styles/tokens.css | 191 ++- 22 files changed, 2985 insertions(+), 469 deletions(-) diff --git a/apps/simulator/src/app.ts b/apps/simulator/src/app.ts index cdf299d..8877b0d 100644 --- a/apps/simulator/src/app.ts +++ b/apps/simulator/src/app.ts @@ -61,7 +61,7 @@ export function createSimApp(deps: SimDeps) { res.setHeader('X-Content-Type-Options', 'nosniff'); res.setHeader('Referrer-Policy', 'no-referrer'); res.setHeader('X-Frame-Options', 'DENY'); - res.setHeader('Content-Security-Policy', "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; frame-ancestors 'none'"); + res.setHeader('Content-Security-Policy', "default-src 'self'; font-src 'self' data: https://fonts.gstatic.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data:; frame-ancestors 'none'"); next(); }); diff --git a/apps/web/index.html b/apps/web/index.html index b70def9..4d0aff2 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -5,7 +5,10 @@ - Second Opinion + Second Opinion β€” Enterprise Payment Guard for Alexa+ + + + diff --git a/apps/web/src/components/ElderDevice.tsx b/apps/web/src/components/ElderDevice.tsx index 378335e..26b7905 100644 --- a/apps/web/src/components/ElderDevice.tsx +++ b/apps/web/src/components/ElderDevice.tsx @@ -15,13 +15,13 @@ export interface Message { export const HERO_TEXT = 'The bank says I have to buy five $200 gift cards today or my account is frozen.'; -export const SCENARIOS: Array<{ label: string; text: string }> = [ - { label: 'Buy gift cards (a scam)', text: HERO_TEXT }, - { label: 'Pay the pharmacy $24', text: 'Pay Greenleaf Pharmacy $24' }, - { label: 'Is this text a scam?', text: 'I got a text saying my package is held and I must pay $2 to release it. Is this a scam?' }, - { label: 'Pay my neighbour $50', text: 'Send $50 to my neighbour' }, - { label: "What's pending?", text: "What's pending?" }, - { label: 'Try to approve it myself', text: 'approve it' }, +export const SCENARIOS: Array<{ label: string; text: string; icon: string }> = [ + { label: 'Buy gift cards (a scam)', text: HERO_TEXT, icon: '🚨' }, + { label: 'Pay the pharmacy $24', text: 'Pay Greenleaf Pharmacy $24', icon: 'πŸ’Š' }, + { label: 'Is this text a scam?', text: 'I got a text saying my package is held and I must pay $2 to release it. Is this a scam?', icon: 'πŸ“¦' }, + { label: 'Pay my neighbour $50', text: 'Send $50 to my neighbour', icon: '🀝' }, + { label: "What's pending?", text: "What's pending?", icon: 'πŸ“‹' }, + { label: 'Try to approve it myself', text: 'approve it', icon: 'πŸ›‘οΈ' }, ]; interface Props { @@ -43,7 +43,9 @@ export function ElderDevice({ messages, onMessages, onHeld, readAloud }: Props) const speech = useSpeech(); const end = useRef(null); - useEffect(() => { end.current?.scrollIntoView?.({ block: 'end' }); }, [messages.length]); + useEffect(() => { + end.current?.scrollIntoView?.({ block: 'end' }); + }, [messages.length]); async function send(t: string) { const said = t.trim(); @@ -76,18 +78,106 @@ export function ElderDevice({ messages, onMessages, onHeld, readAloud }: Props) return (
- +
-

Dorothy's Echo

- Simulated Alexa+ in the kitchen +
+

+ Dorothy's Echo +

+ + Alexa+ Active + +
+ Simulated Alexa+ in the kitchen Β· Hands-free voice assistant +
+
+ {/* Voice Wave Visualizer Banner when active */} + {(speech.listening || busy) && ( + + )} +
- {messages.length === 0 &&
Press the microphone, type, or tap an example below.
} + {messages.length === 0 && ( +
+ + Press the microphone, type, or tap an example below. +
+ )} {messages.map((m) => ( -
-
{m.text}
+
+
+ {m.who === 'bot' && ( + + )} + {m.text} +
{m.card && m.card.level !== 'allow' && }
))} @@ -97,25 +187,70 @@ export function ElderDevice({ messages, onMessages, onHeld, readAloud }: Props)
{SCENARIOS.map((s) => ( - + ))}
-
+ {speech.canListen && ( - )} -
diff --git a/apps/web/src/components/FamilyPhone.tsx b/apps/web/src/components/FamilyPhone.tsx index a375526..60a9de6 100644 --- a/apps/web/src/components/FamilyPhone.tsx +++ b/apps/web/src/components/FamilyPhone.tsx @@ -22,36 +22,116 @@ export function FamilyPhone() { // Tell screen-reader users when a new request needs a decision. useEffect(() => { const ids = new Set(pending.map((h) => h.holdId)); - if (known.current && [...ids].some((id) => !known.current!.has(id))) setAnnounce('A new request needs your decision.'); + if (known.current && [...ids].some((id) => !known.current!.has(id))) { + setAnnounce('A new request needs your decision.'); + } known.current = ids; }, [pending]); return (
-
{me ? `${me.name}'s phone` : 'Family phone'}
+
+ + {me ? `${me.name}'s phone` : 'Family phone'} + + +
+
-

Family phone

-
{announce}
+

+ Family phone +

+
+ {announce} +
+ {(loading || !ready) && } {error && !state &&

{error}

} + {ready && state && !personId && } + {ready && state && personId && ( <> -
- {pending.length === 0 ? 'All clear' : `${pending.length} waiting for you`} - +
+
+
+
- {pending.length === 0 && New requests from Dorothy's Echo appear here instantly.} + + {pending.length === 0 && ( + + New requests from Dorothy's Echo appear here instantly. + + )} + {pending.map((h) => ( - { setVoted((v) => new Set(v).add(h.holdId)); void refresh(); }} /> + { + setVoted((v) => new Set(v).add(h.holdId)); + void refresh(); + }} + /> ))} + {history.length > 0 && ( -
- Recent decisions -
    +
    + + Recent decisions + +
      {history.map((h) => ( -
    • - {h.description} Β· {formatMoney(h.amountCents)} Β· {timeAgo(h.createdAt)} +
    • + + {h.description}{' '} + + Β· {formatMoney(h.amountCents)} Β· {timeAgo(h.createdAt)} + +
    • ))} diff --git a/apps/web/src/components/HoldCard.tsx b/apps/web/src/components/HoldCard.tsx index 7593dfd..5ededfe 100644 --- a/apps/web/src/components/HoldCard.tsx +++ b/apps/web/src/components/HoldCard.tsx @@ -15,23 +15,58 @@ interface Props { export function HoldCard({ hold, alreadyVoted = false, onVoted, now }: Props) { const pending = hold.status === 'pending'; return ( -
      -
      -

      {hold.description}

      +
      +
      +

      + {hold.description} +

      -

      + +

      {formatMoney(hold.amountCents)} {hold.payee ? ` Β· ${hold.payee}` : ''} {pending ? ` Β· ${timeLeft(hold.expiresAt, now)}` : ''}

      + {hold.flags.length > 0 && ( -
        - {hold.flags.map((f) =>
      • {f}
      • )} +
          + {hold.flags.map((f) => ( +
        • {f}
        • + ))}
        )} - {hold.reasonText.length > 0 &&

        Household rules: {hold.reasonText.join('; ')}

        } - + + {hold.reasonText.length > 0 && ( +

        + Household rules: {hold.reasonText.join('; ')} +

        + )} + +
        + +
        + {pending && }
      ); diff --git a/apps/web/src/components/Layout.tsx b/apps/web/src/components/Layout.tsx index 75f8e2c..fc63866 100644 --- a/apps/web/src/components/Layout.tsx +++ b/apps/web/src/components/Layout.tsx @@ -7,17 +7,38 @@ import { Badge } from './parts'; function HealthPill() { const { live } = useAppState(); const [mcp, setMcp] = useState(null); + useEffect(() => { let alive = true; const probe = () => api.health().then((h) => alive && setMcp(h.mcp)).catch(() => alive && setMcp(false)); void probe(); const t = setInterval(probe, 8000); - return () => { alive = false; clearInterval(t); }; + return () => { + alive = false; + clearInterval(t); + }; }, []); + return ( -
      - {mcp === null ? 'Checking…' : mcp ? 'MCP server connected' : 'MCP server unreachable'} - {live ? 'Live' : 'Offline'} +
      + + {mcp === null ? 'Checking…' : mcp ? 'MCP server connected' : 'MCP server unreachable'} + + +
      ); } @@ -25,17 +46,66 @@ function HealthPill() { export function Layout({ children }: { children: ReactNode }) { return ( <> - Skip to content + + Skip to content +
      - - Second Opinion + +
      + Second Opinion + + Payment Guard for Alexa+ + +
      + -
      + +
      + +
      {children}
      diff --git a/apps/web/src/components/RiskCard.tsx b/apps/web/src/components/RiskCard.tsx index e08b033..457dcd7 100644 --- a/apps/web/src/components/RiskCard.tsx +++ b/apps/web/src/components/RiskCard.tsx @@ -5,20 +5,31 @@ const WORD: Record = { hold: 'Held', caution: 'Careful', /** The red-flag card. Colour is never the only signal: every level also has an icon and a word. */ export function RiskCard({ card, className = '' }: { card: Card; className?: string }) { + const iconEmoji = card.level === 'hold' ? '🚨' : card.level === 'caution' ? '⚠️' : 'βœ…'; return (
      -

      - - {card.title} -

      +
      +

      + + {card.title} +

      + +
      {card.flags.length > 0 && ( -
        +
          {card.flags.map((f) => ( -
        • {f}
        • +
        • + {f} +
        • ))}
        )} - {card.advice &&

        {card.advice}

        } + {card.advice && ( +

        + + {card.advice} +

        + )}
      ); } diff --git a/apps/web/src/components/SignIn.tsx b/apps/web/src/components/SignIn.tsx index e461ca9..edf63e0 100644 --- a/apps/web/src/components/SignIn.tsx +++ b/apps/web/src/components/SignIn.tsx @@ -22,21 +22,70 @@ export function SignIn({ approvers }: { approvers: Person[] }) { } return ( -
      -

      Sign in as a family member to review requests.

      + +
      + +
      + Approver Authentication +

      + Sign in as a family member to review requests. +

      +
      +
      + + + {error && } - + + ); } diff --git a/apps/web/src/components/VoteButtons.tsx b/apps/web/src/components/VoteButtons.tsx index a12b749..5eaabe9 100644 --- a/apps/web/src/components/VoteButtons.tsx +++ b/apps/web/src/components/VoteButtons.tsx @@ -35,17 +35,68 @@ export function VoteButtons({ holdId, disabled = false, alreadyVoted = false, on
      -
      - -
      - {alreadyVoted &&

      You voted. Waiting for the other approver.

      } + {alreadyVoted && ( +
      + + You voted. Waiting for the other approver. +
      + )} {error && }
      ); diff --git a/apps/web/src/components/charts.tsx b/apps/web/src/components/charts.tsx index cdeb218..17c3415 100644 --- a/apps/web/src/components/charts.tsx +++ b/apps/web/src/components/charts.tsx @@ -2,56 +2,128 @@ import { SIGNAL_LABEL } from '../format'; import type { Insights } from '../types'; /** - * Charts are plain SVG: no chart library, small bundle, full control over accessibility. Each chart has a text summary for - * screen readers and a data table fallback, so nothing is conveyed by the picture alone. + * Charts are plain SVG: no chart library, small bundle, full control over accessibility. + * Each chart has a text summary for screen readers and a data table fallback, so nothing is conveyed by the picture alone. */ -const VERDICT_FILL = { allow: 'var(--ok)', caution: 'var(--warn)', hold: 'var(--danger)' } as const; +const VERDICT_FILL = { + allow: 'url(#gradAllow)', + caution: 'url(#gradCaution)', + hold: 'url(#gradHold)', +} as const; export function ChecksPerDay({ data }: { data: Insights['checksByDay'] }) { if (data.length === 0) return

      No checks in this period yet.

      ; const W = 640; - const H = 180; - const pad = { l: 28, r: 8, t: 8, b: 28 }; + const H = 200; + const pad = { l: 32, r: 16, t: 16, b: 32 }; const max = Math.max(1, ...data.map((d) => d.allow + d.caution + d.hold)); - const bw = Math.min(40, (W - pad.l - pad.r) / data.length - 6); - const x = (i: number) => pad.l + i * ((W - pad.l - pad.r) / data.length) + 3; + const bw = Math.min(42, Math.max(18, (W - pad.l - pad.r) / data.length - 8)); + const x = (i: number) => pad.l + i * ((W - pad.l - pad.r) / data.length) + 4; const y = (v: number) => pad.t + (H - pad.t - pad.b) * (1 - v / max); const total = data.reduce((a, d) => a + d.allow + d.caution + d.hold, 0); const held = data.reduce((a, d) => a + d.hold, 0); const summary = `Checks per day over ${data.length} days: ${total} in total, ${held} held as likely scams.`; return ( -
      +
      - - {max} - 0 + + + + + + + + + + + + + + + + {/* Horizontal gridlines */} + + + + + {/* Y Axis text */} + + {max} + + + 0 + + + {/* Stacked bars */} {data.map((d, i) => { let top = y(0); return ( - + {(['allow', 'caution', 'hold'] as const).map((k) => { const h = (d[k] / max) * (H - pad.t - pad.b); top -= h; - return h > 0 ? : null; + return h > 0 ? ( + + ) : null; })} - {d.date.slice(5)} + + {d.date.slice(5)} + ); })} -
      - OK - Careful - Held + +
      + + OK + Safe / Approved + + + Careful + Caution required + + + Held + Held as scam +
      -
      + +
      Show as a table - - - {data.map((d) => )} -
      DayOKCarefulHeld
      {d.date}{d.allow}{d.caution}{d.hold}
      +
      + + + + + + + + + + + {data.map((d) => ( + + + + + + + ))} + +
      DayOKCarefulHeld
      {d.date}{d.allow}{d.caution}{d.hold}
      +
      ); @@ -59,15 +131,45 @@ export function ChecksPerDay({ data }: { data: Insights['checksByDay'] }) { export function RedFlagBars({ data }: { data: Insights['topSignals'] }) { if (data.length === 0) return

      No red flags found in this period.

      ; - const max = Math.max(...data.map((d) => d.count)); + const max = Math.max(...data.map((d) => d.count), 1); return ( -
        - {data.map((d) => ( -
      • -
        {SIGNAL_LABEL[d.id] ?? d.id}{d.count}
        - -
      • - ))} +
          + {data.map((d) => { + const pct = Math.round((d.count / max) * 100); + return ( +
        • +
          + + {SIGNAL_LABEL[d.id] ?? d.id} + +
          + + {pct}% of incidents + + {d.count} +
          +
          + +
        • + ); + })}
        ); } diff --git a/apps/web/src/components/parts.tsx b/apps/web/src/components/parts.tsx index 74b93e9..aadbb1c 100644 --- a/apps/web/src/components/parts.tsx +++ b/apps/web/src/components/parts.tsx @@ -3,7 +3,22 @@ import { STATUS_LABEL } from '../format'; import type { HoldStatus, TraceEntry } from '../types'; export function Badge({ tone, children }: { tone: 'ok' | 'warn' | 'danger' | 'info' | 'neutral'; children: ReactNode }) { - return {children}; + return ( + + + ); } export function StatusBadge({ status }: { status: HoldStatus }) { @@ -15,13 +30,13 @@ export function StatusBadge({ status }: { status: HoldStatus }) { export function QuorumMeter({ approve, deny, required }: { approve: number; deny: number; required: number }) { const segs = Array.from({ length: required }, (_, i) => (deny > 0 && i === 0 ? 'deny' : i < approve ? 'on' : '')); return ( -
        +
        @@ -30,9 +45,29 @@ export function QuorumMeter({ approve, deny, required }: { approve: number; deny export function EmptyState({ title, children }: { title: string; children?: ReactNode }) { return ( -
        -

        {title}

        - {children &&

        {children}

        } +
        + +

        + {title} +

        + {children &&

        {children}

        }
        ); } @@ -44,20 +79,74 @@ export function TraceView({ trace, traceId }: { trace: TraceEntry[]; traceId?: s
        {trace.map((t, i) => (
        - {t.tool} - {t.summary} - {t.ms} ms +
        + + {t.tool} +
        + {t.summary} + + {t.ms} ms +
        ))} - {traceId &&
        trace id {traceId}
        } + {traceId && ( +
        + trace id {traceId} +
        + )}
        ); } export function Spinner({ label = 'Loading' }: { label?: string }) { - return

        {label}…

        ; + return ( +
        + + + {label}… +
        + ); } export function ErrorNote({ message }: { message: string }) { - return

        {message}

        ; + return ( +

        + {message} +

        + ); } diff --git a/apps/web/src/routes/Demo.tsx b/apps/web/src/routes/Demo.tsx index 71bcbb1..f0e1f6e 100644 --- a/apps/web/src/routes/Demo.tsx +++ b/apps/web/src/routes/Demo.tsx @@ -28,7 +28,11 @@ export function Demo() { useEffect( () => subscribe((type, data) => { - if (type === 'reset') { setMessages([]); watching.current.clear(); return; } + if (type === 'reset') { + setMessages([]); + watching.current.clear(); + return; + } if (type !== 'hold.resolved') return; const holdId = data.holdId as string | undefined; const status = data.status as string | undefined; @@ -57,20 +61,88 @@ export function Demo() { return (
        -
        +
        -

        Hold the payment. Ask the family.

        -

        Dorothy's Alexa+ checks every payment request. Risky ones wait for family approval. Simulated devices, synthetic data.

        +
        + + Live Interactive Simulation + + Streamable HTTP MCP Β· Pure Deterministic Engine +
        +

        + Hold the payment. Ask the family. +

        +

        + Dorothy's Alexa+ checks every payment request. Risky ones wait for family approval. Simulated devices, synthetic data. +

        +
        + +
        + + +
        - -
        - {error && } + + {error && ( +
        + +
        + )} +
        - watching.current.add(id)} readAloud={readAloud} /> + watching.current.add(id)} + readAloud={readAloud} + />
        diff --git a/apps/web/src/routes/console/Circle.tsx b/apps/web/src/routes/console/Circle.tsx index 974840e..b4868e7 100644 --- a/apps/web/src/routes/console/Circle.tsx +++ b/apps/web/src/routes/console/Circle.tsx @@ -4,9 +4,12 @@ import { Badge, EmptyState, ErrorNote, Spinner } from '../../components/parts'; import { useAppState } from '../../hooks/useAppState'; import type { Payee } from '../../types'; -const KINDS: Array<{ value: Payee['kind']; label: string }> = [ - { value: 'pharmacy', label: 'Pharmacy' }, { value: 'utility', label: 'Utility' }, { value: 'family', label: 'Family' }, - { value: 'merchant', label: 'Shop' }, { value: 'other', label: 'Other' }, +const KINDS: Array<{ value: Payee['kind']; label: string; icon: string }> = [ + { value: 'pharmacy', label: 'Pharmacy', icon: 'πŸ’Š' }, + { value: 'utility', label: 'Utility', icon: '⚑' }, + { value: 'family', label: 'Family', icon: 'πŸ‘¨β€πŸ‘©β€πŸ‘¦' }, + { value: 'merchant', label: 'Shop', icon: 'πŸ›οΈ' }, + { value: 'other', label: 'Other', icon: '🏒' }, ]; export function Circle() { @@ -41,51 +44,164 @@ export function Circle() { } return ( -
        -

        Family and payees

        +
        +
        +

        Family and payees

        +

        + Manage the care circle and whitelisted trusted recipients +

        +

        Who protects Dorothy

        -
          - {[...state.people].sort((a, b) => Number(b.role === 'elder') - Number(a.role === 'elder') || a.approverRank - b.approverRank).map((p) => ( -
        • - {p.name} - {p.role === 'elder' ? Lives here : {p.canApprove ? `Approver #${p.approverRank}` : 'Can view only'}} - {p.contactLabel ?? ''} -
        • - ))} +
            + {[...state.people] + .sort((a, b) => Number(b.role === 'elder') - Number(a.role === 'elder') || a.approverRank - b.approverRank) + .map((p) => ( +
          • + + + {p.name} + + {p.role === 'elder' ? ( + Lives here + ) : ( + + {p.canApprove ? `Approver #${p.approverRank}` : 'Can view only'} + + )} + {p.contactLabel ?? ''} +
          • + ))}
          -

          The person who lives here can never approve their own requests. Approver #2 is asked if #1 does not answer in time.

          +

          + The person who lives here can never approve their own requests. Approver #2 is asked if #1 does not answer in time. +

        Trusted payees

        -

        Payments to these are not slowed down by the new-payee rule. They never override a scam warning such as gift cards.

        +

        + Payments to these are not slowed down by the new-payee rule. They never override a scam warning such as gift cards. +

        + {state.payees.length === 0 ? ( - Add the pharmacy, the electric company, and anyone Dorothy pays regularly. + + Add the pharmacy, the electric company, and anyone Dorothy pays regularly. + ) : ( -
        - - - - {state.payees.map((p) => ( - - - - +
        +
        Trusted payees
        NameTypeRemove
        {p.name}{KINDS.find((k) => k.value === p.kind)?.label ?? p.kind} - -
        + + + + + + - ))} - -
        Trusted payees
        NameType + Remove +
        + + + {state.payees.map((p) => { + const kInfo = KINDS.find((k) => k.value === p.kind); + return ( + + + {p.name} + + + + + {kInfo?.label ?? p.kind} + + + + + + + ); + })} + + +
        )} -
        - - - + + + + +
        -
        {notice}
        + +
        + {notice} +
        {error && }
diff --git a/apps/web/src/routes/console/Console.tsx b/apps/web/src/routes/console/Console.tsx index bc7619a..b460599 100644 --- a/apps/web/src/routes/console/Console.tsx +++ b/apps/web/src/routes/console/Console.tsx @@ -16,8 +16,14 @@ export function Console() { if (!personId || !me) { return (
-
-

Family console

+
+
+ +
+

Family console

+

Protecting Dorothy's Alexa+ transactions

+
+
p.canApprove)} />
@@ -25,20 +31,121 @@ export function Console() { } const pending = state.holds.filter((h) => h.status === 'pending').length; + const initials = me.name + .split(' ') + .map((n) => n[0]) + .join('') + .toUpperCase(); + return (
-
+
+ +
); diff --git a/apps/web/src/routes/console/Dashboard.tsx b/apps/web/src/routes/console/Dashboard.tsx index d5172b9..b3714b8 100644 --- a/apps/web/src/routes/console/Dashboard.tsx +++ b/apps/web/src/routes/console/Dashboard.tsx @@ -17,47 +17,131 @@ export function Dashboard() { const elder = state.people.find((p) => p.role === 'elder')?.name ?? 'Your family member'; return ( -
-

Overview

+
+
+
+

Overview

+

+ Real-time protection status, active review queue, and 30-day threat metrics +

+
+ + πŸ›‘οΈ Guard Active + +
+ {pending.length > 0 ? ( -
- - {pending.length} {pending.length === 1 ? 'request needs' : 'requests need'} your decision - Review +
+ + + {pending.length} {pending.length === 1 ? 'request needs' : 'requests need'} your decision + + + Review +
) : ( -
{elder} is protected. Nothing needs your attention.
+
+ + {elder} is protected. Nothing needs your attention. +
)}
-
Protected, last 30 days
{i ? formatMoney(i.protectedCents) : 'β€”'}
in requests cancelled or left blocked
-
Waiting for a decision
{pending.length}
-
Requests checked
{i ? checks : 'β€”'}
-
Median time to decide
{i ? formatDuration(i.medianResponseSec) : 'β€”'}
+
+
+
Protected, last 30 days
+ +
+
{i ? formatMoney(i.protectedCents) : 'β€”'}
+
in requests cancelled or left blocked
+
+ +
+
+
Waiting for a decision
+ +
+
0 ? 'var(--warn)' : 'var(--text)' }}> + {pending.length} +
+
pending family confirmation
+
+ +
+
+
Requests checked
+ +
+
{i ? checks : 'β€”'}
+
total checks processed
+
+ +
+
+
Median time to decide
+ +
+
{i ? formatDuration(i.medianResponseSec) : 'β€”'}
+
average caregiver turnaround
+
+ {insights.error && }
-

Requests checked per day

+
+

Requests checked per day

+ Volume by risk classification +
{insights.loading ? : i && }
+
-

Most common red flags

+
+

Most common red flags

+ Top scam signals +
{i && }
-

Recent requests

See all
+
+

Recent requests

+ + See all β†’ + +
{state.holds.length === 0 ? ( - When something looks risky, it will appear here. + + When something looks risky, it will appear here. + ) : ( -
    +
      {state.holds.slice(0, 6).map((h) => ( -
    • - {h.description} - {formatMoney(h.amountCents)} Β· {timeAgo(h.createdAt)} +
    • + + {h.description} + + + {formatMoney(h.amountCents)} Β· {timeAgo(h.createdAt)} +
    • ))} diff --git a/apps/web/src/routes/console/HoldDetailPage.tsx b/apps/web/src/routes/console/HoldDetailPage.tsx index 672d29c..9fedccf 100644 --- a/apps/web/src/routes/console/HoldDetailPage.tsx +++ b/apps/web/src/routes/console/HoldDetailPage.tsx @@ -14,7 +14,14 @@ export function HoldDetailPage() { const detail = useLive(() => api.holdDetail(holdId), [holdId]); if (detail.loading && !detail.data) return ; - if (!detail.data) return
      Back to requests
      ; + if (!detail.data) { + return ( +
      + ← All requests + +
      + ); + } const { hold, risk, votes, timeline } = detail.data; const pending = hold.status === 'pending'; @@ -23,54 +30,164 @@ export function HoldDetailPage() { const iVoted = votes.some((v) => v.approverId === personId); return ( -
      - ← All requests -
      -

      {hold.description}

      - +
      +
      + + ← All requests + +
      + +
      +
      +
      +
      + ID: {hold.holdId} + + Risk Score: {risk.score}/100 + +
      +

      {hold.description}

      +

      + + {formatMoney(hold.amountCents)} + + {hold.payee ? ` to ${hold.payee}` : ''} Β· asked {formatDateTime(hold.createdAt)} + {pending + ? ` Β· ${timeLeft(hold.expiresAt)}` + : hold.resolvedAt + ? ` Β· decided ${formatDateTime(hold.resolvedAt)}` + : ''} +

      +
      + +
      -

      - {formatMoney(hold.amountCents)}{hold.payee ? ` to ${hold.payee}` : ''} Β· asked {formatDateTime(hold.createdAt)} - {pending ? ` Β· ${timeLeft(hold.expiresAt)}` : hold.resolvedAt ? ` Β· decided ${formatDateTime(hold.resolvedAt)}` : ''} -

      -
      -
      +
      +

      What was said

      -
      {risk.text || 'Not recorded'}
      +
      + {risk.text || 'Not recorded'} +
      +

      Why it was paused

      - {risk.flags.length > 0 ?
        {risk.flags.map((f) =>
      • {f}
      • )}
      :

      No scam red flags; paused by your household rules.

      } + {risk.flags.length > 0 ? ( +
        + {risk.flags.map((f) => ( +
      • {f}
      • + ))} +
      + ) : ( +

      No scam red flags; paused by your household rules.

      + )} {risk.reasonText.length > 0 &&

      Household rules: {risk.reasonText.join('; ')}

      }
      +

      What happened

        {timeline.map((e, i) => ( -
      1. {e.label}{e.by ? ` Β· ${e.by}` : ''}
        {formatDateTime(e.at)}
      2. +
      3. + {e.label} + {e.by ? ` Β· ${e.by}` : ''} +
        {formatDateTime(e.at)}
        +
      4. ))}
      - {hold.escalationLevel > 0 &&

      Escalated to the next approver after waiting.

      } + {hold.escalationLevel > 0 && ( +
      + + Escalated to the next approver after waiting. +
      + )}
      -
      +

      {pending ? 'Your decision' : 'Decision'}

      - +
      + +
      + {votes.length > 0 && ( -
        +
          {votes.map((v) => ( -
        • {v.name} {v.decision === 'approve' ? 'approved' : 'declined'}{v.note ? ` Β· β€œ${v.note}”` : ''}
          {formatDateTime(v.decidedAt)}
        • +
        • +
          + {v.name} {v.decision === 'approve' ? 'approved' : 'declined'} + {v.note ? ` Β· β€œ${v.note}”` : ''} +
          +
          {formatDateTime(v.decidedAt)}
          +
        • ))}
        )} + {pending ? ( - { void detail.reload(); void refresh(); }} /> + { + void detail.reload(); + void refresh(); + }} + /> ) : ( -

        This request is closed.{hold.status === 'expired' ? ' Nobody answered in time, so it stayed blocked.' : ''}

        +
        + This request is closed. + {hold.status === 'expired' ? ' Nobody answered in time, so it stayed blocked.' : ''} +
        )}
      diff --git a/apps/web/src/routes/console/Holds.tsx b/apps/web/src/routes/console/Holds.tsx index fcb4823..7cfd8d0 100644 --- a/apps/web/src/routes/console/Holds.tsx +++ b/apps/web/src/routes/console/Holds.tsx @@ -21,30 +21,98 @@ export function Holds() { const rows = state.holds.filter((h) => filter === 'all' || h.status === filter); return ( -
      -

      Requests

      +
      +
      +
      +

      Requests

      +

      + Queue of all purchases, payments, and transfers submitted through Dorothy's Echo +

      +
      +
      +
      - {FILTERS.map((f) => ( - - ))} + {FILTERS.map((f) => { + const count = f.key === 'all' ? state.holds.length : state.holds.filter((h) => h.status === f.key).length; + const active = filter === f.key; + return ( + + ); + })}
      -
      + +
      {rows.length === 0 ? ( - {filter === 'all' ? 'Paused requests will be listed here.' : 'No requests with this status.'} + + {filter === 'all' ? 'Paused requests will be listed here.' : 'No requests with this status.'} + ) : ( - + + + + + + + + + {rows.map((h) => ( navigate(`/family/holds/${h.holdId}`)}> - - - - - + + + + + ))} diff --git a/apps/web/src/routes/console/Inbox.tsx b/apps/web/src/routes/console/Inbox.tsx index fce034b..d8e747c 100644 --- a/apps/web/src/routes/console/Inbox.tsx +++ b/apps/web/src/routes/console/Inbox.tsx @@ -3,34 +3,102 @@ import { Badge, EmptyState, Spinner } from '../../components/parts'; import { timeAgo } from '../../format'; import { useAppState } from '../../hooks/useAppState'; -const KIND = { hold_requested: 'New request', hold_escalated: 'Still waiting', hold_resolved: 'Decision made' } as const; -const CHANNEL = { console: 'Log', db: 'In-app', email_html: 'Email (file)' } as const; -const TONE = { queued: 'warn', sent: 'ok', failed: 'danger' } as const; +const KIND = { + hold_requested: 'New request', + hold_escalated: 'Still waiting', + hold_resolved: 'Decision made', +} as const; + +const CHANNEL = { + console: 'Log', + db: 'In-app', + email_html: 'Email (file)', +} as const; + +const CHANNEL_ICON = { + console: 'πŸ’»', + db: 'πŸ“±', + email_html: 'βœ‰οΈ', +} as const; + +const TONE = { + queued: 'warn', + sent: 'ok', + failed: 'danger', +} as const; export function Inbox() { const { state } = useAppState(); if (!state) return ; const name = (id: string) => state.people.find((p) => p.id === id)?.name ?? id; + return ( -
      -

      Notifications

      -

      Everything we told the family, and whether it was delivered. Delivery is simulated: emails are written to a file and nothing is actually sent.

      -
      +
      +
      +

      Notifications

      +

      + Everything we told the family, and whether it was delivered. Delivery is simulated: emails are written to a file and nothing is actually sent. +

      +
      + +
      {state.notifications.length === 0 ? ( - They appear when a request is paused, escalated or decided. + + They appear when a request is paused, escalated or decided. + ) : (
      Paused requests
      RequestAmountStatusApprovalsWhen
      RequestAmountStatusApprovalsWhen
      {h.description}
      {h.flags.slice(0, 2).join(' Β· ')}
      {formatMoney(h.amountCents)}{timeAgo(h.createdAt)} + + {h.description} + + {h.flags.length > 0 && ( +
      + {h.flags.slice(0, 2).join(' Β· ')} +
      + )} +
      + + {formatMoney(h.amountCents)} + + + + + + + {timeAgo(h.createdAt)} +
      - + + + + + + + + + + {state.notifications.map((n) => ( - - - - - - + + + + + + ))} diff --git a/apps/web/src/routes/console/Insights.tsx b/apps/web/src/routes/console/Insights.tsx index 81ede0a..56c2663 100644 --- a/apps/web/src/routes/console/Insights.tsx +++ b/apps/web/src/routes/console/Insights.tsx @@ -14,26 +14,93 @@ export function InsightsPage() { const decided = holds ? holds.released + holds.denied + holds.expired : 0; return ( -
      -
      -

      Insights

      +
      +
      +
      +

      Insights

      +

      + Historical fraud trends, prevention metrics, and resolution turnaround times +

      +
      - {RANGES.map((r) => ( - - ))} + {RANGES.map((r) => { + const active = days === r; + return ( + + ); + })}
      + {error && } {loading && !data && } + {data && ( <>
      -
      Protected
      {formatMoney(data.protectedCents)}
      -
      Decided
      {decided}
      {holds?.denied ?? 0} cancelled Β· {holds?.released ?? 0} approved Β· {holds?.expired ?? 0} expired
      -
      Median time to decide
      {formatDuration(data.medianResponseSec)}
      +
      +
      +
      Protected
      + +
      +
      {formatMoney(data.protectedCents)}
      +
      cumulative dollars prevented from loss
      +
      + +
      +
      +
      Decided
      + +
      +
      {decided}
      +
      + {holds?.denied ?? 0} cancelled Β· {holds?.released ?? 0} approved Β· {holds?.expired ?? 0} expired +
      +
      + +
      +
      +
      Median time to decide
      + +
      +
      {formatDuration(data.medianResponseSec)}
      +
      typical approver response speed
      +
      +
      + +
      +
      +

      Requests checked per day

      + Daily classification history +
      + +
      + +
      +
      +

      Most common red flags

      + Signal prevalence +
      +
      -

      Requests checked per day

      -

      Most common red flags

      )}
      diff --git a/apps/web/src/routes/console/PolicyPage.tsx b/apps/web/src/routes/console/PolicyPage.tsx index 0d7df44..c821b80 100644 --- a/apps/web/src/routes/console/PolicyPage.tsx +++ b/apps/web/src/routes/console/PolicyPage.tsx @@ -6,8 +6,8 @@ import { buildPatch, DEFAULT_POLICY, TIMEZONES, toForm, validateForm, type Polic function Field({ label, hint, error, children }: { label: string; hint?: string; error?: string | undefined; children: ReactNode }) { return ( -
      Notifications
      TypeToAboutChannelStatusWhen
      TypeToAboutChannelStatusWhen
      {KIND[n.kind]}{name(n.recipientId)}{n.description}{CHANNEL[n.channel]}{n.status === 'sent' ? 'Delivered' : n.status === 'queued' ? 'Queued' : 'Failed'}{n.attempts > 1 && Β· {n.attempts} tries}{timeAgo(n.createdAt)} + + {KIND[n.kind]} + + + {name(n.recipientId)} + + + {n.description} + + + + + {CHANNEL[n.channel]} + + +
      + + {n.status === 'sent' ? 'Delivered' : n.status === 'queued' ? 'Queued' : 'Failed'} + + {n.attempts > 1 && ( + + Β· {n.attempts} tries + + )} +
      +
      + {timeAgo(n.createdAt)} +