Skip to content

Commit 430a693

Browse files
Merge pull request #4279 from OneCommunityGlobal/fatima-fix-for-Distribution-Labor-Hours
Fatima added Dark mode to Distribution Labour Hours
2 parents e464cfd + 5603df9 commit 430a693

2 files changed

Lines changed: 52 additions & 32 deletions

File tree

src/components/BMDashboard/WeeklyProjectSummary/DistributionLaborHours/DistributionLaborHours.jsx

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
import React, { useState, useEffect } from 'react';
2-
import { PieChart, Pie, Cell, Tooltip, Legend, ResponsiveContainer } from 'recharts';
2+
import { useSelector } from 'react-redux';
3+
import { PieChart, Pie, Cell, Tooltip, ResponsiveContainer } from 'recharts';
34
import styles from './DistributionLaborHours.module.css';
45

5-
const COLORS = ['#f9f3e3', '#2a647c', '#2e8ea3', '#ffab91', '#ffccbb', '#bbbbbbff'];
6+
const COLORS = ['#2a647c', '#2e8ea3', '#ffab91', '#ffccbb', '#bbbbbb', '#f9f3e3'];
67

7-
const CustomTooltip = ({ active, payload, total }) => {
8+
const CustomTooltip = ({ active, payload, total, darkMode }) => {
89
if (active && payload && payload.length) {
9-
const category = payload[0].name;
10-
const value = payload[0].value;
10+
const { name, value } = payload[0];
1111
const percent = ((value / total) * 100).toFixed(1);
1212
return (
13-
<div className={styles.tooltip}>
14-
<p>{category}</p>
13+
<div
14+
className={styles.tooltip}
15+
style={{
16+
backgroundColor: darkMode ? '#2E3E5A' : '#fff',
17+
color: darkMode ? '#fff' : '#000',
18+
border: darkMode ? '1px solid #555' : '1px solid #ccc',
19+
}}
20+
>
21+
<p>{name}</p>
1522
<p>{`Hours: ${value} hrs`}</p>
1623
<p>{`Percentage: ${percent}%`}</p>
1724
</div>
@@ -21,6 +28,8 @@ const CustomTooltip = ({ active, payload, total }) => {
2128
};
2229

2330
export default function DistributionLaborHours() {
31+
const darkMode = useSelector(state => state.theme.darkMode);
32+
2433
const [originalData, setOriginalData] = useState([]);
2534
const [filteredData, setFilteredData] = useState([]);
2635
const [dateRange, setDateRange] = useState({ from: '', to: '' });
@@ -56,47 +65,55 @@ export default function DistributionLaborHours() {
5665
const totalHours = filteredData.reduce((sum, item) => sum + item.value, 0);
5766

5867
return (
59-
<div className={styles.container}>
60-
<h3 className={styles.title}>Distribution of Labor Hours</h3>
68+
<div
69+
className={styles.container}
70+
style={{
71+
backgroundColor: darkMode ? '#2E3E5A' : '#fff',
72+
color: darkMode ? '#f5f5f5' : '#000',
73+
}}
74+
>
75+
<h3 className={styles.title} style={{ color: darkMode ? '#ffffff' : '#000000' }}>
76+
Distribution of Labor Hours
77+
</h3>
6178

79+
{/* Filters */}
6280
<div className={styles.filters}>
63-
<label>
81+
<label style={{ color: darkMode ? '#ffffff' : '#000000' }}>
6482
From:
6583
<input
6684
type="date"
6785
value={dateRange.from}
6886
onChange={e => setDateRange({ ...dateRange, from: e.target.value })}
6987
/>
7088
</label>
71-
<label>
89+
<label style={{ color: darkMode ? '#ffffff' : '#000000' }}>
7290
To:
7391
<input
7492
type="date"
7593
value={dateRange.to}
7694
onChange={e => setDateRange({ ...dateRange, to: e.target.value })}
7795
/>
7896
</label>
79-
<label>
97+
<label style={{ color: darkMode ? '#ffffff' : '#000000' }}>
8098
Project:
8199
<select onChange={e => setProjectFilter(e.target.value)} value={projectFilter}>
82100
<option value="">All</option>
83101
<option value="Project A">Project A</option>
84102
<option value="Project B">Project B</option>
85103
</select>
86104
</label>
87-
<label>
105+
<label style={{ color: darkMode ? '#ffffff' : '#000000' }}>
88106
Member:
89107
<select onChange={e => setMemberFilter(e.target.value)} value={memberFilter}>
90108
<option value="">All</option>
91109
<option value="Member 1">Member 1</option>
92110
<option value="Member 2">Member 2</option>
93111
</select>
94112
</label>
95-
<button className={styles.button} onClick={() => window.location.reload()}>
96-
Submit
97-
</button>
113+
<button className={styles.button}>Submit</button>
98114
</div>
99115

116+
{/* Chart + Legend */}
100117
<div className={styles.chartWrapper}>
101118
<div className={styles.legend}>
102119
{filteredData.map((entry, index) => (
@@ -105,7 +122,9 @@ export default function DistributionLaborHours() {
105122
className={styles.colorBox}
106123
style={{ backgroundColor: COLORS[index % COLORS.length] }}
107124
/>
108-
{entry.name}: {entry.value} hrs
125+
<span style={{ color: darkMode ? '#f5f5f5' : '#000' }}>
126+
{entry.name}: {entry.value} hrs
127+
</span>
109128
</div>
110129
))}
111130
</div>
@@ -120,13 +139,14 @@ export default function DistributionLaborHours() {
120139
cx="50%"
121140
cy="50%"
122141
outerRadius={100}
123-
onClick={data => alert(`Drilldown for: ${data.name}`)}
142+
labelLine={false}
143+
label={({ value }) => `${((value / totalHours) * 100).toFixed(1)}%`}
124144
>
125145
{filteredData.map((entry, index) => (
126146
<Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
127147
))}
128148
</Pie>
129-
<Tooltip content={<CustomTooltip total={totalHours} />} />
149+
<Tooltip content={<CustomTooltip total={totalHours} darkMode={darkMode} />} />
130150
</PieChart>
131151
</ResponsiveContainer>
132152
</div>

src/components/BMDashboard/WeeklyProjectSummary/DistributionLaborHours/DistributionLaborHours.module.css

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
12
.container {
2-
background-color: white;
33
border-radius: 8px;
44
padding: 16px;
5-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
5+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
66
width: 100%;
77
height: 100%;
88
display: flex;
99
flex-direction: column;
10+
transition: background-color 0.3s ease, color 0.3s ease;
1011
}
1112

1213
.title {
1314
font-size: large;
14-
color: black;
1515
font-weight: bold;
16+
margin-bottom: 8px;
1617
}
1718

1819
.filters {
@@ -58,24 +59,24 @@
5859
}
5960

6061
.tooltip {
61-
background-color: white;
62-
border: 1px solid #ccc;
62+
border-radius: 6px;
6363
padding: 8px;
6464
font-size: 0.85rem;
65-
border-radius: 4px;
65+
transition: background-color 0.2s ease, color 0.2s ease;
6666
}
6767

6868
.button {
69-
background-color: white;
70-
border: 1px solid black;
71-
border-radius: 10%;
72-
padding: 10px 20px;
69+
background-color: transparent;
70+
color: inherit;
71+
border: 1px solid currentColor;
72+
border-radius: 6px;
73+
padding: 8px 16px;
7374
cursor: pointer;
74-
transition: background-color 0.3s ease;
75+
transition: all 0.3s ease;
7576
}
7677

7778
.button:hover {
78-
background-color: #fff2f0;
79+
background-color: rgba(255, 255, 255, 0.1);
7980
}
8081

8182
.pieChartContainer {
@@ -85,7 +86,6 @@
8586
width: 100%;
8687
}
8788

88-
8989
@media (max-width: 768px) {
9090
.chartWrapper {
9191
flex-direction: column;

0 commit comments

Comments
 (0)