# H2O Portal

- URL: https://danicalero.com/en/projects/h2o-portal
- markdown: https://danicalero.com/en/projects/h2o-portal.md
- Client: H2O Restoration
- Services: Web development
- Technologies: Next.js, React

A multi-territory enquiry portal that turns website forms into a tracked pipeline, from first message to completed job.

One inbox, one pipeline, for a franchise network. A multi-territory enquiry portal that turns website forms into a tracked pipeline, from first message to completed job.

All screenshots and videos show the super admin view and seeded demo data (about 617 enquiries over 14 months, four territories). The company brand, H2O Restoration, is shown with permission. No client data appears.

## Context and problem

H2O Restoration works as a franchise network. Customers send enquiries through several websites. Each territory handles its own follow-up.

Without a shared view, enquiries sit in separate inboxes. Quotes go cold. Nobody can say which territory is winning work or which job needs a call today.

- Image: The H2O portal dashboard. It shows money KPI cards, enquiry counts by status, a territory leaderboard and a Need attention list.

## My role

I built the whole product on my own: product and UI design, architecture, development and deployment. The client brought the problems they needed to solve. I turned each one into a feature, from the data model and permissions to the screens.

## Solution overview

The portal is one flow. A website form posts to an intake API. A spam filter scores the submission. The portal routes it to a territory by postcode. The enquiry enters a pipeline. The dashboard summarises the pipeline for each viewer.

Everything is scoped by the viewer's role and territories. A franchisee sees only their own patch. An admin sees all of it.

- Image: A dense enquiries table with a filters popover open. The popover lists status and territory options.

- Image: An enquiry detail page. A row of pipeline stage cards sits above key value cards and an activity feed of notes, edits and status changes.

## Key features

### 1. A dashboard that tells you what to do next

The money figures follow event dates, not cohorts. "Won this month" counts enquiries that moved to Won in that month, whenever they arrived. Trends compare the period so far with the same elapsed span of the previous period, so a half-finished month is not judged against a full one. Every KPI carries a help icon that says what it counts and what it is compared to.

Two leaderboards rank territories and forms. The need-attention list ranks open enquiries by reason. An expired quote scores highest, then an uncontacted enquiry that is overdue. A planned follow-up silences "gone quiet" warnings, but never deadline warnings. One territory filter re-scopes every widget on the page.

- Image: Screen recording of the dashboard. The period changes to Last 30 days and the figures update. A help tooltip explains a KPI. A tooltip on the territory leaderboard shows a status breakdown, and the leaderboard switches to forms. The page scrolls to the Need attention list, then a territory filter re-scopes the page.

### 2. Every enquiry in one place

Enquiries from every form and territory land in one list. Search covers the contact's name, email and phone and the message. Filters combine status, next action, form, territory and date. The money columns sort, so the biggest open quotes come first.

The same list is also a map and a board. The chosen view is saved per user in the database, so each person returns to the view they work in.

- Image: Screen recording of the enquiries table. A search word narrows the rows. A Quoted status filter is applied and the table is sorted by quoted value. The view switches to the map, where a cluster is zoomed until it splits into pins, a pin opens a popup card, and the map is dragged.

- Image: A zoomed-out map of England with enquiry clusters over Manchester, Leeds, Birmingham and Bristol. A legend explains the pipeline status colours.

### 3. A pipeline with rules

Enquiries move through New, Contacted, Quoted, Won, Lost and Completed. The kanban board and the detail page share one transition dialog. It asks for what that step needs: a quoted value for Quoted, a final price for Won, a reason for Lost. Each move can also set a follow-up date.

Dragging on the board only goes forward. A revert needs a reason, so it lives on the detail page. Money is stored in pence in the database and typed as such in code, so a pounds-versus-pence mix-up fails at compile time.

- Image: Screen recording of the kanban board. A card is dragged from the Contacted column to Quoted. A dialog asks for a quoted value and a follow-up date. After confirming, the card sits in the Quoted column.

- Image: Kanban board with New, Contacted, Quoted and Won columns; each card shows the contact, message, territory and date.

### 4. The whole story of a job

One enquiry holds its stage, its money, its next action and every note, edit and status change in one activity feed. It opens as a drawer over the list, so staff keep their place, filters and scroll.

The portal matches enquiries to contacts by email, then phone. The contact shows lifetime value, open pipeline, a relationship label (New, Active, Customer, Repeat customer, Lapsed) and every linked enquiry. The enquiry drawer can open the contact on top of it.

- Image: Screen recording of an enquiry drawer over the enquiries list. A note is added to the activity feed. The enquiry is marked as won with an edited final price. The contact drawer opens on top with an updated lifetime value, then the full contact page opens with its linked enquiries.

- Image: A contact detail page with KPI cards, a relationship badge, a list of linked enquiries and a notes timeline.

### 5. Every enquiry, any shape

Not every enquiry comes from a form. Staff add phone, WhatsApp and social media enquiries through a drawer. Typing a name suggests an existing contact, and picking one reuses it instead of creating a duplicate. The address prefills from the contact. The territory resolves from the postcode, and a scoped user can only create inside their own territories. The form asks only for what the chosen status needs: a quote value for Quoted, a sale value for Won, a reason for Lost.

