Skip to content

feat: add periodic report generation interface - #60

Merged
marcvergees merged 2 commits into
fireform-core:mainfrom
Aliussman:58-feat-periodic-report-generation
Nov 7, 2026
Merged

marcvergees merged 2 commits into
fireform-core:mainfrom
Aliussman:58-feat-periodic-report-generation

Conversation

@Aliussman

Copy link
Copy Markdown
Contributor

Description

Adds a Reports tab for the periodic report API from fireform-core/fireform-backend#737 (POST /api/v1/reports/generate and GET /api/v1/reports/{report_id}).

  • Request form: choose Monthly / Quarterly / Annual, then the year and the month or quarter, and PDF or JSON output. Months and quarters that haven't started yet are disabled, matching the backend's FUTURE_PERIOD rule. The backend's error still shows if one comes back.
  • Background generation: after the 202, the tab polls GET /reports/{report_id}, waiting the retry_after_seconds the API returns each time. It shows elapsed time and the next check. Polling stops after 10 minutes with a "check the worker" message.
  • Switching tabs: the in-progress report is kept in memory in the zustand store (not localStorage), so you can leave Reports and come back without losing the job.
  • PDF: a Download PDF button that saves through Electron's normal save dialog. No main-process changes.
  • JSON: shown in the tab as summary cards, NERIS compliance, by-type and by-status bars, a per-period table and an incidents table, with a Download JSON button.
  • Errors: 422 (validation and FUTURE_PERIOD), 503 QUEUE_UNAVAILABLE, 404 REPORT_NOT_FOUND, 500 REPORT_FAILED, PDF_NOT_FOUND, and an unreachable backend each get a clear message, with Check again / Start over where they make sense.

Files:

  • src/renderer/lib/api.ts: typed generateReport / fetchReportResult, matching contracts/schemas/reporting.yaml, plus a ReportApiError that keeps error_code.
  • src/renderer/features/reports/: Reports.tsx (UI) and hooks.ts (polling hook, plus period labels and file names that match the backend's).
  • src/renderer/store/index.ts: activeReport state.
  • src/renderer/App.tsx: nav item and route.

Notes for reviewers

  • The UI offers PDF and JSON only. The backend also accepts format: "both", but GET /reports/{id} then returns only the JSON, so the PDF can't be downloaded. I can follow up on the backend if you'd like both.
  • The backend's CORS setup doesn't expose Content-Disposition, so the renderer usually can't read the server's filename. The frontend names the file the same way the backend does (e.g. FireForm_Quarterly_2026-Q3.pdf).

Depends on fireform-core/fireform-backend#737.

Fixes #58

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • npm run typecheck: passes
  • npm run lint: 0 errors. The 33 existing warnings are the same as on main; this PR adds none (eslint src/renderer/features/reports --max-warnings 0 passes).
  • npm run build: passes
  • Checked the real api.ts and hooks.ts code against a mock of the two endpoints (bundled with esbuild, run in Node). The mock answers 202 twice before the result. 26/26 checks passed:
    • PDF flow: two 202 responses honouring retry_after_seconds, then the PDF blob.
    • JSON flow: polling, then the PeriodicReport parsed correctly.
    • Request body: sends quarter or month only for the matching period type.
    • Errors surfaced with the right code and status: 422 FUTURE_PERIOD, 422 validation_errors, 503 QUEUE_UNAVAILABLE, 404 REPORT_NOT_FOUND, 500 REPORT_FAILED.
    • Period labels, file names and future-period checks.
  • Not yet clicked through in the running app against the full backend stack (Postgres + Redis + Celery). To try it: run the backend from FireForm#737 with docker compose, run npm run dev, open Reports, and generate a PDF report and a JSON report.

Test Configuration:

  • Node version: 24.12.0
  • Docker/Compose version: N/A (mock backend)
  • OS: Ubuntu Linux (x86_64)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (the repo has no frontend test runner; see the mock check above)
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules (needs feat: implement periodic report generation API (#557) fireform-backend#737)

@marcvergees
marcvergees merged commit 59030b6 into fireform-core:main Nov 7, 2026
1 check passed
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.

[FEAT]: Add periodic report generation interface

2 participants