Incident Management — Codebase Flow
This page is for engineers: it maps domain behaviour to the main files/classes. Paths are relative to the repo root.
Staff/Admin Frontend
| Component | File | Role |
|---|---|---|
| List page | Tuke/app/[curl]/incident-management/index.tsx | Active/Closed tabs, filters, create permission, open drawer. |
| Detail page | Tuke/app/[curl]/incident-management/[id]/index.tsx | Shows incident detail, attendees, attachments, workflow actions, history. |
| Create/edit form | Tuke/app/[curl]/incident-management/components/IncidentForm.tsx | Incident fields, site/course, attendee context. |
| Create/edit drawer | components/IncidentFormDrawer.tsx | Calls create/update service, redirects to detail. |
| Workflow actions | components/WorkflowActions.tsx | Submit/review/approve/send/close/reopen/cancel. |
| Attachments | components/AttachmentSection.tsx | Upload/download/delete file attachment. |
| Generated reports | components/GeneratedAttachmentSection.tsx | Generate/download generated PDF. |
| Notification history | components/NotificationHistoryTimeline.tsx | Shows notification jobs related to incident. |
| Client API wrapper | services/incident-management.ts | Maps UI calls to backend routes. |
Staff/Admin Backend API
Tux/src/Tux.Api/Controllers/IncidentManagementController.cs
| Route | Service method | Behaviour |
|---|---|---|
GET /api/incident-management/incidents | SearchAsync | Search list by status/filter/scope. |
GET /{id} | GetDetailAsync | Load detail, attendees, attachments, acknowledgements, actions. |
POST / | CreateDraftAsync | Create draft incident. |
POST /{id}/update | UpdateDraftAsync | Edit incident when editable. |
POST /{id}/submit | SubmitAsync | Move to Submitted, write history, enqueue notification. |
POST /{id}/start-review | StartReviewAsync | Move to Under Review. |
POST /{id}/request-changes | RequestChangesAsync | Move to Changes Requested, save comment. |
POST /{id}/approve | ApproveAsync | Move to Approved, write approval metadata. |
POST /{id}/send-to-customer | SendToCustomerAsync | Create acknowledgements, status Sent To Customer, enqueue notification. |
POST /{id}/generate-pdf | GeneratePdfAsync | Render and store generated PDF. |
GET /{id}/notification-history | GetNotificationHistoryAsync | Return notification jobs for incident. |
The aggregate interface is Tux/src/Tux.Core/Interfaces/IIncidentManagementService.cs.
Backend Service
Tux/src/Services/Tux.Service/IncidentManagementService.cs holds the domain behavior:
Important helpers:
| Helper | Role |
|---|---|
GetIncidentPermissionLevelAsync | Resolves create/view/full-control behaviour. |
GetEditableIncidentAsync | Guards whether an incident can be edited. |
GetAllowedActions | Computes actions from status + permission. |
SaveHistoryAsync | Writes EntityHistory/snapshot for lifecycle. |
BuildPdfDatasetAsync | Collects data for report PDF. |
MergePdfAttachmentsAsync | Merges PDF attachment files into the report when eligible. |
Customer Portal
| Component | File | Role |
|---|---|---|
| Customer list | Tuke/app/[curl]/incidents/index.tsx | Shows incident acknowledgements for the current account. |
| Customer detail | Tuke/app/[curl]/incidents/[id]/index.tsx | Shows detail, generated PDF, acknowledge/sign form. |
| Customer service wrapper | Tuke/app/[curl]/incidents/services/incidents.ts | Calls ConsumerForm endpoints. |
| Controller | Tux/src/Tux.Api/Controllers/Consumer/ConsumerFormController.cs | Customer-facing routes. |
| Service | Tux/src/Services/Tux.Service.Consumer/ConsumerFormService.cs | Scope by account + acknowledgement, submit acknowledgement/signature. |
Notification Worker
| Component | File | Role |
|---|---|---|
| Generator | Tux/src/Workers/Tux.Workers.Notification.Generator/Generator.cs | Processes notification scheduler, renders output. |
HandleIncidentSentToCustomerAsync | Same file | Loads incident/contact/template and queues email/SMS/user message when applicable. |
| Platform flow | Platform → Codebase flow | Explains IncidentSubmitted in the event-derived notification flow. |
Quick Debug Search
bash
rg -n "IncidentManagementService|IncidentManagementController|ConsumerFormController" Tux/src
rg -n "IncidentStatus|sendToCustomerIncident|generateIncidentPdf" 'Tuke/app/[curl]/incident-management'
rg -n "ConsumerForm/incidents|getCustomerIncident" 'Tuke/app/[curl]/incidents'Next: Data & read/write tables.