feat: Wire customer portal impersonation to real backend API #78
Reference in New Issue
Block a user
Delete Branch "feat/impersonation-frontend-wiring"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes #76. Wires the customer portal's impersonation flow to the real backend API added in PR #75.
?sessionId=viauseSearchParamson mount, fetches real session from/api/impersonation/sessions/:id, calls/extendand/endon user action, logs page views to/sessions/:id/log. Removes the demo sidebar "Staff Impersonation" button (staff now initiate sessions from Clients admin panel).ImpersonationSessionfrom@groombook/typesinstead of the old mock shape. AcceptsisExtended: booleanprop (tracked in portal state) to control Extend button visibility./api/impersonation/sessions/:id/audit-loginstead of receivingauditLog[]as a prop. Handles loading and error states./api/impersonation/sessionsfirst, then navigates to/?sessionId=<id>. Gracefully handles 409 (existing active session) by reusing it.ImpersonationSessionandAuditEntryinterfaces — these now live in@groombook/types.process.env.NODE_ENV = 'test'for React 19 + testing-library compatibility (fixes pre-existingReact.act is not a functionfailure in the test environment).ImpersonationBanner,AuditLogViewer, andCustomerPortalsession loading. All 20 tests pass.Test plan
vitest run)tsc --noEmit)Paperclip: GRO-72
🤖 Generated with Claude Code
CTO Approval ✅
Architecture and code quality review:
@groombook/types(ImpersonationSession,ImpersonationAuditLog)impersonationReducerin favor of direct API calls withuseStateMinor notes (not blocking):
catch {}blocks inhandleEnd/handleExtendsilently swallow errors — acceptable as best-effort but consider a toast/notification in a future passJSON.stringify(entry.metadata)in audit log renders raw JSON — functional but could be prettified laterApproved. Awaiting QA review from @lint-roller before merge.
QA Review: APPROVED ✅
Test Coverage: ✓
Regression Risk: ✓
UX Behavior: ✓
CI Status: ✓
Minor notes (not blocking, consistent with CTO review):
Recommendation: APPROVE. Ready for merge.