Agent Portal
Agent-facing views for managing clients and their home estimates — distinct from the public Home Estimate — How it works flow that end users see.
Agents (and admins) get their own screens: a list of their clients, a per-client estimates workspace, and — for admins — a screen to manage the agent roster itself.
Routes & entry
All routes live under src/app/(Estimates)/ and are wrapped in ClientSidePageTemplate
with loginRedirect + a roles allowlist (client-side role gate).
| Route | File | Roles |
|---|---|---|
/agent | agent/page.tsx → AgentClientsContent | agent, admin |
/agent/client/[clientId] | agent/client/[clientId]/page.tsx → AgentEstimatesContent | agent, admin |
/agent/client/[clientId]/estimate/[[...slugs]] | re-exports the public estimate/[[...slugs]]/page | agent, admin |
/admin/agents | admin/agents/page.tsx → AgentsPageContent | admin |
The per-client estimate route re-exports the standard estimate page, so agents author
estimates through the same estimate flow as public users — just under the /agent/… path.
An optional ?s=<signature> search param is threaded through for signed access.
Providers
Each screen mounts its own scoped provider (in src/providers/):
| Provider | Hook | Backing service (services/API/APIAgent) |
|---|---|---|
AgentClientsProvider | useAgentClients | fetchClients → GET /agent/client |
AgentEstimatesProvider | useAgentEstimates | fetchClient, updateEstimate, removeEstimate, sendEstimateEmail |
AgentsProvider (admin) | useAgents (data via useAgentsData) | fetchAgents, createAgent, updateAgent under /admin/agents |
AgentClientsProviderfetches the client list; it passesshowEstimates: falsewhen aclientIdis present (the detail view fetches estimates separately).AgentEstimatesProviderloads a single client — the client endpoint returns its estimates inline, so no separate estimate fetch — and exposes update/remove/send-email actions plusgetEstimateUrl(fromuseEstimateUrl).AgentsProvidermanages the agent roster. Its data are FollowUpBoss users (FubUser/FubUsersResponse) linked to a Repliers agent record; all mutations no-op unlessadminRole.
How it works
agentRolebranches the estimate flow.EstimateRouter(@pages/estimate) readsuseUser().agentRole; for the form route it rendersAgentLandingPageContentfor agents andClientLandingPageContentotherwise (route === 'result'showsResultPageContentfor both).EstimateProvider/EstimateStepsProvideralso useagentRoleto skip theconfirmationandcontactsteps — agents author estimates without OTP/login.- Client list.
/agentrenders “My Clients” viaAgentClientsGrid, driven byuseAgentClients. - Per-client estimates.
/agent/client/[clientId]rendersAgentEstimatesLayout(a clientProfile, anEstimatesListofEstimateCards, andEstimatesTopBar) plus anEstimateRemoveDialog, all fed byuseAgentEstimates. - Admin — agents management.
/admin/agentsrendersAgentsGrid(search + create/update rows) viauseAgents, syncing the CRM agent roster.
Gotchas & hints
- Where
agentRolecomes from —UserProvider. It is derived, not stored:agentRole = profile.role === 'agent' || profile.role === 'admin'. Admins therefore pass every agent gate; onlyadminRole(role === 'admin') reaches/admin/agents. See Authentication. - Role gating is client-side. The
rolesallowlist lives inClientSidePageTemplatewithloginRedirect; it is a UI gate, not a substitute for backend authorization. - Estimate flow reuse. The agent estimate route re-exports the public estimate page rather
than duplicating it — behaviour differences are driven entirely by
agentRoleinside the shared providers, so keep changes to the estimate flow role-aware.