Skip to content

Commit

Permalink
fixing startMonth
Browse files Browse the repository at this point in the history
  • Loading branch information
shivbang committed Nov 22, 2023
1 parent 0b6442a commit df583bd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/DatePicker/DatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ export const DatePicker = ({
}) => {
const initialValue = value ? (variant === variants.single ? value : value.from) : null;
const [currentMonth, setCurrentMonth] = useState(initialValue ?? dayjs().toDate());
const [startMonth, setStartMonth] = useState(value?.from);
const [startMonth, setStartMonth] = useState(() => {
if (!value || !value.from) {
return new Date();
}

return value.from;
});
const [endMonth, setEndMonth] = useState(() => {
if (!value || !value.to || !value.from) {
return new Date();
return dayjs(new Date()).add(1, "month").toDate();
}

return dayjs(value.to).isSame(dayjs(value.from), "month")
Expand Down

0 comments on commit df583bd

Please sign in to comment.