diff --git a/src/components/CommunityPortal/ResourceUsage/ResourceUsage.jsx b/src/components/CommunityPortal/ResourceUsage/ResourceUsage.jsx index 9e54ce32b0..a1b4e57dd5 100644 --- a/src/components/CommunityPortal/ResourceUsage/ResourceUsage.jsx +++ b/src/components/CommunityPortal/ResourceUsage/ResourceUsage.jsx @@ -1,6 +1,6 @@ 'use client'; -import { useState, useEffect } from 'react'; +import { useState, useEffect, useRef } from 'react'; import { Dropdown } from 'react-bootstrap'; import { BarChart, @@ -82,6 +82,10 @@ const insightDefinitions = { 'Highest cost venues/hr': 'Venue with the highest hourly cost during the selected period.', }; +function filterDataByDate(data, timePeriod) { + return data; +} + function CustomTooltip({ active, payload, darkMode }) { if (!active || !payload || !payload.length) return null; @@ -120,10 +124,21 @@ export default function ResourceUsage() { const [insights, setInsights] = useState(allInsights['Last Week']); const darkMode = useSelector(state => state.theme.darkMode); + const badgeRefs = useRef([]); + + useEffect(() => { + badgeRefs.current.forEach(badge => { + if (badge) { + badge.style.setProperty('color', '#000'); + } + }); + }, [insights, darkMode]); useEffect(() => { - setData(allData[resourceType.toLowerCase()]); - }, [resourceType]); + const resourceTypeKey = resourceType.toLowerCase(); + const filteredData = filterDataByDate(allData[resourceTypeKey], timePeriod); + setData(filteredData); + }, [resourceType, timePeriod, allData]); useEffect(() => { setInsights(allInsights[insightsTimePeriod]); @@ -172,51 +187,64 @@ export default function ResourceUsage() { Amount - - - + {data && data.length > 0 ? ( + + + - + - + - } /> + } /> - + - - - - + + + + + ) : ( +
+

No data available for the selected time period and resource type.

+
+ )} @@ -224,7 +252,6 @@ export default function ResourceUsage() {

Insights

- {insightsTimePeriod} @@ -249,25 +276,28 @@ export default function ResourceUsage() { key={idx} className={`${styles.insightCard} ${darkMode ? 'bg-yinmn-blue text-light' : ''}`} > - {/* 🔹 ADD THIS LINE RIGHT HERE */} -
{insightDefinitions[insight.title]}
+
+
+ {insight.title} +
-
- {insight.title} -
+
(badgeRefs.current[idx] = el)} + className={styles.insightBadge} + style={{ backgroundColor: insight.color }} + > + {insight.value} +
-
- {insight.value} +
Based on returned vs loaned comparison
-
Based on returned vs loaned comparison
+ {/* Tooltip */} +
{insightDefinitions[insight.title]}
))}
diff --git a/src/components/CommunityPortal/ResourceUsage/ResourceUsage.module.css b/src/components/CommunityPortal/ResourceUsage/ResourceUsage.module.css index ac172e0314..4efee66921 100644 --- a/src/components/CommunityPortal/ResourceUsage/ResourceUsage.module.css +++ b/src/components/CommunityPortal/ResourceUsage/ResourceUsage.module.css @@ -1,7 +1,6 @@ .resourceUsageContainer { display: flex; min-height: 100vh; - background-color: #fff; } .darkContainer { @@ -13,6 +12,10 @@ padding: 1.5rem; } +.darkChartSection { + background: #2b3e59; +} + .headerSection { margin-bottom: 2rem; } @@ -27,6 +30,22 @@ padding: 0.5rem 1rem !important; border-radius: 0.375rem !important; font-size: 0.875rem !important; + + /* Your enhancements */ + box-shadow: none !important; + display: flex !important; + align-items: center !important; + gap: 0.5rem !important; +} + +.customDropdown:hover, +.customDropdown:focus { + background-color: #b7b7b8 !important; + border-color: #e5e7eb !important; +} + +.customDropdown::after { + margin-left: 0.5rem !important; } .chartContainer { @@ -51,10 +70,6 @@ border-left: 1px solid #e5e7eb; } -.darkInsightsSection { - background: #1b2a41; -} - .insightCard { position: relative; padding: 1rem; @@ -83,27 +98,22 @@ /* Tooltip */ .insightTooltip { position: absolute; - bottom: 3.25rem; + bottom: 100%; left: 50%; - transform: translateX(-50%) translateY(6px); - max-width: 140px; - width: max-content; - padding: 0.6rem 0.75rem; - background-color: #374151; - color: #fff; - font-size: 0.75rem; - line-height: 1.35; - border-radius: 0.5rem; - white-space: normal; - text-align: left; - box-shadow: 0 8px 20px rgb(0 0 0 / 18%); + transform: translateX(-50%); + background: #374151; + color: white; + padding: 8px 10px; + border-radius: 6px; + font-size: 12px; opacity: 0; + visibility: hidden; + transition: all 0.2s ease; pointer-events: none; - transition: opacity 0.15s ease, transform 0.15s ease; - z-index: 5; + z-index: 10; } -/* 🔥 FIX: Apply dark styles INSIDE insights section */ +/* FIX: Apply dark styles INSIDE insights section */ .darkInsightsSection .insightCard { background-color: #1e293b; border: 1px solid #334155; @@ -134,6 +144,7 @@ font-weight: 600; margin: 0; color: #111827; + border-left: 1px solid #e5e7eb; } .darkInsightsSection .insightsHeader h2 { @@ -147,6 +158,7 @@ } /* BADGE */ + .insightBadge { padding: 0.25rem 0.75rem; border-radius: 1rem; @@ -155,11 +167,17 @@ color: #111827; } - .insightCard .insightBadge { color: #111827 !important; } +/* Tooltip */ +.customTooltip { + padding: 0.75rem; + border-radius: 0.375rem; + border: 1px solid #e5e7eb; +} + .insightCard:hover .insightTooltip { opacity: 1; transform: translateX(-50%) translateY(0); @@ -176,6 +194,7 @@ line-height: 1.3; } +/* Tooltip styles */ .tooltipTitle { font-weight: 600; font-size: 0.8rem; @@ -201,23 +220,22 @@ font-weight: 600; } -/* ---------------- DARK MODE DROPDOWNS ---------------- */ - +/* DARK MODE DROPDOWN */ .dark-mode .customDropdown, .dark-mode .dropdown-toggle.customDropdown { - background-color: #1c2541 !important; + background-color: #1C2541 !important; color: #fff !important; - border-color: #3a506b !important; + border-color: #3A506B !important; } .dark-mode .dropdown-toggle.customDropdown.show, .dark-mode .show > .customDropdown.dropdown-toggle { - background-color: #243b5a !important; + background-color: #243B5A !important; } .dark-mode .dropdown-menu { - background-color: #1c2541 !important; - border-color: #3a506b !important; + background-color: #1C2541 !important; + border-color: #3A506B !important; } .dark-mode .dropdown-item { @@ -225,7 +243,7 @@ } .dark-mode .dropdown-item:hover { - background-color: #3a506b !important; + background-color: #3A506B !important; } /* Chart ticks */ @@ -233,4 +251,4 @@ font-size: 12px; font-weight: 700; fill: #666; -} +} \ No newline at end of file diff --git a/src/components/CommunityPortal/ResourceUsage/__tests__/ResourceUsage.test.jsx b/src/components/CommunityPortal/ResourceUsage/__tests__/ResourceUsage.test.jsx index d5a0174143..556dc4e765 100644 --- a/src/components/CommunityPortal/ResourceUsage/__tests__/ResourceUsage.test.jsx +++ b/src/components/CommunityPortal/ResourceUsage/__tests__/ResourceUsage.test.jsx @@ -39,6 +39,7 @@ describe('ResourceUsage Component', () => { // Find ALL "Venue" buttons const venueButtons = screen.getAllByRole('button', { name: 'Venue' }); + // The LAST one is the dropdown menu option const menuOption = venueButtons[venueButtons.length - 1]; fireEvent.click(menuOption);