Skip to content

Commit 1ca44a5

Browse files
Merge pull request #4451 from OneCommunityGlobal/Sanjeev_fix_event_display_for_selected_date
Sanjeev fix event display for selected date
2 parents fa2c158 + c1ab864 commit 1ca44a5

17 files changed

Lines changed: 554 additions & 211 deletions

File tree

.stylelintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public/
2+
node_modules/
3+
dist/
4+
build/
5+
coverage/

src/actions/__tests__/authActions.js.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ describe('authActions', () => {
116116

117117
expect(setHeaderData(data)).toEqual(expectedAction); // Assert the action
118118
});
119-
});
119+
});

src/actions/authActions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const getHeaderData = userId => {
115115
};
116116
};
117117

118-
export const logoutUser = () => dispatch => {
118+
export const logoutUser = () => (dispatch) => {
119119
// Clear any active force-logout timer before logging out
120120
dispatch(stopForceLogout());
121121
localStorage.removeItem(tokenKey);
@@ -135,18 +135,18 @@ export const startForceLogout = (delayMs = 20000) => (dispatch, getState) => {
135135
const timerId = setTimeout(async () => {
136136
try {
137137
const { userProfile } = getState();
138-
138+
139139
if (userProfile && userProfile._id) {
140140
const { firstName: name, lastName, personalLinks, adminLinks, _id } = userProfile;
141-
141+
142142
await axios.put(ENDPOINTS.USER_PROFILE(_id), {
143143
firstName: name,
144144
lastName,
145145
personalLinks,
146146
adminLinks,
147147
isAcknowledged: true,
148148
});
149-
149+
150150
// eslint-disable-next-line no-console
151151
console.log('Permission changes acknowledged during force logout');
152152
}

src/components/Auth/PermissionWatcher.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from 'react';
1+
import { useEffect, useState, useRef } from 'react';
22
import { useSelector, useDispatch } from 'react-redux';
33
import axios from 'axios';
44
import { ENDPOINTS } from '~/utils/URL';

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
}
7070

7171
.darkMode .dropdownButton {
72-
color: #eee;
72+
color: #ccc;
7373
background: #2b2b2b;
7474
border: 1px solid #555;
7575
}
@@ -93,7 +93,7 @@
9393

9494
.darkMode .dropdownMenu {
9595
background: #2c2c2c;
96-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
96+
box-shadow: 0 2px 8px #000;
9797
}
9898

9999
/* React-select overrides */

src/components/CommunityPortal/Activities/activityId/ResourcesUsage.module.css

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
/* src/components/CommunityPortal/Activities/activityId/Resources.module.css */
2-
.resourcesUsage {
3-
background: white;
4-
padding: 20px;
5-
border-radius: 8px;
6-
font-family: Arial, sans-serif;
7-
width: 100%;
8-
}
92

103
/* border for all the row data */
114
.resourceRow {

src/components/CommunityPortal/Activities/styles.module.css

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@
130130
color: red;
131131
}
132132

133+
/* Resource Monitoring Title */
134+
.resourceMonitoring .resourceTitle {
135+
font-weight: bold;
136+
color: grey;
137+
text-align: left;
138+
font-size: 1.2rem;
139+
margin-bottom: 5px;
140+
}
141+
133142
.registrationForm,
134143
.filters {
135144
margin: 20px 0;
@@ -240,17 +249,24 @@
240249
font-size: 1.5em;
241250
}
242251

243-
.status.active {
252+
.myEvent .status {
253+
padding: 5px;
254+
border-radius: 5px;
255+
color: white;
256+
font-weight: bold;
257+
}
258+
259+
.myEvent .status.active {
244260
background-color: rgb(200, 240, 200);
245261
color: green;
246262
}
247263

248-
.status.closed {
264+
.myEvent .status.closed {
249265
background-color: rgb(191, 191, 238);
250266
color: purple;
251267
}
252268

253-
.status.cancelled {
269+
.myEvent .status.cancelled {
254270
background-color: rgb(239, 170, 170);
255271
color: red;
256272
}
@@ -321,12 +337,22 @@
321337

322338
/* Resource Monitoring */
323339

340+
341+
324342
.resourceValue {
325343
font-weight: bold;
326344
color: black;
327345
font-size: 1rem;
328346
}
329347

348+
.resourceMonitoring .resourceStats {
349+
display: flex;
350+
align-items: center;
351+
margin-top: 10px;
352+
}
353+
354+
355+
330356
/* My Events toggle button */
331357
.viewToggle button {
332358
padding: 10px 20px;
@@ -370,6 +396,17 @@
370396
background-color: #0056b3;
371397
}
372398

399+
.myEvent .createNewBtn {
400+
padding: 8px 20px;
401+
background-color: #28a745;
402+
color: white;
403+
border: none;
404+
border-radius: 5px;
405+
cursor: pointer;
406+
}
407+
408+
409+
373410
.registerinfo {
374411
display: flex;
375412
flex-direction: column;

src/components/CommunityPortal/CPDashboard.jsx

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function CPDashboard() {
3737
const [events, setEvents] = useState([]);
3838
const [searchInput, setSearchInput] = useState('');
3939
const [searchQuery, setSearchQuery] = useState('');
40+
const [selectedDate, setSelectedDate] = useState('');
4041
const [onlineOnly, setOnlineOnly] = useState(false);
4142
const [isLoading, setIsLoading] = useState(false);
4243
const [dateFilter, setDateFilter] = useState('');
@@ -99,6 +100,25 @@ export function CPDashboard() {
99100
});
100101
};
101102

103+
// Helper function to extract date in YYYY-MM-DD format from event date
104+
const parseEventDate = dateString => {
105+
if (!dateString) return null;
106+
107+
try {
108+
// Try to parse as ISO date string or standard date
109+
const parsedDate = new Date(dateString);
110+
if (!isNaN(parsedDate.getTime())) {
111+
const year = parsedDate.getFullYear();
112+
const month = String(parsedDate.getMonth() + 1).padStart(2, '0');
113+
const day = String(parsedDate.getDate()).padStart(2, '0');
114+
return `${year}-${month}-${day}`;
115+
}
116+
} catch (error) {
117+
console.error('Error parsing date:', error);
118+
}
119+
return null;
120+
};
121+
102122
function isTomorrow(dateString) {
103123
const input = new Date(dateString);
104124

@@ -133,11 +153,17 @@ export function CPDashboard() {
133153
if (!isOnlineEvent) return false;
134154
}
135155

136-
// Filter by date filter
156+
// Filter by date filter (Tomorrow / Weekend)
137157
if (dateFilter === 'tomorrow') {
138-
return isTomorrow(event.date);
158+
if (!isTomorrow(event.date)) return false;
139159
} else if (dateFilter === 'weekend') {
140-
return isComingWeekend(event.date);
160+
if (!isComingWeekend(event.date)) return false;
161+
}
162+
163+
// Filter by specific date (if selected)
164+
const eventDate = event.date ? parseEventDate(event.date) : null;
165+
if (selectedDate && eventDate !== selectedDate) {
166+
return false;
141167
}
142168

143169
// Filter by search query if provided
@@ -151,6 +177,11 @@ export function CPDashboard() {
151177
);
152178
});
153179

180+
// Reset pagination to page 1 when filters change
181+
useEffect(() => {
182+
setPagination(prev => ({ ...prev, currentPage: 1 }));
183+
}, [searchQuery, selectedDate, onlineOnly, dateFilter]);
184+
154185
const totalPages = Math.ceil(filteredEvents.length / pagination.limit) || 1;
155186

156187
const displayedEvents = filteredEvents.slice(
@@ -180,11 +211,11 @@ export function CPDashboard() {
180211
}
181212

182213
return (
183-
<Container className={styles.cp_dashboard_container}>
184-
<header className={styles.cp_dashboard_header}>
214+
<Container className={styles.dashboardContainer}>
215+
<header className={`${styles.dashboardHeader} ${darkMode ? styles.darkHeader : ''}`}>
185216
<h1>All Events</h1>
186217
<div>
187-
<div className={styles.cp_dashboard_search_container}>
218+
<div className={styles.dashboardSearchContainer}>
188219
<Input
189220
id="search"
190221
type="search"
@@ -265,11 +296,24 @@ export function CPDashboard() {
265296
</FormGroup>
266297
</div>
267298
<div className={styles.dashboardActions}>
268-
<Button color="primary" onClick={() => setDateFilter('')}>
299+
<Button
300+
color="primary"
301+
onClick={() => {
302+
setDateFilter('');
303+
setSelectedDate('');
304+
}}
305+
>
269306
Clear date filter
270307
</Button>
271308
</div>
272-
<Input type="date" placeholder="Ending After" className={styles['date-filter']} />
309+
<Input
310+
type="date"
311+
placeholder="Select Date"
312+
className={styles.dateFilter}
313+
value={selectedDate}
314+
onChange={e => setSelectedDate(e.target.value)}
315+
style={{ marginTop: '10px' }}
316+
/>
273317
</div>
274318

275319
<div className={styles.filterItem}>
@@ -316,7 +360,11 @@ export function CPDashboard() {
316360
<h2 className={styles.sectionTitle}>Events</h2>
317361

318362
<Row>
319-
{displayedEvents.length > 0 ? (
363+
{isLoading ? (
364+
<div className={styles.noEvents}>Loading events...</div>
365+
) : error ? (
366+
<div className={styles.noEvents}>{error}</div>
367+
) : displayedEvents.length > 0 ? (
320368
displayedEvents.map(event => (
321369
<Col md={4} key={event.id} className={styles.eventCardCol}>
322370
<Card className={styles.eventCard}>
@@ -330,13 +378,15 @@ export function CPDashboard() {
330378
<CardBody>
331379
<h5 className={styles.eventTitle}>{event.title}</h5>
332380
<p className={styles.eventDate}>
333-
<FaCalendarAlt /> {formatDate(event.date)}
381+
<FaCalendarAlt className={styles.eventIcon} /> {formatDate(event.date)}
334382
</p>
335383
<p className={styles.eventLocation}>
336-
<FaMapMarkerAlt /> {event.location}
384+
<FaMapMarkerAlt className={styles.eventIcon} />{' '}
385+
{event.location || 'Location TBD'}
337386
</p>
338387
<p className={styles.eventOrganizer}>
339-
<FaUserAlt /> {event.organizer}
388+
<FaUserAlt className={styles.eventIcon} />{' '}
389+
{event.organizer || 'Organizer TBD'}
340390
</p>
341391
</CardBody>
342392
</Card>

0 commit comments

Comments
 (0)