-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(date_manipulation): add option to filter products by dates vulne…
…rable to date manipulation (#320)
- Loading branch information
Showing
17 changed files
with
317 additions
and
111 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { useState } from 'react'; | ||
import DatePicker from 'react-datepicker'; | ||
import 'react-datepicker/dist/react-datepicker.css'; | ||
|
||
interface DateRangePickerProps { | ||
onDatesChange: (dateFrom: Date, dateTo: Date) => void; | ||
} | ||
|
||
const DateRangePicker: React.FC<DateRangePickerProps> = ({ onDatesChange }) => { | ||
const [dates, setDates] = useState<{ | ||
dateFrom: Date; | ||
dateTo: Date; | ||
}>({ | ||
dateFrom: new Date(new Date().setFullYear(new Date().getFullYear() - 1)), | ||
dateTo: new Date() | ||
}); | ||
|
||
const handleDateFromChange = (date: Date) => { | ||
setDates({ dateFrom: date, dateTo: dates.dateTo }); | ||
onDatesChange(dates.dateFrom, dates.dateTo); | ||
}; | ||
const handleDateToChange = (date: Date) => { | ||
setDates({ dateFrom: dates.dateFrom, dateTo: date }); | ||
onDatesChange(dates.dateFrom, dates.dateTo); | ||
}; | ||
|
||
return ( | ||
<div className="col-lg-12 d-flex justify-content-center"> | ||
<div className="input-group" style={{ width: '130px' }}> | ||
<DatePicker | ||
selected={dates.dateFrom} | ||
onChange={handleDateFromChange} | ||
selectsStart | ||
dateFormat="yyyy-MM-dd" | ||
className="form-control" | ||
placeholderText="Date From" | ||
excludeDateIntervals={[ | ||
{ start: dates.dateTo, end: new Date('02-05-2100') } | ||
]} | ||
isClearable={false} | ||
closeOnScroll={true} | ||
/> | ||
</div> | ||
<p style={{ padding: '8px' }}>-</p> | ||
<div className="input-group" style={{ width: '130px' }}> | ||
<DatePicker | ||
selected={dates.dateTo} | ||
onChange={handleDateToChange} | ||
selectsEnd | ||
dateFormat="yyyy-MM-dd" | ||
className="form-control" | ||
placeholderText="Date To" | ||
excludeDateIntervals={[ | ||
{ start: new Date('02-05-1970'), end: dates.dateFrom } | ||
]} | ||
isClearable={false} | ||
closeOnScroll={true} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DateRangePicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.