Skip to content

Purav taking over for Juhitha-Reddy create injury trend chart - #5439

Open
pixelpix13 wants to merge 13 commits into
developmentfrom
Purav-taking-over-Injury-Trend-Chart
Open

Purav taking over for Juhitha-Reddy create injury trend chart#5439
pixelpix13 wants to merge 13 commits into
developmentfrom
Purav-taking-over-Injury-Trend-Chart

Conversation

@pixelpix13

@pixelpix13 pixelpix13 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Frontend PR — Injury Trend Line Chart (Phase 2)

Description

Takes over and finishes the frontend work from #4063 (Juhitha_Create_Injury_Trend_Chart) on a fresh development base.

Implements the Injuries Tracking line chart for Phase 2 Summary Dashboard with Project and Date filters, dark mode styling, responsive layout, BM Dashboard menu access, and project-linked demo data. Integrates with backend Injury Trend APIs for monthly counts by severity.

Implements #Phase2-InjuryTrend

Related PRs

  • Supersedes: frontend #4063 (closed in favor of this takeover)
  • Backend pair: HGNRest #2304 — Purav taking over injury trend APIs + POST injuries
  • Original backend reference: HGNRest #1723

Main changes explained

  • Create InjuryTrendChart component with Recharts multi-line chart:
    • Lines: Serious (red), Medium (orange), Low Level (green)
    • Legend at top, axis labels (Month / counts), and data labels
    • Dark mode theming and responsive layout
  • Filters (aligned in header):
    • Project dropdown (projects with injuries; falls back to demo projects if needed)
    • Start / End date pickers with month and year dropdowns
  • Data integration:
    • Fetches trend data from GET /bm/injuries/trend-data by project ObjectIds + date range
    • Fetches project list from GET /bm/injuries/project-injury
    • Project-linked demo series when API has no filtered data; ALL = sum of every project’s series (no unlinked injuries)
  • Navigation:
    • Injuries Tracking appears under Other Links → BM Dashboard only while on a BM Dashboard route (/bmdashboard or /bmdashboard/...)
    • Chart route remains /bmdashboard/injurychart (BMProtectedRoute)
  • UI polish:
    • Reference-style layout (title left, filters right, centered legend)
    • No forced blank page space under the chart

How to test

  1. Check out this branch and the backend pair:
    • Frontend: Purav-taking-over-Injury-Trend-Chart (this PR)
    • Backend: HGNRest #2304
  2. Frontend:
    • yarn install
    • Set REACT_APP_APIENDPOINT=http://localhost:4500/api
    • yarn start:local
  3. Backend:
    • yarn dev (or npm run dev) on port 4500
  4. Login as an admin / BM Dashboard user.
  5. Go to Other Links → BM Dashboard (/bmdashboard).
  6. Confirm Injuries Tracking is visible in Other Links (directly under BM Dashboard) while on BM Dashboard, and is not shown when you are outside BM Dashboard routes.
  7. Open Injuries Tracking/bmdashboard/injurychart.
  8. Verify:
    • Chart title Injuries Tracking, legend (Serious / Medium / Low Level), and aligned Project + Dates filters
    • Project dropdown lists projects; switching projects changes the chart (Building 1 ≠ akv_test ≠ ALL)
    • ALL shows higher totals than any single project (sum of project-linked data)
    • Date pickers support month + year dropdowns; clearing dates shows a multi-month window
    • Legend, axis labels, data labels, and project name in tooltip
    • Light and dark mode look correct; layout works on desktop and mobile widths
    • Page does not leave a large empty space below the chart
    • Direct navigation to /bmdashboard/injurychart still requires BM access (BMProtectedRoute)

Screenshots

Light mode
pr 2304 5439_2



Dark mode
pr 2304 5439_1



Video

pr.2304.5439.mp4



Note

  • Pair with backend PR #2304 for full API filtering.
  • Demo data is project-linked and used when the API has no filtered series yet; replace/verify with real seeded injuries from the backend POST API when available.

…lters.

Takes over PR #4063 on a fresh development base, wires trend-data APIs correctly, and fixes review issues around project filtering, filter layout, and dark mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit 1a9300a
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6a862ea5db7a360008f27965
😎 Deploy Preview https://deploy-preview-5439--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

pixelpix13 and others added 6 commits August 11, 2026 14:36
…link.

Align title, legend, and filters; add month/year date dropdowns, responsive layout, All Projects demo data, and a BM Dashboard menu entry for the chart.

