Skip to content

Add actions tracker with filters and premises navigation#5

Draft
jonbur wants to merge 16 commits into
mainfrom
cursor/actions-tracker-af56
Draft

Add actions tracker with filters and premises navigation#5
jonbur wants to merge 16 commits into
mainfrom
cursor/actions-tracker-af56

Conversation

@jonbur

@jonbur jonbur commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a dedicated Actions section at /premises/[id]/actions where users can view and manage all follow-up actions raised during audits.

What's included

  • Actions tracker page with summary cards (total, open, in progress, overdue)
  • Filters for status, priority, due date presets (overdue / upcoming / none), and custom due-before / due-after ranges
  • Inline status updates, edit modal, and delete with confirmation
  • Premises navigation tabs (Profile | Audit | Actions) shared across premises pages
  • Home page link to the actions tracker
  • Shared lib/actions.ts for listing, updating, and deleting actions

How to test

  1. Run migrations and seed: npm run db:migrate:deploy && npm run db:seed
  2. Start the app and open a premises with audit actions
  3. Navigate to Actions via the tab bar or home page link
  4. Try filtering by status, priority, and due date
  5. Change status inline, edit an action (including status), and delete one

Notes

  • Filter query params are reflected in the URL so filters survive refresh
  • The edit modal reuses the audit ActionForm with an optional status field
Open in Web Open in Cursor 

cursoragent and others added 16 commits July 1, 2026 16:48
- Rewrite audit seed with official September 2025 section titles (25 sections, 100 items)
- Add lib/sections.ts to compute applicableSections from profile flags
- Add 5-step premises profile wizard at /premises/[id]/profile
- Add profile GET/PUT API with organisation-scoped access
- Seed dev organisation and premises for local testing

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
- lib/audit.ts: start/resume audit, save responses, section status, actions
- lib/audit-items.ts: filter questions by premises profile tags
- API routes for audit lifecycle, responses, and actions
- AuditWizard with SectionNav, QuestionCard, ResponseInput, ActionRaiseForm
- Pages at /premises/[id]/audit and /premises/[id]/audit/[auditId]
- Responses saved to DB on each answer; actions linked to audit items
- Seed dev premises profile for audit testing

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
- Widen app shell from max-w-3xl to max-w-6xl
- Use two-column grid from sm breakpoint (640px) instead of lg
- Sticky scrollable section nav on the left

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
- Add needsAction flag on AuditResponse (separate from yes/no answer)
- Yes shows mandatory 'Provide details' notes field before saving
- Needs action checkbox available for Yes and No answers
- Section progress only counts complete answers (Yes requires notes)
- API validates response rules server-side

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Co-authored-by: jonbur <jonbur@users.noreply.github.com>
- Import full audit-template-seed.ts as source of truth (26 sections, 122 items)
- Add normalization layer flattening subsections (e.g. s14 staff/volunteers)
- Support YES_NO_NA_ACTION, OPEN_TEXT, and DATE_UPLOAD response types
- Update section/item profileFlag filtering to match template metadata
- Section IDs now s1–s26; reseed updates AuditTemplate JSON

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Draft audits created before the September 2025 template update stored
section IDs that no longer match the active template, so buildAuditOverview
returned no sections and the wizard page hit notFound().

Sync draft audit sections from the current profile on load and resume,
recomputing applicableSections and attaching the active template when needed.
Show a clear recovery message if no sections apply after sync.

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Replace the flattened audit template with the official September 2025
structure where compound topics use GROUP items with individually
answerable sub-questions.

- Extend template types with GROUP, subQuestions, and label fields
- Normalize section subsections and group items without flattening
- Count and save responses per sub-question for progress tracking
- Render grouped questions with QuestionGroupCard in the audit wizard

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
QuestionCard synced local state from the entire item prop on every parent
re-render. In grouped sections, sibling saves created new item objects and
wiped unsaved Yes/details selections.

Only re-sync when the stored server response changes, debounce text saves,
and flush valid pending answers on unmount.

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Debounced saves set savingItemId which disabled the textarea, causing it
to grey out and lose focus mid-typing. Keep textareas editable during
background saves, skip note sync while focused, and slow autosave to 800ms.

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Unmount and debounced saves used activeSectionId, so leaving a section
could flush answers against the newly selected section (e.g. Electrical)
and fail with 'Question not found in this section'.

Pass the rendered section id with each save and resolve items across the
audit template on the server as a fallback.

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Add AuditResponse.recordedDate (PostgreSQL DATE) for certificate and
inspection dates. DATE_UPLOAD questions now render a native date picker
instead of a free-text field, with validation and autosave on change.

Open-text questions continue to use the textarea; completion logic
checks recordedDate for date items and notes for text items.

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Load linked Action records from the database per question instead of
inferring from the needsAction flag, which caused a flash of the Raise
action button after navigation. Items with an existing action now show
a stable Edit action link that opens the action form in edit mode.

Add PATCH /api/actions/[actionId] for updating actions.

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Remove the Needs action toggle from audit questions. Each item now has
an Actions panel with list, add, edit, and delete backed by Action
records in the database. Creating an action no longer mutates the audit
response needsAction flag.

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Introduce a dedicated /premises/[id]/actions section to view all follow-up
actions with filtering by status, priority, and due date. Includes summary
cards, inline status updates, and edit/delete via the shared ActionForm.

Wire PremisesNav across profile, audit, and actions pages, and add a home
page link to the actions tracker.

Co-authored-by: jonbur <jonbur@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants