Skip to content

Linh – Add Material Usage Insights & Visual Indicators to Materials Table#4736

Open
linh2020 wants to merge 11 commits into
developmentfrom
linh_materials_usage_insights_visual_indicators
Open

Linh – Add Material Usage Insights & Visual Indicators to Materials Table#4736
linh2020 wants to merge 11 commits into
developmentfrom
linh_materials_usage_insights_visual_indicators

Conversation

@linh2020

@linh2020 linh2020 commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Description

image

This PR improves the usability and clarity of the Materials table in the BM Dashboard by adding visual indicators and usage insights.

Previously, the table displayed only raw numeric values (Bought, Used, Available, Wasted, Hold), requiring admins to manually interpret stock health and material consumption. This made it easy to miss low-stock or high-usage items, especially when managing large datasets.

This update enhances the table with intuitive visual cues and a summary panel, allowing admins to quickly identify materials that may require attention.

Implements:
(WBS: Add Material Usage Insights & Visual Indicators)

Related PRs (if any)

Related backend PR: #2019 (Material Usage Insights Backend APIs and Calculations)

Main changes explained

Stock Health Indicator

Added a new Stock Health column to the Materials table.
Displays color-coded icons to represent inventory status:

  • Green: Healthy
  • Yellow: Low stock
  • Red: Critical stock
  • Gray: No purchases recorded

Status is calculated using Available / Bought with default thresholds:

  • Critical ≤ 20%
  • Low ≤ 40%
  • Healthy > 40%

Added hover tooltips explaining:

  • Available vs. Bought values
  • Stock ratio percentage
  • Health status

Usage Percentage Bar

Added a Usage % column showing material consumption as Used / Bought.
Displays a progress bar with contextual text (e.g., 7.1 / 40 (18%)).
Safely handles edge cases:

  • Displays N/A when Bought = 0
  • Prevents overflow by clamping values
    Tooltips provide clear explanations of usage calculations.

Summary Panel
Added a summary panel above the Materials table displaying:

  • Total materials
  • % at low stock (Low + Critical)
  • % over usage threshold (≥ 80% used)
  • Items on Hold

Metrics are calculated based on the currently displayed dataset (frontend-only).

How to test

  1. Check out this branch: linh_materials_usage_insights_visual_indicators
  2. Run npm install (or yarn install) and start the frontend locally.
  3. Clear browser cache / site data if needed.
  4. Log in as an admin user.
  5. Navigate to the Materials page: /bmdashboard/materials
  6. Verify:
  • Stock Health icons display correctly based on inventory levels.
  • Usage % bars reflect correct consumption values.
  • Tooltips explain calculations clearly.
  • Summary panel metrics update correctly.
  • UI renders properly in both light and dark mode.
  • Layout remains responsive on different screen sizes.

Note

This PR focuses on frontend-only enhancements using existing material data.
Custom low-stock thresholds per project or global configuration are intentionally left as a future enhancement and will require backend support.

- Implement usage percentage calculation (Used / Bought)
- Implement stock ratio calculation (Available / Bought)
- Add stock health status determination (Critical/Low/Healthy/No-Data)
- Add formatting utilities for floating point precision handling
- Create tooltip generation functions for visual indicators
- Include summary metrics calculation from material lists
- All calculations include safe guards for zero/null values
- MaterialSummaryPanel: displays 4 key metrics (total, low stock %, usage %, on hold)
- ItemsTable: adds Stock Health Indicator and Usage % Bar columns
- ItemListView: integrates summary panel above table
- Components support dark mode, responsive design, and accessibility
@netlify

netlify Bot commented Jan 20, 2026

Copy link
Copy Markdown

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit 2d7939a
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6a384910c5c5a30008302c60
😎 Deploy Preview https://deploy-preview-4736--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.

@linh2020 linh2020 changed the title Linh materials usage insights visual indicators Linh – Add Material Usage Insights & Visual Indicators to Materials Table Jan 20, 2026
@linh2020 linh2020 changed the title Linh – Add Material Usage Insights & Visual Indicators to Materials Table Linh – Add Material Usage Insights & Visual Indicators to Materials Table [WIP] Jan 20, 2026
@sonarqubecloud

Copy link
Copy Markdown

@linh2020 linh2020 changed the title Linh – Add Material Usage Insights & Visual Indicators to Materials Table [WIP] Linh – Add Material Usage Insights & Visual Indicators to Materials Table Feb 3, 2026
@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 Apr 24, 2026
@sonarqubecloud

