Add actions tracker with filters and premises navigation#5
Draft
jonbur wants to merge 16 commits into
Draft
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a dedicated Actions section at
/premises/[id]/actionswhere users can view and manage all follow-up actions raised during audits.What's included
lib/actions.tsfor listing, updating, and deleting actionsHow to test
npm run db:migrate:deploy && npm run db:seedNotes
ActionFormwith an optional status field