@@ -3,11 +3,15 @@ import { Container, Row, Col, Card, CardBody, Button, Input } from 'reactstrap';
33import styles from './CPDashboard.module.css' ;
44import { FaCalendarAlt , FaMapMarkerAlt , FaUserAlt } from 'react-icons/fa' ;
55import { ENDPOINTS } from '../../utils/URL' ;
6+ import DatePicker from 'react-datepicker' ;
7+ import 'react-datepicker/dist/react-datepicker.css' ;
68import axios from 'axios' ;
79
810export function CPDashboard ( ) {
911 const [ events , setEvents ] = useState ( [ ] ) ;
1012 const [ search , setSearch ] = useState ( '' ) ;
13+ const [ selectedDate , setSelectedDate ] = useState ( '' ) ;
14+ const [ dateError , setDateError ] = useState ( '' ) ;
1115 const [ isLoading , setIsLoading ] = useState ( false ) ;
1216 const [ error , setError ] = useState ( null ) ;
1317 const [ pagination , setPagination ] = useState ( {
@@ -17,6 +21,19 @@ export function CPDashboard() {
1721 limit : 6 ,
1822 } ) ;
1923
24+ const handleDateChange = date => {
25+ const today = new Date ( ) ;
26+ today . setHours ( 0 , 0 , 0 , 0 ) ; // midnight today
27+
28+ if ( date < today ) {
29+ toast . error ( 'Past dates are not supported. Please select a future date.' ) ;
30+ setSelectedDate ( '' ) ;
31+ return ;
32+ }
33+ setDateError ( '' ) ;
34+ setSelectedDate ( date ) ;
35+ } ;
36+
2037 const FALLBACK_IMG =
2138 'https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=600&q=60' ;
2239
@@ -120,7 +137,22 @@ export function CPDashboard() {
120137 < Input type = "radio" name = "dates" /> This Weekend
121138 </ div >
122139 </ div >
123- < Input type = "date" placeholder = "Ending After" className = { styles [ 'date-filter' ] } />
140+ { /* <Input type="date" placeholder="Ending After" className={styles['date-filter']} /> */ }
141+ < div style = { { width : '100%' } } >
142+ < DatePicker
143+ selected = { selectedDate }
144+ onChange = { date => handleDateChange ( date ) }
145+ placeholderText = "Ending After"
146+ id = "ending-after"
147+ className = { styles [ 'date-filter' ] }
148+ style = { { width : '100%' } }
149+ />
150+ { dateError && (
151+ < p className = "date-error-message" style = { { color : 'red' , marginTop : '5px' } } >
152+ { dateError }
153+ </ p >
154+ ) }
155+ </ div >
124156 </ div >
125157 < div className = { styles [ 'filter-item' ] } >
126158 < label htmlFor = "online-only" > Online</ label >
0 commit comments