Skip to content

Commit 2cedfb4

Browse files
Merge pull request #4428 from OneCommunityGlobal/som-fix/ending-after-figma-mismatch
Som - fix(DatePicker): add "Ending After" date picker to search filters in CPDashboard.jsx
2 parents 88691bc + 85afae1 commit 2cedfb4

2 files changed

Lines changed: 84 additions & 24 deletions

File tree

src/components/CommunityPortal/CPDashboard.jsx

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import {
1515
import { FaCalendarAlt, FaMapMarkerAlt, FaUserAlt, FaSearch, FaTimes } from 'react-icons/fa';
1616
import styles from './CPDashboard.module.css';
1717
import { ENDPOINTS } from '../../utils/URL';
18+
import DatePicker from 'react-datepicker';
19+
import 'react-datepicker/dist/react-datepicker.css';
20+
import { toast } from 'react-toastify';
1821
import axios from 'axios';
1922
import { el } from 'date-fns/locale';
2023
import { fuzzySearch } from '../../utils/fuzzySearch';
@@ -92,6 +95,18 @@ export function CPDashboard() {
9295
limit: 6,
9396
});
9497

98+
const handleDateChange = date => {
99+
const today = new Date();
100+
today.setHours(0, 0, 0, 0); // midnight today
101+
102+
if (date < today) {
103+
toast.error('Past dates are not supported. Please select a future date.');
104+
setSelectedDate('');
105+
return;
106+
}
107+
setSelectedDate(date);
108+
};
109+
95110
const FALLBACK_IMG =
96111
'https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=600&q=60';
97112

@@ -410,26 +425,31 @@ export function CPDashboard() {
410425
</Label>
411426
</FormGroup>
412427
</div>
413-
414-
<Button
415-
color="primary"
416-
size="sm"
417-
onClick={() => {
418-
setDateFilter('');
419-
setSelectedDate('');
420-
}}
421-
>
422-
Clear date filter
423-
</Button>
424-
425-
<Input
426-
type="date"
427-
placeholder="Select Date"
428-
className={styles.dateFilter}
429-
value={selectedDate}
430-
onChange={e => setSelectedDate(e.target.value)}
431-
style={{ marginTop: '10px' }}
432-
/>
428+
<div className={styles.dashboardActions}>
429+
<Button
430+
color="primary"
431+
onClick={() => {
432+
setDateFilter('');
433+
setSelectedDate('');
434+
}}
435+
>
436+
Clear date filter
437+
</Button>
438+
</div>
439+
<div className={styles.filterItem}>
440+
<div className={styles.dateFilterContainer}>
441+
<DatePicker
442+
type="date"
443+
selected={selectedDate ? new Date(selectedDate) : null}
444+
onChange={handleDateChange}
445+
placeholderText="Ending After"
446+
id="ending-after"
447+
className={styles.dateFilter}
448+
dateFormat="yyyy-MM-dd"
449+
isClearable
450+
/>
451+
</div>
452+
</div>
433453
</div>
434454

435455
<div className={styles.filterItem}>

src/components/CommunityPortal/CPDashboard.module.css

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,6 @@
253253
margin-bottom: 8px;
254254
}
255255

256-
.dateFilter {
257-
margin-top: 10px;
258-
}
259-
260256
.dateFilter:focus {
261257
border-color: #2c3e50;
262258
box-shadow: 0 0 5px rgba(44, 62, 80, 0.4);
@@ -396,6 +392,50 @@
396392
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
397393
}
398394

395+
.dateFilter {
396+
padding-left: 10px;
397+
margin-top: 15px;
398+
padding-top: 0px;
399+
padding-bottom: 0px;
400+
}
401+
402+
.dateFilterContainer {
403+
display: flex;
404+
justify-content: center;
405+
align-items: center;
406+
padding: 6px 10px 20px;
407+
}
408+
.dateFilterContainer :global(.react-datepicker-wrapper) input {
409+
border: 2px solid #1b3c55;
410+
border-radius: 8px;
411+
padding: 8px 12px;
412+
width: 100%;
413+
outline: none;
414+
font-size: 1rem;
415+
transition: all 0.3s ease;
416+
}
417+
418+
.darkSidebar :global(.react-datepicker__input-container input) {
419+
background-color: #000000 !important;
420+
color: #ffffff !important;
421+
border: 2px solid #4da3ff !important;
422+
}
423+
424+
.darkSidebar :global(.react-datepicker__input-container input::placeholder) {
425+
color: #ffffff !important;
426+
}
427+
428+
.dateFilterContainer :global(.react-datepicker-wrapper) input:focus {
429+
border-color: #34495e;
430+
box-shadow: 0 0 5px rgba(44, 62, 80, 0.4);
431+
}
432+
433+
.dateErrorMessage {
434+
color: red;
435+
margin-top: 5px;
436+
}
437+
438+
399439
.paginationContainer {
400440
margin-top: 20px;
401441
display: flex;

0 commit comments

Comments
 (0)