Skip to content

Commit 1fde99f

Browse files
Merge pull request #4415 from OneCommunityGlobal/SaiKrishna_SearchAndSortFunctionalityForProjectsDetailsTable
Vamsidhar - AddingSearchAndSortFeatureForProjectDetailsTable
2 parents caf26a3 + f5ae2bb commit 1fde99f

10 files changed

Lines changed: 517 additions & 101 deletions

File tree

src/components/BMDashboard/BMDashboard.jsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,17 @@ export function BMDashboard() {
6666
}
6767
});
6868

69-
// Handle containers
69+
// Handle containers - only target containers within BMDashboard, not ProjectDetails
7070
const containers = bmContainer.querySelectorAll(
71-
'.container, .projects-list, .project-summary, .log-bar, .log-bar-dark',
71+
'.container, .projects-list, .project-summary',
7272
);
7373
containers.forEach(container => {
74+
// Skip if it's inside ProjectDetails (has project-details class in parent)
75+
const isInProjectDetails = container.closest('.project-details, .project-details-dark');
76+
if (isInProjectDetails) {
77+
return; // Don't override ProjectDetails styles
78+
}
79+
7480
if (darkMode) {
7581
container.style.setProperty('background-color', '#1b2a41', 'important');
7682
container.style.setProperty('color', '#ffffff', 'important');
@@ -80,11 +86,17 @@ export function BMDashboard() {
8086
}
8187
});
8288

83-
// Handle LogBar headings specifically
89+
// Handle LogBar headings specifically - only within BMDashboard, not ProjectDetails
8490
const logBarHeadings = bmContainer.querySelectorAll(
8591
'.log-bar h2, .log-bar-dark h2, .log-bar__section h2',
8692
);
8793
logBarHeadings.forEach(heading => {
94+
// Skip if it's inside ProjectDetails (has project-details class in parent)
95+
const isInProjectDetails = heading.closest('.project-details, .project-details-dark');
96+
if (isInProjectDetails) {
97+
return; // Don't override ProjectDetails LogBar styles
98+
}
99+
88100
if (darkMode) {
89101
heading.style.setProperty('color', '#ffffff', 'important');
90102
heading.style.setProperty('text-shadow', '0 1px 2px rgba(0, 0, 0, 0.5)', 'important');

src/components/BMDashboard/Projects/ProjectDetails/LogBar.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Button } from 'reactstrap';
33
import { Link } from 'react-router-dom';
44
import { useSelector } from 'react-redux';
55
import styles from './ProjectDetails.module.css';
6-
76
// button styles for each section
87
const buttonStyles = {
98
dailyLogging: 'green',
@@ -57,9 +56,7 @@ function LogBar(props) {
5756
<Link to={buttonLabels[section].url[index]}>
5857
<Button
5958
type="button"
60-
className={`${styles.button} ${styles.btn} ${
61-
styles[`button--${buttonStyles[section]}`]
62-
}`}
59+
className={`${styles.button} ${styles[`button--${buttonStyles[section]}`]}`}
6360
>
6461
{label}
6562
</Button>
@@ -68,7 +65,7 @@ function LogBar(props) {
6865
<Link to={`/bmdashboard/issues/add/${projectId}`}>
6966
<Button
7067
type="button"
71-
className={`${styles.button} ${styles.btn} ${styles['button--maroon']}`}
68+
className={`${styles.button} ${styles['button--maroon']}`}
7269
>
7370
Log Issue
7471
</Button>

src/components/BMDashboard/Projects/ProjectDetails/Materials/Materials.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import MaterialCard from './MaterialCard';
2+
import styles from '../ProjectDetails.module.css';
23

34
function Materials() {
45
return (
5-
<div className="cards-container__content">
6+
<div className={styles['cards-container__content']}>
67
<MaterialCard />
78
<MaterialCard />
89
<MaterialCard />

src/components/BMDashboard/Projects/ProjectDetails/Materials/MaterialsDisplay.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Card } from 'reactstrap';
22
import Materials from './Materials';
3+
import styles from '../ProjectDetails.module.css';
34

45
function MaterialsDisplay() {
56
return (
6-
<Card className="cards-container">
7-
<h2 className="cards-container__header">Materials with quantity less than 20% left</h2>
7+
<Card className={`card ${styles['cards-container']}`}>
8+
<h2>Materials with quantity less than 20% left</h2>
89
<Materials />
910
</Card>
1011
);

src/components/BMDashboard/Projects/ProjectDetails/ProjectDetails.jsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { useEffect, useState } from 'react';
12
import { useParams } from 'react-router-dom';
2-
import { useSelector } from 'react-redux';
3+
import { useSelector, useDispatch } from 'react-redux';
34
import { Container, Row, Col } from 'reactstrap';
5+
import { fetchBMProjects } from '~/actions/bmdashboard/projectActions';
6+
import Loading from '~/components/common/Loading';
47
import LogBar from './LogBar';
58
import RentedToolsDisplay from './RentedTools/RentedToolsDisplay';
69
import MaterialsDisplay from './Materials/MaterialsDisplay';
@@ -9,10 +12,32 @@ import styles from './ProjectDetails.module.css';
912

1013
function ProjectDetails() {
1114
const { projectId } = useParams();
15+
const dispatch = useDispatch();
1216
const darkMode = useSelector(state => state.theme.darkMode);
1317
const projects = useSelector(state => state.bmProjects) || [];
18+
const [isLoading, setIsLoading] = useState(true);
1419
const currProject = projects.find(project => String(project._id) === String(projectId));
1520

21+
useEffect(() => {
22+
const fetchProjects = async () => {
23+
setIsLoading(true);
24+
try {
25+
await dispatch(fetchBMProjects());
26+
} finally {
27+
setIsLoading(false);
28+
}
29+
};
30+
fetchProjects();
31+
}, [dispatch, projectId]);
32+
33+
if (isLoading) {
34+
return (
35+
<Container className={`${styles['project-details']} text-center mt-5`}>
36+
<Loading align="center" darkMode={darkMode} />
37+
</Container>
38+
);
39+
}
40+
1641
if (!currProject) {
1742
return (
1843
<Container className={`${styles['project-details']} text-center mt-5`}>
@@ -48,7 +73,7 @@ function ProjectDetails() {
4873
</Col>
4974
</Row>
5075

51-
<ProjectLog projectId={projectId} />
76+
<ProjectLog projectId={projectId} darkMode={darkMode} />
5277
</Col>
5378
</Row>
5479
</Container>

src/components/BMDashboard/Projects/ProjectDetails/ProjectDetails.module.css

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
margin-top: 1em;
5757
}
5858

59-
.log-bar__section h2,
60-
.card.cards-container h2,
61-
.project-log h2 {
59+
.log-bar__section :global(h2),
60+
.cards-container :global(h2),
61+
.project-log :global(h2) {
6262
font-size: 1em;
6363
font-weight: bold;
6464
color: #333333;
@@ -75,7 +75,7 @@
7575
list-style-type: none;
7676
}
7777

78-
.button.btn {
78+
.button {
7979
border: 0;
8080
border-radius: 10px;
8181
margin: 0.1em;
@@ -84,34 +84,55 @@
8484
font-weight: 500;
8585
}
8686

87-
.button.btn:hover {
87+
.button:hover {
8888
outline: auto;
8989
filter: brightness(130%);
9090
color: #ffffff !important;
9191
}
9292

9393
/* buttons custom colors */
94-
.button.btn.button--green {
94+
.button--green {
9595
background-color: #015d4a;
9696
color: #ffffff !important;
9797
}
9898

99-
.button.btn.button--blue {
99+
.button--blue {
100100
background-color: #0f6386;
101101
color: #ffffff !important;
102102
}
103103

104-
.button.btn.button--indigo {
104+
.button--indigo {
105105
background-color: #203844;
106106
color: #ffffff !important;
107107
}
108108

109-
.button.btn.button--maroon {
109+
.button--maroon {
110110
background-color: #980101;
111111
margin-top: 2em;
112112
color: #ffffff !important;
113113
}
114114

115+
/* Dark mode button colors - brighter/more vibrant for visibility */
116+
.log-bar-dark .button--green {
117+
background-color: #0d8b6f !important;
118+
border: 1px solid #0fb894;
119+
}
120+
121+
.log-bar-dark .button--blue {
122+
background-color: #1a8bb8 !important;
123+
border: 1px solid #2ba3d1;
124+
}
125+
126+
.log-bar-dark .button--indigo {
127+
background-color: #3a5a6b !important;
128+
border: 1px solid #4d7a94;
129+
}
130+
131+
.log-bar-dark .button--maroon {
132+
background-color: #c41e1e !important;
133+
border: 1px solid #e63939;
134+
}
135+
115136
@media (min-width: 550px) {
116137
.log-bar {
117138
display: flex;
@@ -124,11 +145,11 @@
124145
justify-content: center;
125146
}
126147

127-
.button.btn.btn-secondary {
148+
.button {
128149
width: auto;
129150
}
130151

131-
.button.btn.btn-secondary.button--maroon {
152+
.button.button--maroon {
132153
margin-top: auto;
133154
}
134155
}
@@ -142,22 +163,30 @@
142163
margin: 2em;
143164
}
144165

166+
.log-bar-dark {
167+
display: flex;
168+
flex-direction: row;
169+
flex-wrap: wrap;
170+
justify-content: center;
171+
margin: 2em;
172+
}
173+
145174
.log-bar__section {
146175
width: 50%;
147176
flex: auto;
148177
}
149178

150-
.button.btn.btn-secondary {
179+
.button {
151180
width: auto;
152181
}
153182

154-
.button.btn.btn-secondary.button--maroon {
183+
.button.button--maroon {
155184
margin-left: 2em;
156185
}
157186
}
158187

159188
/* styling for containers with cards */
160-
.card.cards-container {
189+
.cards-container {
161190
align-items: center;
162191
margin: 1em 2em;
163192
padding: 1em;
@@ -216,7 +245,7 @@
216245
padding: 0.5em;
217246
}
218247

219-
.single-card__body h3 {
248+
.single-card__body :global(h3) {
220249
font-size: 1em;
221250
margin-bottom: -0.2em;
222251
}
@@ -268,17 +297,17 @@
268297
white-space: nowrap;
269298
}
270299

271-
.project-log thead {
300+
.project-log :global(thead) {
272301
background-color: transparent;
273302
}
274303

275304
@media (max-width: 768px) {
276-
.project-log td,
277-
.project-log th {
305+
.project-log :global(td),
306+
.project-log :global(th) {
278307
font-size: 0.6em;
279308
}
280309
}
281310

282-
ul.log-bar__btn-group {
311+
.log-bar__btn-group {
283312
padding: 0px;
284313
}

0 commit comments

Comments
 (0)