From 3ac111e02143cd098bd690610bb3dc49e4e942c0 Mon Sep 17 00:00:00 2001 From: lorentz Date: Sun, 12 Jul 2026 07:51:23 -0400 Subject: [PATCH 1/3] feat(260712-ash): add PAX8 sync detail page - New app/admin/sync/pax8/page.tsx mirroring sentinelone/duo pattern - Polls GET /api/pax8/sync every 10s, shows companies/subscriptions/products stats - Sync Now button POSTs with triggeredBy, handles 403/409 via sonner toast, polls until complete --- app/admin/sync/pax8/page.tsx | 208 +++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 app/admin/sync/pax8/page.tsx diff --git a/app/admin/sync/pax8/page.tsx b/app/admin/sync/pax8/page.tsx new file mode 100644 index 0000000..36805bb --- /dev/null +++ b/app/admin/sync/pax8/page.tsx @@ -0,0 +1,208 @@ +'use client'; + +import { useState, useEffect, useCallback } from 'react'; +import Link from 'next/link'; +import { Button } from '@/components/ui/button'; +import { Badge } from '@/components/ui/badge'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { + ArrowLeft, RefreshCw, Play, CheckCircle2, XCircle, + Building2, Package, Boxes, +} from 'lucide-react'; +import { toast } from 'sonner'; +import { useUserTimezone } from '@/lib/hooks/use-user-timezone'; + +interface Pax8SyncHistoryEntry { + id: string; + sync_type: string; + status: string; + started_at: string; + completed_at: string | null; + records_added: number; + records_updated: number; + records_deleted: number; + error_message: string | null; + triggered_by: string; +} + +interface Pax8SyncData { + inProgress: boolean; + counts: { companies: number; subscriptions: number; products: number }; + history: Pax8SyncHistoryEntry[]; +} + +function fmtDate(d: string | null, tz: string) { + if (!d) return '—'; + return new Date(d).toLocaleString(undefined, { timeZone: tz }); +} + +function fmtDuration(started: string | null, completed: string | null) { + if (!started || !completed) return '—'; + const ms = new Date(completed).getTime() - new Date(started).getTime(); + if (!Number.isFinite(ms) || ms < 0) return '—'; + if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`; + return `${(ms / 60000).toFixed(1)}m`; +} + +function totalRecords(h: Pax8SyncHistoryEntry) { + return (h.records_added ?? 0) + (h.records_updated ?? 0) + (h.records_deleted ?? 0); +} + +export default function Pax8SyncPage() { + const tz = useUserTimezone(); + const [data, setData] = useState(null); + const [loading, setLoading] = useState(true); + const [syncing, setSyncing] = useState(false); + + const fetchData = useCallback(async () => { + try { + const res = await fetch('/api/pax8/sync'); + if (res.ok) setData(await res.json()); + } finally { + setLoading(false); + } + }, []); + + useEffect(() => { + fetchData(); + const interval = setInterval(fetchData, 10000); + return () => clearInterval(interval); + }, [fetchData]); + + const triggerSync = async () => { + setSyncing(true); + try { + const res = await fetch('/api/pax8/sync', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ triggeredBy: 'manual' }), + }); + if (!res.ok) { + const json = await res.json().catch(() => ({})); + toast.error(json.message || json.error || 'Failed to start PAX8 sync'); + setSyncing(false); + return; + } + toast.success('PAX8 sync started'); + const poll = setInterval(async () => { + const r = await fetch('/api/pax8/sync'); + if (r.ok) { + const d = await r.json(); + if (!d.inProgress) { + clearInterval(poll); + setSyncing(false); + fetchData(); + } + } + }, 5000); + } catch (e) { + console.error(e); + toast.error('Failed to start PAX8 sync'); + setSyncing(false); + } + }; + + const lastSync = data?.history?.[0]; + const counts = data?.counts ?? { companies: 0, subscriptions: 0, products: 0 }; + const inProgress = data?.inProgress ?? false; + + return ( +
+
+
+ + + +
+ PAX8 +
+

PAX8 Sync

+

Companies, subscriptions, and products synced to pax8_* tables

+
+
+
+ +
+ + {/* Stats */} +
+ {[ + { label: 'Companies', value: counts.companies, icon: Building2, color: 'text-blue-500' }, + { label: 'Subscriptions', value: counts.subscriptions, icon: Package, color: 'text-green-500' }, + { label: 'Products', value: counts.products, icon: Boxes, color: 'text-purple-500' }, + ].map(({ label, value, icon: Icon, color }) => ( + + + + {label} + + + +
+ {loading ? '—' : Number(value ?? 0).toLocaleString()} +
+
+
+ ))} +
+ + {/* Last sync status */} + {lastSync && ( + + + Last Sync + + +
+ {lastSync.status === 'completed' + ? + : lastSync.status === 'running' + ? + : } +
+
{lastSync.status}
+
+ {fmtDate(lastSync.completed_at || lastSync.started_at, tz)} · {fmtDuration(lastSync.started_at, lastSync.completed_at)} · {totalRecords(lastSync).toLocaleString()} records +
+
+
+ {lastSync.error_message && ( +
{lastSync.error_message}
+ )} +
+
+ )} + + {/* History */} + + Sync History + +
+ {(data?.history ?? []).map((h) => ( +
+
+ {h.status === 'completed' ? + : h.status === 'running' ? + : } + {fmtDate(h.started_at, tz)} +
+
+ {totalRecords(h).toLocaleString()} records + {fmtDuration(h.started_at, h.completed_at)} + {h.triggered_by} +
+
+ ))} + {!loading && (data?.history ?? []).length === 0 && ( +

No sync history yet — run a sync to get started

+ )} +
+
+
+
+ ); +} From 6ed6c668106610ea76e96d942b0a58faed608f61 Mon Sep 17 00:00:00 2001 From: lorentz Date: Sun, 12 Jul 2026 07:52:21 -0400 Subject: [PATCH 2/3] feat(260712-ash): add PAX8 card to sync overview page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Append PAX8 entry to INTEGRATIONS with logo, description, and detail link - Fetch /api/pax8/sync in fetchAll, wire pax8 branches in getSummary/getStatusIcon - Add PAX8 stats block (last sync, companies, subscriptions) to card render - Add public/logos/pax8.ico as placeholder (copied from itglue.ico — no network access available to fetch the real PAX8 favicon; replace with the real logo when convenient) --- app/admin/sync/page.tsx | 37 ++++++++++++++++++++++++++++++++++++- public/logos/pax8.ico | Bin 0 -> 621 bytes 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 public/logos/pax8.ico diff --git a/app/admin/sync/page.tsx b/app/admin/sync/page.tsx index 6cef917..d41545a 100644 --- a/app/admin/sync/page.tsx +++ b/app/admin/sync/page.tsx @@ -26,6 +26,7 @@ const INTEGRATIONS: IntegrationCard[] = [ { id: 'sentinelone', category: 'EDR/AV', product: 'SentinelOne', description: 'Endpoint agents, threat detections, site coverage, AV health', href: '/admin/sync/sentinelone', logo: '/logos/sentinelone.ico', color: 'purple' }, { id: 'mimecast', category: 'Email Security', product: 'Mimecast', description: 'Message tracking logs, threat events, SIEM data, 120-day retention', href: '/admin/sync/mimecast', logo: '/logos/mimecast.ico', color: 'blue' }, { id: 'duo', category: '2FA / MFA', product: 'Duo Security', description: 'Users, phones, auth logs, groups, integrations across all child accounts', href: '/admin/sync/duo', logo: '/logos/duo.ico', color: 'green' }, + { id: 'pax8', category: 'Licensing', product: 'PAX8', description: 'Companies, subscriptions, products, and license billing', href: '/admin/sync/pax8', logo: '/logos/pax8.ico', color: 'blue' }, ]; const COLOR_MAP: Record = { @@ -59,16 +60,18 @@ export default function SyncOverviewPage() { const [mimecastData, setMimecastData] = useState(null); const [duoData, setDuoData] = useState(null); + const [pax8Data, setPax8Data] = useState(null); const fetchAll = async () => { try { - const [intRes, atRes, itgRes, s1Res, mcRes, duoRes] = await Promise.all([ + const [intRes, atRes, itgRes, s1Res, mcRes, duoRes, pax8Res] = await Promise.all([ fetch('/api/integrations/status'), fetch('/api/sync/last-sync'), fetch('/api/itglue/sync'), fetch('/api/sentinelone/sync'), fetch('/api/mimecast/status'), fetch('/api/duo/status'), + fetch('/api/pax8/sync'), ]); if (intRes.ok) setStatus(await intRes.json()); if (atRes.ok) { @@ -79,6 +82,7 @@ export default function SyncOverviewPage() { if (s1Res.ok) setS1SyncData(await s1Res.json()); if (mcRes.ok) setMimecastData(await mcRes.json()); if (duoRes.ok) setDuoData(await duoRes.json()); + if (pax8Res.ok) setPax8Data(await pax8Res.json()); } catch (e) { console.error(e); } finally { @@ -180,6 +184,16 @@ export default function SyncOverviewPage() { bypass: c.bypass ?? 0, }; } + if (id === 'pax8') { + if (!pax8Data) return null; + const h = pax8Data.history?.[0]; + return { + lastSync: h?.completed_at ?? null, + status: h?.status ?? null, + companies: Number(pax8Data.counts?.companies ?? 0), + subscriptions: Number(pax8Data.counts?.subscriptions ?? 0), + }; + } return null; }; @@ -219,6 +233,11 @@ export default function SyncOverviewPage() { if ((summary as any).bypass > 0) return ; return ; } + if (id === 'pax8') { + if (!summary.lastSync) return ; + if (summary.status === 'failed') return ; + return ; + } return ; }; @@ -411,6 +430,22 @@ export default function SyncOverviewPage() { )} )} + {intg.id === 'pax8' && summary && ( + <> +
+ Last sync + {fmtDate(summary.lastSync)} +
+
+ Companies + {(summary as any).companies?.toLocaleString()} +
+
+ Subscriptions + {(summary as any).subscriptions?.toLocaleString()} +
+ + )} {(intg.id === 'auvik' || intg.id === 'addigy') && (
Status diff --git a/public/logos/pax8.ico b/public/logos/pax8.ico new file mode 100644 index 0000000000000000000000000000000000000000..70f4d8c803db532829a7f83254520d3d77ad040e GIT binary patch literal 621 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!bOU@sT-^(NfJ`F6+HG;mflB#G zg8YIRzC6v}*)sKlppvgy(u&}pQ-c{87$17NIEF;DE}edRTeAX>i(tT>1^@r=bYE!e z=fM&7=~>jvW1dC}rIKSL;@V1|@zj^N7^J=Z`L}S#KJguK2fs1030E;D>nF%rG0x4k zU`%U&E^v4A2L=TtvCleg3^O{`e_(TH)9l@T^N*|_d(U(ZozsVA%;u7~_W7dYE`LsM z=WDzhzEvHo?9pVN*~Gyh6I}SfVD_Yw)y)k{1l6nR6`FuXOnq`^Q&z*{S4Y@hnyEKl zwg+;S2=dPf5;EG$$8ofA{x$znK~@FRSL%YQ3Y`a-k56d}yI;y6JTbaIEI!oXQV099 zYm2Y4%Nk5&fA-ULwSO+dP2HVYqS0XtE-c%Z<}#mX+?kbedL{3HyGl2TvY9-t7QHS! z;3Tck;V``?w;{mPEq4b^->$3 z)=Xc@Brr{qZ^r&k(}oRaPVJR1Ww?Lh$){iX-l7gJ1<`SOGfNNjC{^U|E3cAO$Vu7u zy_rkl^J)EA=jX0t-0-zYce{!cvw+~8X^|~l0%k_1cExOZ!60%_-Rk~JtphGUwr@9z zY`o&iVv@4coI&jo_Xqy}Y3? Date: Sun, 12 Jul 2026 07:52:55 -0400 Subject: [PATCH 3/3] docs(260712-ash): add execution summary Co-Authored-By: Claude Sonnet 5 --- .../260712-ash-SUMMARY.md | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .planning/quick/260712-ash-add-pax8-to-the-admin-sync-overview-page/260712-ash-SUMMARY.md diff --git a/.planning/quick/260712-ash-add-pax8-to-the-admin-sync-overview-page/260712-ash-SUMMARY.md b/.planning/quick/260712-ash-add-pax8-to-the-admin-sync-overview-page/260712-ash-SUMMARY.md new file mode 100644 index 0000000..2962620 --- /dev/null +++ b/.planning/quick/260712-ash-add-pax8-to-the-admin-sync-overview-page/260712-ash-SUMMARY.md @@ -0,0 +1,117 @@ +--- +quick_task: 260712-ash +title: Add PAX8 to the admin sync overview page +one_liner: PAX8 sync detail page + overview card wired to existing /api/pax8/sync route +key_files: + created: + - app/admin/sync/pax8/page.tsx + - public/logos/pax8.ico + modified: + - app/admin/sync/page.tsx +completed: 2026-07-12 +--- + +# Quick Task 260712-ash: Add PAX8 to the admin sync overview page Summary + +PAX8 sync detail page + overview card wired to existing `/api/pax8/sync` route. + +## What was built + +1. **`app/admin/sync/pax8/page.tsx`** — new client detail page mirroring the + `sentinelone`/`duo` sibling pages: + - Polls `GET /api/pax8/sync` every 10s via `fetchData`/`useCallback`, uses + `useUserTimezone()` for date formatting. + - Header with back link to `/admin/sync`, `/logos/pax8.ico` logo, title + "PAX8 Sync", subtitle "Companies, subscriptions, and products synced to + pax8_* tables". + - Stat cards for Companies / Subscriptions / Products, sourced from + `data.counts`. + - Last-sync card showing status icon (completed/running/failed), formatted + timestamp, computed duration (`completed_at - started_at`, since the PAX8 + history rows have no `duration_ms`), and total records + (`records_added + records_updated + records_deleted`). Renders + `error_message` in a red box when present. + - Sync history list with the same per-row shape (status icon, date, total + records, duration, `triggered_by` badge) and an empty-state message. + - "Sync Now" button: `POST /api/pax8/sync` with + `{ triggeredBy: 'manual' }`. On non-ok response, reads the JSON body and + shows `toast.error(json.message || json.error)` — covers the 403 + (disabled) and 409 (already in progress) cases from the route. On success, + shows `toast.success('PAX8 sync started')` and polls `GET /api/pax8/sync` + every 5s until `inProgress` clears, then refetches. Button disabled while + `syncing` or `data.inProgress`. + +2. **`app/admin/sync/page.tsx`** — wired PAX8 into the existing per-integration + pattern: + - Appended a `pax8` entry to `INTEGRATIONS` (category "Licensing", href + `/admin/sync/pax8`, logo `/logos/pax8.ico`, color `blue`). + - Added `pax8Data` state and a `fetch('/api/pax8/sync')` call inside the + existing `Promise.all` in `fetchAll`. + - Added a `pax8` branch to `getSummary` returning `lastSync`, `status`, + `companies`, `subscriptions` (guarded on `pax8Data` being null). + - Added a `pax8` branch to `getStatusIcon` (no `lastSync` → muted clock; + `status === 'failed'` → red X; else green check). + - Added a card stats block for `intg.id === 'pax8'` showing Last sync / + Companies / Subscriptions rows, matching the existing itglue/duo markup. + +3. **`public/logos/pax8.ico`** — logo asset for the card/detail page. The + sandboxed executor environment has no outbound network access, so + `curl -fsSL https://www.pax8.com/favicon.ico` returned a 0-byte file. Per + the plan's fallback instruction, copied `public/logos/itglue.ico` as a + placeholder so the card never shows a broken image. **This is a known + placeholder — swap in the real PAX8 favicon when there's network access.** + +## Verification + +- `npx tsc --noEmit --pretty` — clean, no errors, after both tasks. +- Task 1 automated check: file exists, contains `'/api/pax8/sync'` and + `triggeredBy`. +- Task 2 automated check: `public/logos/pax8.ico` is non-empty, `page.tsx` + contains `id: 'pax8'`, `fetch('/api/pax8/sync')`, and `setPax8Data`. + +## Deviations from Plan + +### Auto-fixed / expected fallback + +**1. [Plan-specified fallback] PAX8 logo could not be fetched from the network** +- **Found during:** Task 2 +- **Issue:** The plan instructed fetching `https://www.pax8.com/favicon.ico` + via curl, with an explicit fallback to copy an existing logo if the fetch + fails or returns empty. The executor sandbox has no outbound network access, + so the curl returned a 0-byte file. +- **Fix:** Followed the plan's documented fallback exactly — copied + `public/logos/itglue.ico` to `public/logos/pax8.ico` as a placeholder. +- **Files modified:** `public/logos/pax8.ico` +- **Commit:** `6ed6c66` +- **Follow-up needed:** Replace with the real PAX8 favicon/logo when network + access or a manually-downloaded asset is available. Not a stub in the + functional sense (the card and detail page work correctly) — purely a + cosmetic placeholder. + +No other deviations. Both tasks executed exactly as specified. + +## Known Stubs + +- `public/logos/pax8.ico` is a placeholder (copy of `itglue.ico`), not the + real PAX8 logo. Functionally harmless — the image renders, just not the + correct brand mark. Should be replaced with the actual PAX8 favicon in a + follow-up task once network access is available. + +## Threat Flags + +None. This plan only reads from an existing, already-authenticated admin route +(`/api/pax8/sync`, itself protected by the existing admin page layout/auth) and +adds no new endpoints, auth paths, or schema changes. + +## Commits + +- `3ac111e` — feat(260712-ash): add PAX8 sync detail page +- `6ed6c66` — feat(260712-ash): add PAX8 card to sync overview page + +## Self-Check: PASSED + +- FOUND: `app/admin/sync/pax8/page.tsx` +- FOUND: `public/logos/pax8.ico` +- FOUND: `app/admin/sync/page.tsx` (modified, PAX8 branches present) +- FOUND commit `3ac111e` in `git log --oneline` +- FOUND commit `6ed6c66` in `git log --oneline`