Skip to content

Commit

Permalink
setting the defualt end date a year from now
Browse files Browse the repository at this point in the history
  • Loading branch information
sam9116 committed Feb 3, 2024
1 parent 8f342bc commit b3d31f7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/PickDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ import "react-datepicker/dist/react-datepicker.css";
function PickDate({ updateStartDateInParent, updateEndDateInParent }) {
let cachedStartDate = localStorage.getItem('startDate');
let cachedEndDate = localStorage.getItem('endDate');

const today = new Date();
const oneYearFromNow = new Date(today);
oneYearFromNow.setFullYear(today.getFullYear() + 1);



const [startDate, setStartDate] = useState(cachedStartDate === null ? new Date() : new Date(cachedStartDate));
const [endDate, setEndDate] = useState(cachedEndDate === null ? new Date() : new Date(cachedEndDate));
const [endDate, setEndDate] = useState(cachedEndDate === null ? oneYearFromNow : new Date(cachedEndDate));

// Display spotify token
return (
Expand Down

0 comments on commit b3d31f7

Please sign in to comment.