Manual entries use the same intake path as web forms, so they get the same contact matching, history and live updates.

- Image: Screen recording of the Add Enquiry drawer. A search finds an existing contact and the address is prefilled from it. The territory line resolves from the postcode. Status Quoted adds a required quote value. After submitting, a toast appears and the new row is first in the table. The video then opens the Forms list, a form and its field mapping screen.

Web forms differ per site. A field-mapping screen lets an admin map any form's fields into one shared schema.

- Image: The form mapping screen. A list of website form fields is matched to portal enquiry fields.

### 6. Nothing gets lost

Public forms attract bots. Each submission gets a score from field-shape rules: fictional phone numbers, blocked email domains, template messages, non-UK postcodes and keyword lists. A score of 5 blocks. Some rules block alone, others need company.

Blocked submissions go to quarantine, not the bin. An admin sees the signals that fired and can release the submission, which turns it into a real enquiry. The bot sees an identical "accepted" response, so it cannot tell it was blocked.

Deleting an enquiry moves it to Trash, where an admin can recover it. Permanent deletion is a separate permission. Releases, recoveries, deletions, status changes, edits, notes and invitations all write to an audit log with the time, the user and the record.

- Image: Screen recording of the portal safety nets. A quarantined submission opens and shows its spam filter signals. It is released after a confirmation dialog. In Trash, a deleted enquiry is selected and recovered. The audit log then lists the recovery and the release as its newest rows, with time, user and event.

- Image: A quarantine detail page. A spam signals card lists the rules that fired for the blocked submission, next to the original payload.

## Deep dives

### Realtime

A new enquiry should appear without a refresh, and only for people allowed to see it. I used Ably with one channel per territory.

The first version used one channel per form. That broke in two ways. The first enquiry for a new form-and-territory pair was missed, because the client only subscribed to forms that already had enquiries. And channel count grew with forms times territories, against Ably's limit of 200 channels per connection. Territory channels derive from the user's scope, so the count stays small and never misses a first enquiry.

The security boundary is the token, not the client. The token route grants an admin subscribe-only access to all territory channels. A franchisee gets only their own, and nobody can publish. Tokens last two minutes, which bounds how long a revoked permission can linger.

Staff can pause live data while they read, so rows do not move under the cursor. Paused events are dropped, not queued. On resume the screen refetches from the server, which is the source of truth, so nothing is missed.

- Image: Screen recording of the enquiries table with a Live data indicator. A new row appears at the top with a green left border and a toast announces the enquiry. Live data is paused, a second submission arrives and nothing moves. On resume the missed row appears at the top.

- Image: A profile dialog with notification switches, one per territory.

### RBAC and entitlements

Two questions are kept apart. Roles and territories decide who may see or change something. Entitlements decide whether the plan includes the feature at all.

There are four roles. Admins see every territory. Franchisee roles see only assigned ones. The invite dialog sets role and territories together.

- Image: Screen recording of the Users page. The table lists users with their roles and territories. The Invite user dialog opens and an email address is typed, a role is picked and territories are added. The dialog stays complete on screen and is then cancelled without sending.

- Image: The users table with an Invite dialog open. The dialog has a role selector and a territory selector.

Plans are data. A single catalogue lists 25 features, each with a minimum tier and optional add-ons. A feature moves between plans by changing one line. I rejected comparing tier names in code, which scatters plan logic everywhere. A lint rule now bans it.

A single point in the system decides what a portal has. Today it reads a demo cookie, or grants everything. A future per-customer plan plugs in there and nothing else changes. Gates apply on the server and in the UI. The server gate is the security boundary. Gates hide and refuse. They never delete data, so a downgrade is safe.

### Data layer scoping and caching

Every database query must receive the viewer's visibility scope. The scope becomes the conditions of the query: no filter for admins, no results for a user with no territories, and only the assigned territories for everyone else. A query without it can leak across territories, so the rule has no exceptions.

Counts need the same care. A board that scopes its rows but not its column totals still leaks volume, so counts go through the scope too. Dashboard tests pass an out-of-scope territory filter and expect zeros.

For caching, Next.js 16 cache components hold slow-changing data such as territory lookups. Anything that takes a scope is never shared-cached. Hot data stays dynamic, refreshed by TanStack Query and Ably. Opening a record uses an intercepted route, so the drawer shows the same server content as the full page and the list keeps its scroll and filters.

- Image: An enquiry drawer slides over the list. A contact drawer for a repeat customer is stacked on top of it.

## Outcome

One portal replaces separate inboxes. Website forms, phone calls and manual entries land in the same pipeline. Each territory sees only its own work, and the network sees all of it. Spam is held back, deleted records can be recovered, and every change is in the audit log.

- HTML version: [https://danicalero.com/en/projects/h2o-portal](https://danicalero.com/en/projects/h2o-portal)
- Site index: [llms.txt](https://danicalero.com/en/llms.txt)