Copy link
Copy Markdown

…odNetworkApp into linh_materials_usage_insights_visual_indicators

@handikaharianto handikaharianto 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.

Hi, after reviewing this PR, here's my findings:

Worked Well

Stock Health data is displayed properly✅

The stock health data correctly displays the icons based on the inventory level. The colors also make it easier to distinguish the data.
Image

Usage % bars reflect correct consumption values✅

The Usage % bars correctly reflects the consumption values based on the Bought and Used data.
Image

Tooltips explain calculations clearly✅

The tooltips in Usage % and Stock Health provides clear information about the data.
Image

Image

Summary panel metrics are updated correctly✅

After applying the available filters, the metrics in the Summary Panel are updated and displayed correctly.
Image

Responsive layout in different screen sizes✅

The layout is responsive in all screen sizes (mobile, tablets, desktop)
Image

Image

Requires some updates

Time label color mismatched❌

This Time label color is shown as black in the dark mode, while others are displayed in white.
Image

Alignments❌

These Select and Date picker are not aligned properly.

  • The time label is on the left side of the date picker, while the labels for select are on top.
Image

Also, whenever I opened the date picker, it will automatically push the Project and Material to the right side.
Image

Material Usage Proportion dialog dark styles❌

As can be seen from the image below, this dialog doesn't have a proper styles when it's in a dark mode.
Image

@sonarqubecloud

Copy link
Copy Markdown

@pixelpix13 pixelpix13 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.

hi @linh2020 below are are reviews for the frontend repo and some changes that are needed

Testing Summary

Tested frontend PR #4736 together with backend PR #2019.

Verified

  • Stock Health indicators display correctly based on Available vs Bought values.
  • Usage percentage bars calculate correctly.
  • Summary panel metrics update correctly.
  • Over Usage Threshold values update correctly.
  • Items on Hold metrics update correctly.
  • Tooltips display the correct stock and usage information.
  • Layout generally works in both light and dark modes.
  • Usage calculations handle normal datasets correctly.

Summary Panel Verification

image

Stock Health & Usage Indicators

image

Issue 1 – Dark Mode Usage Bar Contrast

The usage percentage bars become difficult to distinguish in dark mode because the border contrast is too low.

Expected Behavior

The usage bar border should maintain sufficient contrast in dark mode to clearly separate the progress bar from the background.

Screenshot

image

Issue 2 – Duplicate Project Fields

There appear to be duplicate project selection fields on the page.

Expected Behavior

Only the necessary project filter should be displayed to avoid confusion.

Screenshot

image

Issue 3 – Tooltip Displays Extra "?"

When hovering over Stock Health and Usage indicators:

  • Tooltip data itself is displayed correctly.
  • An additional "?" icon/text also appears.

This extra indicator appears unnecessary and may confuse users.


Issue 4 – Tooltip Missing When Only One Search Result Exists

When filtering the table down to a single result:

  • Stock Health tooltip does not appear.
  • This appears to be caused by tooltip positioning constraints inside the table.

Expected Behavior

Tooltips should display regardless of row count.

Screenshot

image

Issue 5 – Modal Dark Mode Contrast

The modal does not have sufficient color contrast in dark mode.

Some text and controls become difficult to distinguish from the background.

Expected Behavior

Modal elements should follow the same dark mode accessibility and contrast standards as the rest of the page.

Screenshot

image

Issue 6 – Duplicate Search Fields

Two search inputs appear to be available simultaneously.

Question

Please verify whether both search fields are required or if one is unintended.

Screenshot

image

Issue 7 – Critical Stock Threshold Validation

When setting the Critical Stock threshold to:

0

the functionality begins to behave unexpectedly.

Observed:

  • Editing other rows afterwards produces errors.
  • Healthy rows can no longer be edited correctly.

Expected Behavior

Threshold values should be validated and invalid values should not cause failures in unrelated rows.

Screenshot

image

Overall Assessment

Verified Working

  • Stock Health indicators
  • Usage percentage calculations
  • Summary panel calculations
  • Usage threshold metrics
  • Tooltip data calculations
  • General responsiveness

Requesting Changes

The feature works overall, but the following issues should be addressed:

  • Dark mode contrast for usage bars
  • Duplicate project fields
  • Extra tooltip "?" indicator
  • Missing tooltip when only one row exists
  • Modal dark mode contrast
  • Duplicate search fields
  • Critical stock threshold validation when set to 0

These appear to be UI/UX and validation issues rather than calculation issues, but they should be resolved before approval.

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.

5 participants