Skip to content

Commit 6aecb34

Browse files
Merge pull request #5066 from OneCommunityGlobal/chirag-linked-projects-filter-fix-merge-errors
Chirag - Fixed the dark mode issues on the Total Construction Summary screen
2 parents 55ac805 + de598f3 commit 6aecb34

4 files changed

Lines changed: 117 additions & 61 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export const CustomDateComponent = ({
2+
date,
3+
decreaseMonth,
4+
increaseMonth,
5+
darkMode,
6+
isStartDate,
7+
}) => {
8+
const buttonStyle = {
9+
background: 'none',
10+
border: 'none',
11+
cursor: 'pointer',
12+
color: darkMode ? 'white' : 'black',
13+
fontSize: '16px',
14+
};
15+
16+
return (
17+
<div style={{ display: 'flex', alignItems: 'center', marginBottom: '10px' }}>
18+
<button onClick={decreaseMonth} style={{ ...buttonStyle, marginLeft: '10px' }}>
19+
20+
</button>
21+
22+
<span style={{ flex: 1, textAlign: 'center', fontWeight: 'bold', fontSize: '16px' }}>
23+
{date.toLocaleString('default', {
24+
month: 'long',
25+
year: 'numeric',
26+
})}
27+
</span>
28+
<button onClick={increaseMonth} style={{ ...buttonStyle, marginRight: '10px' }}>
29+
30+
</button>
31+
</div>
32+
);
33+
};

src/components/BMDashboard/Issues/issueCharts.module.css

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
/* ===========================
2-
Issue Charts Module CSS
3-
=========================== */
2+
Issue Charts Module CSS
3+
=========================== */
44

55
/* ----- Containers ----- */
66
.issueChartContainer,
77
.issueChartEventContainer {
88
width: 100%;
9+
max-width: 100%;
910
margin: 0;
10-
padding: 20px 40px;
11+
padding: 30px 40px;
1112
background: #f9f9f9;
1213
border-radius: 8px;
13-
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
14+
box-shadow: 0 4px 6px rgb(0 0 0 / 10%);
1415
display: flex; /* match dark mode layout */
1516
flex-direction: column; /* match dark mode */
1617
align-items: center; /* center filters like dark mode */
@@ -22,8 +23,7 @@
2223
max-width: 100%;
2324
margin: 0;
2425
padding: 30px 40px;
25-
26-
background:#1B2A41;
26+
background:#1B2A41;
2727
border-radius: 0;
2828
box-shadow: none;
2929
color: #ccd1dc;
@@ -82,20 +82,20 @@
8282
padding: 20px;
8383
background: #fff;
8484
border-radius: 8px;
85-
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
85+
box-shadow: 0 4px 6px rgb(0 0 0 / 10%);
8686
}
8787

8888
.chartWrapperDark {
8989
background: #1a1c20;
90-
width:100%;
90+
width:100%;
9191
padding: 25px;
9292
border-radius: 12px;
93-
box-shadow: 0 2px 6px rgba(0,0,0,0.6);
93+
box-shadow: 0 2px 6px rgb(0 0 0 / 60%);
9494
}
9595

9696
/* ----- Labels & Select Controls ----- */
9797
.issueChartLabel {
98-
width:100%;
98+
width:100%;
9999
font-size: 16px;
100100
color: #555;
101101
margin-right: 10px;
@@ -106,7 +106,7 @@
106106
}
107107

108108
.selectContainer {
109-
width:100%;
109+
width:100%;
110110
display: flex;
111111
align-items: center;
112112
justify-content: center;
@@ -132,6 +132,27 @@
132132
color: #cfd7e3;
133133
}
134134

