Polish #19
@@ -43,22 +43,18 @@ const CalenderContextProvider = ({
|
|||||||
getDate(endOfMonth(selectedDate))
|
getDate(endOfMonth(selectedDate))
|
||||||
);
|
);
|
||||||
|
|
||||||
const [daysOfMonth, setDaysOfMonth] = useState<[number]>([0]);
|
const [daysOfMonth, setDaysOfMonth] = useState<[number]>([1]);
|
||||||
|
|
||||||
// Update or populate the days of the month.
|
// Update or populate the days of the month.
|
||||||
const populateDays = (): void => {
|
const populateDays = (): void => {
|
||||||
let newDaysOfMonth: [number] = [...daysOfMonth];
|
let newDaysOfMonth: [number] = [...daysOfMonth];
|
||||||
|
|
||||||
if (newDaysOfMonth.length > 1) {
|
if (newDaysOfMonth.length > 1) {
|
||||||
newDaysOfMonth = [0];
|
newDaysOfMonth = [1];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 1; i < endOfSelectedMonth; i++) {
|
for (let i = 1; i < endOfSelectedMonth; i++) {
|
||||||
if (newDaysOfMonth[i - 1] === 0) {
|
newDaysOfMonth.push(i + 1);
|
||||||
newDaysOfMonth[i - 1] = i;
|
|
||||||
} else {
|
|
||||||
newDaysOfMonth.push(i + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setDaysOfMonth(newDaysOfMonth);
|
setDaysOfMonth(newDaysOfMonth);
|
||||||
|
|||||||
Reference in New Issue
Block a user