From 0d57c267ca3f2f33ccbc3d5a9bd432fee89ca216 Mon Sep 17 00:00:00 2001 From: Thomas Joise Date: Mon, 13 Jul 2026 16:55:45 +0530 Subject: [PATCH] feat(hq-web): reminder email preview in the manual queue Co-Authored-By: Claude Fable 5 --- apps/hq-web/src/pages/Dashboard.tsx | 35 ++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/apps/hq-web/src/pages/Dashboard.tsx b/apps/hq-web/src/pages/Dashboard.tsx index 0488d87..9d38396 100644 --- a/apps/hq-web/src/pages/Dashboard.tsx +++ b/apps/hq-web/src/pages/Dashboard.tsx @@ -2,7 +2,7 @@ import { useState, type ReactNode } from 'react' import { useNavigate } from 'react-router-dom' import { formatINR } from '@sims/domain' import { Badge, Button, DataTable, EmptyState, Notice, PageHeader, StatCard, Stats } from '@sims/ui' -import { getDashboard, sendReminder, dismissReminder, type Reminder } from '../api' +import { getDashboard, sendReminder, dismissReminder, getReminderPreview, type Reminder } from '../api' import { useData } from './Clients' const inr = (p: number) => formatINR(p) @@ -105,20 +105,43 @@ function Section(props: { function QueueActions(props: { rem: Reminder & { docNo: string | null }; onDone: () => void; onError: (m: string) => void }) { const [busy, setBusy] = useState(false) + const [mail, setMail] = useState<{ subject: string; body: string } | undefined>() + const [loading, setLoading] = useState(false) const run = (p: Promise) => { setBusy(true); props.onError('') p.catch((e: Error) => props.onError(e.message)) // Reload even on failure: the server has already parked the reminder as - // 'failed' with its error, and the row must flip live (Task 12 walk §3.2). + // 'failed' with its error, and the row must flip live. .then(props.onDone) .finally(() => setBusy(false)) } + const preview = () => { + if (mail !== undefined) { setMail(undefined); return } // toggle closed + setLoading(true); props.onError('') + getReminderPreview(props.rem.id) + .then(setMail) + .catch((e: Error) => props.onError(e.message)) + .finally(() => setLoading(false)) + } return ( -
- {SENDABLE.has(props.rem.ruleKind) && ( - +
+
+ {SENDABLE.has(props.rem.ruleKind) && ( + <> + + + + )} + +
+ {mail !== undefined && ( +
+
Subject
+
{mail.subject}
+
Body
+
{mail.body}
+
)} -
) }