135+
.filterSelect,
136+
.issueChartSelect {
137+
height: 60px;
138+
padding: 8px 12px;
139+
font-size: 15px;
140+
border-radius: 6px;
141+
border: 1px solid #cbd5e0;
142+
background-color: #fff;
143+
color: #2d3748;
144+
width: 100%;
145+
box-sizing: border-box;
146+
}
147+
148+
.filterSelectDark,
149+
.issueChartSelectDark {
150+
background-color: #2d3748;
151+
border: 1px solid #4a5568;
152+
color: #edf2f7;
153+
}
154+
155+
135156
.issueChartSelect:focus,
136157
.issueChartSelectDark:focus {
137158
border-color: #4caf50;
@@ -140,7 +161,7 @@
140161
/* ----- Filters ----- */
141162
.filtersContainer {
142163
display: flex;
143-
gap: 16px;
164+
gap: 45px;
144165
margin-top: 10px;
145166
margin-bottom: 25px;
146167
flex-wrap: wrap;
@@ -158,6 +179,10 @@
158179
gap: 8px;
159180
}
160181

182+
.projectFilter{
183+
width: 220px;
184+
}
185+
161186
.filterSelect {
162187
padding: 6px 8px;
163188
border: 1px solid #ccc;
@@ -195,26 +220,6 @@
195220

196221
/* ---------- Select / input base styles ---------- */
197222

198-
.filterSelect,
199-
.issueChartSelect {
200-
height: 60px;
201-
padding: 8px 12px;
202-
font-size: 15px;
203-
border-radius: 6px;
204-
border: 1px solid #cbd5e0;
205-
background-color: #ffffff;
206-
color: #2d3748;
207-
width: 100%;
208-
box-sizing: border-box;
209-
}
210-
211-
.filterSelectDark,
212-
.issueChartSelectDark {
213-
background-color: #2d3748;
214-
border: 1px solid #4a5568;
215-
color: #edf2f7;
216-
}
217-
218223
.filterSelect:focus,
219224
.issueChartSelect:focus {
220225
border-color: #4caf50;
@@ -225,24 +230,15 @@
225230

226231
/* ----- Chart Container ----- */
227232
.chartContainer {
228-
margin: 0 auto;
233+
margin: 20px;
229234
width: 100%;
230235
height: 400px;
231-
background: white;
232236
padding: 20px;
233237
border-radius: 8px;
234-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
235238
color: #000;
236239
}
237240

238241
.chartContainerDark {
239-
width: 100%;
240-
max-width: 900px; /* centers the chart while panel stays 100% */
241-
background: #1a1c20;
242-
padding: 25px;
243-
border-radius: 12px;
244-
margin: 0 auto;
245-
box-shadow: 0 2px 6px rgba(0,0,0,0.6);
246242
color: #cfd7e3;
247243
}
248244

@@ -294,7 +290,7 @@
294290
}
295291

296292
/* ----- Responsive ----- */
297-
@media (max-width: 768px) {
293+
@media (width <= 768px) {
298294
.chartContainer {
299295
height: 250px;
300296
padding: 10px;

src/components/BMDashboard/Issues/openIssueCharts.jsx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
fetchLongestOpenIssues,
2020
setProjectFilter,
2121
} from '../../../actions/bmdashboard/issueChartActions';
22+
import { CustomDateComponent } from './CustomDateComponent';
2223
import styles from './issueCharts.module.css';
2324

2425
/* ---------- helpers ---------- */
@@ -275,6 +276,9 @@ function IssueCharts() {
275276
<div className={styles.dateRangePicker}>
276277
<div className={styles.dateRangePickerStart}>
277278
<DatePicker
279+
renderCustomHeader={props => (
280+
<CustomDateComponent {...props} darkMode={darkMode} isStartDate={true} />
281+
)}
278282
id="start-date"
279283
selected={startDate}
280284
onChange={date => setStartDate(date)}
@@ -291,6 +295,9 @@ function IssueCharts() {
291295
<span className={styles.dateRangeSeparator}>to</span>
292296
<div className={styles.dateRangePickerEnd}>
293297
<DatePicker
298+
renderCustomHeader={props => (
299+
<CustomDateComponent {...props} darkMode={darkMode} isStartDate={false} />
300+
)}
294301
selected={endDate}
295302
onChange={date => setEndDate(date)}
296303
selectsEnd
@@ -317,13 +324,12 @@ function IssueCharts() {
317324
options={projectOptions}
318325
onChange={handleProjectChange}
319326
value={projectOptions.filter(option => (selectedProjects ?? []).includes(option.value))}
320-
// className={filterSelectClass}
321327
classNamePrefix="select"
322328
styles={{
323329
control: base => ({
324330
...base,
325-
backgroundColor: darkMode ? '#22272e' : '#ffffff',
326-
borderColor: darkMode ? '#3d444d' : '#ccc',
331+
backgroundColor: darkMode ? '#2D3748' : '#ffffff',
332+
borderColor: darkMode ? '#4a5568' : '#ccc',
327333
color: darkMode ? '#cfd7e3' : '#333',
328334
boxShadow: 'none',
329335
'&:hover': {
@@ -332,21 +338,21 @@ function IssueCharts() {
332338
}),
333339
menu: base => ({
334340
...base,
335-
backgroundColor: darkMode ? '#22272e' : '#ffffff',
336-
color: darkMode ? '#cfd7e3' : '#333',
341+
backgroundColor: darkMode ? '#2D3748' : '#ffffff',
342+
color: darkMode ? '#4a5568' : '#333',
337343
}),
338344
option: (base, state) => ({
339345
...base,
340346
backgroundColor: state.isFocused
341347
? darkMode
342-
? '#2f3540'
348+
? '#334155'
343349
: '#e5e5e5'
344350
: 'transparent',
345351
color: darkMode ? '#fff' : '#333',
346352
}),
347353
multiValue: base => ({
348354
...base,
349-
backgroundColor: darkMode ? '#3d444d' : '#e2e8f0',
355+
backgroundColor: darkMode ? '#334155' : '#e2e8f0',
350356
color: darkMode ? '#fff' : '#333',
351357
}),
352358
multiValueLabel: base => ({
@@ -368,7 +374,16 @@ function IssueCharts() {
368374

369375
<div className={chartContainerClass} ref={chartContainerRef}>
370376
{/* Step 6: Project Legend above the chart */}
371-
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '12px', marginBottom: '12px' }}>
377+
<div
378+
style={{
379+
display: 'flex',
380+
flexWrap: 'wrap',
381+
alignItems: 'center',
382+
gap: '12px',
383+
marginBottom: '12px',
384+
justifyContent: 'center',
385+
}}
386+
>
372387
{projectLegend.map(p => (
373388
<div key={p.projectId} style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>
374389
<span
@@ -398,7 +413,7 @@ function IssueCharts() {
398413
<CartesianGrid strokeDasharray="3 3" />
399414
<XAxis
400415
type="number"
401-
label={{ value: 'Duration in Months', position: 'insideBottom', offset: -5 }}
416+
label={{ value: 'Duration in Months', position: 'insideBottom', offset: -12 }}
402417
/>
403418
<YAxis
404419
dataKey="issueName"
@@ -423,7 +438,6 @@ function IssueCharts() {
423438
formatter={value => `${value} months`}
424439
labelFormatter={label => `Issue: ${label}`}
425440
/>
426-
{/* Step 5: Bar uses per-project colors */}
427441
<Bar dataKey="durationOpen" barSize={22} isAnimationActive={false}>
428442
{chartData.map((entry, index) => (
429443
<Cell key={index} fill={projectColorMap[entry.projectId] || '#94a3b8'} />

src/components/BMDashboard/WeeklyProjectSummary/QuantityOfMaterialsUsed/QuantityOfMaterialsUsed.jsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import {
1616
PointElement,
1717
LineController,
1818
} from 'chart.js';
19-
import { useSelector } from 'react-redux';
19+
import { useDispatch, useSelector } from 'react-redux';
2020
import ReactTooltip from 'react-tooltip';
2121
import { Info, Repeat } from 'lucide-react';
2222
import { v4 as uuidv4 } from 'uuid';
23+
import { fetchBMProjects } from '../../../../actions/bmdashboard/projectActions';
2324
import styles from './QuantityOfMaterialsUsed.module.css';
2425

2526
ChartJS.register(
@@ -68,13 +69,15 @@ function getRandomColor() {
6869
}
6970

7071
function QuantityOfMaterialsUsed({ data }) {
72+
const dispatch = useDispatch();
7173
const [chartData, setChartData] = useState(null);
7274
const [selectedMaterials, setSelectedMaterials] = useState([]);
7375
const [selectedDate, setSelectedDate] = useState('Last Week');
7476
const [dateRangeOne, setDateRangeOne] = useState([null, null]);
7577
const [dateRangeTwo, setDateRangeTwo] = useState([null, null]);
7678
const darkMode = useSelector(state => state.theme.darkMode);
77-
const selectedOrg = useSelector(state => state.weeklyProjectSummary.projectFilter);
79+
const projects = useSelector(state => state.bmProjects);
80+
const [selectedProjects, setSelectedProjects] = useState([]);
7881
const [legendColors, setLegendColors] = useState([]);
7982
const chartContainerRef = useRef(null);
8083
const [visibleRange, setVisibleRange] = useState([0, 30]);
@@ -83,6 +86,10 @@ function QuantityOfMaterialsUsed({ data }) {
8386

8487
const [isSmallScreen, setIsSmallScreen] = useState(false);
8588

89+
useEffect(() => {
90+
dispatch(fetchBMProjects());
91+
}, [dispatch]);
92+
8693
const selectStyles = useMemo(
8794
() => ({
8895
control: base => ({
@@ -190,7 +197,10 @@ function QuantityOfMaterialsUsed({ data }) {
190197
return Array.from(uniqueMaterials.values());
191198
}, [data]);
192199

193-
const orgOptions = useMemo(() => [{ value: selectedOrg, label: selectedOrg }], [selectedOrg]);
200+
const projectOptions = projects.map(project => ({
201+
value: project._id,
202+
label: project.name,
203+
}));
194204

195205
const dateOptions = useMemo(
196206
() => [
@@ -493,7 +503,7 @@ function QuantityOfMaterialsUsed({ data }) {
493503
: []),
494504
],
495505
});
496-
}, [data, selectedMaterials, selectedOrg, selectedDate, dateRangeOne, dateRangeTwo]);
506+
}, [data, selectedMaterials, selectedProjects, selectedDate, dateRangeOne, dateRangeTwo]);
497507

498508
const barWidth = 12;
499509
// Subtract the 40-px y-axis offset
@@ -735,13 +745,16 @@ function QuantityOfMaterialsUsed({ data }) {
735745
/>
736746

737747
<Select
738-
options={orgOptions}
739-
value={orgOptions.find(option => option.value === selectedOrg)}
740-
placeholder="Organization"
748+
options={projectOptions}
749+
isMulti
750+
isSearchable
751+
value={projectOptions.find(option => option.value === selectedProjects)}
752+
placeholder="Projects"
741753
menuPlacement={isSmallScreen ? 'top' : 'auto'}
742754
classNamePrefix="custom-select"
743755
className={`quantity-of-materials-used-dropdown-item ${styles.dropdownItem}`}
744-
// isDisabled
756+
closeMenuOnSelect={false}
757+
hideSelectedOptions={true}
745758
styles={selectStyles}
746759
/>
747760
<Select

0 commit comments

Comments
 (0)