Co-authored-by: Cursor <cursoragent@cursor.com>
…from those series.

Ensures demo injuries are never unlinked from a project, and each project filter shows its own trend instead of a single shared dataset.

Co-authored-by: Cursor <cursoragent@cursor.com>
… every project.

Fixes identical charts across project filters by rendering linked demo profiles instead of the unfiltered API payload.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keeps the chart link gated to BM Dashboard routes like the other BM project menu items.

Co-authored-by: Cursor <cursoragent@cursor.com>
Fixes the menu gate that only matched /bmdashboard/* so the link appears after entering BM Dashboard without changing the chart route.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace Date relational comparisons with month-index math and remove unreachable demo-mode branches that failed the quality gate.

Co-authored-by: Cursor <cursoragent@cursor.com>
@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Aug 13, 2026

@Adit0717 Adit0717 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this locally on Purav-taking-over-Injury-Trend-Chart branch and found a relevant issue.

Date fields don't switch to dark mode - On the Injuries Tracking chart, the "Start date" and "End date" inputs stay in light styling (white/light background) when dark mode is toggled on.

Image

@RuthwikHM RuthwikHM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this locally and things are working fine. Found one small issue in dark mode though. The date pickers do not respect dark mode colors. See the screenshots attached below.

Image Image

@DeepighaJ DeepighaJ left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the PR against all the listed requirements.
Everything is working as expected, including Injuries Tracking visibility, project filtering, ALL totals, date/month/year selectors, chart data/labels/tooltips, responsive layout, light/dark mode, empty-space handling, and BM-protected direct navigation.

One issue found: In Dark Mode, the Start Date and End Date picker text/values appear in white, which reduces readability/visibility. Please update the date picker styling for dark mode.
Other than this, all tested functionality is working as expected.

Image Image Image Image Image

@linlin-husky linlin-husky left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested on the local brand. Most of the checking points work fine. However, I found the below two issues.

  1. injury list is available outside the BM Dashboard: When I clicking the total construction summary below the report, the injury list is visible below the BM dashboards under the Other Links. Pls refer to the below image.
Image
  1. in the right upper date picking area, click the right date picking area, the left date is visible. However, when clicking the left date picking area, the right is invisible, which looks misleading to user. User may assume they can not enter the right data picking area because it disappeared. Pls refer to the below image.
Image Image

pixelpix13 and others added 6 commits August 19, 2026 17:12
Address dark-mode date pickers, keep both date inputs visible when a calendar opens, and hide Injuries Tracking outside true BM Dashboard context.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove centered portal modal behavior while keeping dark-mode input/calendar styling and overflow fixes so both date fields stay visible.

Co-authored-by: Cursor <cursoragent@cursor.com>
Layer the end date field above the start calendar popper and widen the dates filter column so both inputs stay visible.

Co-authored-by: Cursor <cursoragent@cursor.com>
Match start date styling by relying on shared input styles instead of white backgrounds on date picker wrappers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Stop raising the end date input above its clear icon while keeping the field layered above the start calendar popper.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

Copy link
Copy Markdown

@beblicarl
beblicarl self-requested a review August 20, 2026 10:10
@beblicarl

Copy link
Copy Markdown
Contributor

This feature works as intended, and the code is great

https://www.loom.com/share/09be45496fa44e20817685fbde3fe56c

@ShreyasB02 ShreyasB02 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and verified all the changes including the latest fixes.
All these work :

  • Chart title: Injuries Tracking, legend (Serious / Medium / Low Level), and aligned Project + Dates filters
  • Project dropdown lists projects; switching projects changes the chart (Building 1 ≠ akv_test ≠ ALL)
  • ALL shows higher totals than any single project (sum of project-linked data)
  • Date pickers support month + year dropdowns; clearing dates shows a multi-month window
  • Legend, axis labels, data labels, and project name in tooltip
  • Light and dark mode look correct.
  • Direct navigation to /bmdashboard/injurychart still requires BM access (BMProtectedRoute)

Changes requested:

  • Start date later than end date should not be allowed.
Screenshot 2026-08-20 at 4 36 37 PM
  • When switched to tablet view in portrait mode, there is a lot of empty space at the bottom after the graph, unlike mobile view on iPhone 14 Pro and Samsung Galaxy S20 Ultra.
Screenshot 2026-08-20 at 4 32 29 PM Screenshot 2026-08-20 at 4 47 27 PM

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants