Aditya-fix: BM dashboard stoppage data loading and responsiveness#4396
Aditya-fix: BM dashboard stoppage data loading and responsiveness#4396Aditya-gam wants to merge 34 commits intodevelopmentfrom
Conversation
- Extract data from structured response {success, data, message, ...}
- Add validation for success field in responses
- Display API message for empty results and errors
- Enhance error handling with specific messages for auth, network, and server errors
- Add console logging for debugging API failures
- Support backward compatibility with raw array responses
Fixes issue with component crashing when backend returns structured response format instead of raw arrays.
- Replace axios import with httpService for consistent auth handling - Update all axios.get() calls to httpService.get() (3 locations) - Enable automatic JWT token attachment to requests - Enable automatic auth error interception (401/403 redirects) - Align with codebase standard pattern used in other BM components This ensures proper authentication handling and prevents intermittent failures when JWT tokens expire.
…ffects - Create dedicated useEffect for auto-selecting first project - Separate data-fetching useEffect with single responsibility - Remove 'projects' from data-fetch dependencies (eliminates race condition) - Add early return guard clause when no project selected - Simplify logic by removing complex conditional branching This follows React best practices (single responsibility principle) and eliminates the race condition that caused redundant API calls. The auto-select effect runs once when projects load, then the data-fetch effect runs when selectedProject changes.
- Add 500+ server error detection in projects fetch useEffect - Include HTTP status codes in generic error fallbacks for debugging - Maintain consistent error handling pattern across both useEffects - Distinguish between auth (401/403), network, server (500+), and unknown errors - Provide actionable error messages for each error category Users now receive specific guidance (login, check network, wait for server) instead of generic error messages. Status codes help developers diagnose production issues.
…error tracking - Import logService from services directory - Replace console.error calls with logService.logError in both catch blocks - Leverage Sentry integration for centralized error monitoring - Eliminates ESLint warnings about console statements - Aligns with codebase logging standards Errors are now properly captured in production monitoring instead of just browser console.
- Add align-items: start to grid container to prevent cards from stretching - Change card min-heights from fixed 250px to auto for content-based sizing - Cards now size to their content instead of matching tallest card height
- Change ToolsHorizontalBarChart card height from 100% to auto - Add height: auto and flex properties to donut chart wrapper - Override tools-availability-page min-height 100vh to auto for card context - Add styles for tools-horizontal-chart-container to prevent stretching - Remove excessive padding from tools-availability-page wrapper
- Reduce Reason of Stoppage chart height from 600px to 300px - Add categoryPercentage (0.6) and barPercentage (0.9) to reduce bar spacing - Replace barThickness with maxBarThickness (25px) for better scaling - Standardize donut chart height to 300px on desktop, 280px on tablet - Increase Tools by Availability chart height from 200px to 280px - All charts now fit on screen without scrolling and have consistent sizing
… and tablet - Add responsive grid layout: 1 column mobile, 2 columns tablet, 4 columns desktop - Ensure cards span full width on mobile/tablet to prevent squishing - Reduce spacing and padding on mobile to eliminate empty space - Add width constraints (100%, max-width: 100%, box-sizing: border-box) to cards - Ensure filter controls don't overflow on mobile screens
- Add responsive margin calculation (mobile: {5,5,15,5}, tablet: {8,15,25,8}, desktop: {10,30,40,10})
- Add responsive Y-axis width (mobile: 20px, tablet: 28px, desktop: 35px)
- Add responsive font sizes for Y-axis ticks (mobile: 10px, tablet: 11px, desktop: 12px)
- Add width constraints to chart content container (100%, max-width: 100%)
- Add box-sizing: border-box to card container to prevent overflow
- Reduce padding and margins on mobile for better fit
…bile/tablet - Add responsive Chart.js options: maxBarThickness, categoryPercentage, barPercentage - Add responsive font sizes for scales, legend, and datalabels based on screen width - Wrap Chart.js Bar component in constrained container div to prevent overflow - Add Bootstrap Row/Col responsive fixes for mobile (full width, proper padding) - Add width constraints (100%, max-width: 100%) to chart container - Reduce title font size on mobile for better fit - Ensure filter controls stack vertically and don't overflow on mobile
- Add responsive margin calculation (mobile: {20,20,20,20}, tablet: {25,25,30,30}, desktop: {30,30,40,40})
- Add responsive font size for center text (mobile: 10px, tablet: 12px, desktop: 14px)
- Remove max-width: 400px constraint and add width: 100%, max-width: 100%
- Add box-sizing: border-box to wrapper for proper sizing
- Reduce spacing and font sizes on mobile for better readability
- Ensure chart fits within viewport without overflow
✅ Deploy Preview for highestgoodnetwork-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…bility - Fix grey background in light mode: Add white background (#ffffff) to tools-availability-page and chart containers to match other charts in Tools and Equipment Tracking section - Fix axis visibility in dark mode: Change axis border and tick colors from #e0e0e0 to #ffffff for better contrast and visibility - Add !important flags to ensure background colors override parent card styles - Add background styling to chart container wrapper divs to cover entire chart area including legend
Anusha-Gali
left a comment
There was a problem hiding this comment.
Hi Aditya,
I have reviewed your PR locally and though most of the functionalities work as per requirement. I have identified three issues.
1: When i choose the below mobile responsive format, the charts were not completely visible


2: The dropdown in Stoppage of Tools and Tool/Equipment are in white background where in Tools by Availability, it isn't consistent. I would appreciate if it is consistent

3: Also the dropdown in Tools/Equipment when an option is selected - it doesn't show any other options in dropdown, i.e we need to click on ALL and then selected another option

…ools section - Add responsive breakpoint at 1366px for better chart visibility on medium screens - Standardize chart heights across all three Tools charts (240px/280px/300px) - Fix height matching so donut chart determines section height, other charts adapt - Remove conflicting dark mode CSS overrides for react-select dropdowns - Standardize all dropdowns to use consistent react-select dark mode styles - Convert ToolStatusDonutChart native selects to react-select with proper theming - Fix ToolStatusDonutChart to use unfiltered toolslist for options to prevent disappearing selections - Ensure all charts stretch or shrink to match donut chart's natural height - Remove min-height constraints that prevented proper height matching
…vices - Add granular breakpoints (375px, 428px, 480px) for better mobile support - Implement progressive chart height scaling from 180px (small phones) to 300px (desktop) - Scale all chart elements proportionally (fonts, margins, bar thickness, radii) - Add overflow prevention to chart containers for small screens - Update CSS media queries with gradient scaling for titles, filters, and legends - Ensure charts scale smoothly across all device sizes preventing overflow on iPhones - Reduce padding and spacing on smaller screens for optimal space utilization
- Add filter labels for date range and project filters with proper dark mode styling - Fix label and chart title text colors to white in dark mode for better contrast - Restructure filter layout to be symmetric and modular with consistent sizing - Ensure all filter inputs have matching heights (38px) for proper alignment - Improve date picker input group layout with clear button integration - Add reset button wrapper for consistent spacing with other filters - Fix date picker dark mode background styling with inline styles and CSS fallbacks
…and dark modes - Standardize date picker input dimensions to match other form inputs (38px height) - Ensure dark mode only changes colors, not sizes or dimensions - Remove inline styles that could cause sizing inconsistencies - Set consistent font-size (13px), padding (8px 12px), and border-radius (6px) - Make date picker visually identical in both modes except for colors
- Fix tools dropdown to use correct data structure (tool.itemType._id and tool.itemType.name) - Fetch projects from TOOLS_AVAILABILITY_PROJECTS endpoint instead of extracting from toolslist - Fix projects dropdown to properly display available projects - Add projects state and useEffect to fetch projects data - Ensure dropdown options remain available after selection (use unfiltered data sources) - Match data structure access pattern used in EquipmentUpdateForm component
…e duplication - Extract react-select option styling logic into shared utility functions - Create reactSelectUtils.js with getOptionBackgroundColor and getOptionColor helpers - Replace nested ternary operators with if-else statements in helper functions - Remove duplicate helper functions from ToolStatusDonutChart and ToolsHorizontalBarChart - Reduce cognitive complexity from 17 to below 15 in both components - Eliminate code duplication by centralizing shared styling logic
- Extract nested ternary operations to shared utility functions - Reduce cognitive complexity from 17 to below 15 in ToolsStoppageHorizontalBarChart - Fix CSS contrast issues in datepicker calendar (lines 58 and 69) - Extract complete selectStyles object to shared getStandardSelectStyles utility - Eliminate code duplication by centralizing react-select styling logic - Update both ToolsStoppageHorizontalBarChart and ToolStatusDonutChart to use shared utilities - Improve maintainability with single source of truth for react-select styles
|
ResponsiveContainer with height="100%" needs an ancestor with explicit pixel height. On mobile single-column layout this caused 0px height. Use getChartHeight() for explicit px height so chart renders on all sizes. Co-authored-by: Cursor <cursoragent@cursor.com>
- ToolsStoppageHorizontalBarChart: replace nested flex wrappers with single div using explicit pixel height; remove overflow clipping - ToolsStoppageHorizontalBarChart.module.css: remove flex:1, min-height:0, overflow:hidden from .tools-horizontal-chart-container - ToolsHorizontalBarChart.css: remove flex/min-height from content area, set overflow:visible to avoid tooltip clipping Co-authored-by: Cursor <cursoragent@cursor.com>
Resolved conflicts across 7 files, preserving our responsive chart fixes while integrating dev branch's CSS modules migration, new features, and dependency updates.
Resolves yarn install --frozen-lockfile failure in GitHub Actions. Co-authored-by: Cursor <cursoragent@cursor.com>
Centralize responsive breakpoints (375, 428, 480, 768, 1024) and export getValueForBreakpoints plus getChartHeight, getChartMargins, getYAxisWidth, getChartFontSize, getMaxBarThickness, getCategoryPercentage, getBarPercentage, getChartTitleFontSize for use by tools charts. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove duplicated responsive logic from ToolsHorizontalBarChart and ToolsStoppageHorizontalBarChart; both now import shared helpers from chartResponsiveUtils. Reduces SonarQube duplicated lines on new code while keeping behavior unchanged (same breakpoints and values). Co-authored-by: Cursor <cursoragent@cursor.com>
|

























Description
Fixes # (PRIORITY HIGH) - BM Dashboard fix 'Reason of Stoppage of Tools' data loading error

This PR implements a comprehensive fix for the BM Dashboard "Reason of Stoppage of Tools" section data loading error and introduces responsive design improvements for all tool-related charts in the Weekly Project Summary. The implementation includes a new horizontal bar chart component for visualizing tool stoppage reasons (Used its lifetime, Damaged, Lost), enhanced error handling with proper user-facing messages, and full mobile/tablet responsiveness across the Tools and Equipment Tracking section.
Related PRs (if any):
Main changes explained:
Created/Updated Files (highlights):
Tools/ToolsStoppageHorizontalBarChart.jsxTools/ToolsStoppageHorizontalBarChart.module.css+ related assetsWeeklyProjectSummary/Tools/ToolsHorizontalBarChart.jsx&.cssWeeklyProjectSummary/ToolStatusDonutChart/*WeeklyProjectSummary/WeeklyProjectSummary.jsx&.module.csssrc/utils/URL.jsBM_TOOL_PROJECTSandBM_TOOLS_STOPPAGE_BY_PROJECThelpers so the frontend can request project lists and stoppage data with optional date filters.Key Implementation Details:
Structured API Response Handling
All components now handle the new backend response format consistently:
Components check
response.successand extract data fromresponse.dataor fall back to treating the response itself as data for backward compatibility.Enhanced Error Handling
Categorized error messages for better user experience:
response.data.messagewhen availableService Layer Migration
axioscalls withhttpService.get()wrapper in ToolsStoppageHorizontalBarChartconsole.errorwithlogService.logError()for centralized error trackinguseEffecthooks for better separation of concerns:Responsive Design Strategy
All tool charts now use a consistent responsive approach:
windowWidthstateDark Mode Consistency
darkModestate from ReduxHow to test:
Aditya-fix/reason-tool-stoppage-chart-fixrm -rf node_modules && yarn cache cleanyarn installand start the app:yarn start:localReason of Stoppage chart
Error/Resilience
Responsive & Dark Mode
Integration sanity
Screenshots or videos of changes:
TestVideo.mov
Note: