redesign calendar api for improving loading performance

This commit is contained in:
isUnknown 2024-09-11 16:34:58 +02:00
parent 78d542cbac
commit d2b2cea846
5 changed files with 76 additions and 99 deletions

View file

@ -149,18 +149,14 @@ function getId(eventData) {
function createEmptyCalendar() {
const calendar = {};
for (let month = 9; month < 19; month++) {
for (let month = 9; month < 21; month++) {
const normalizedMonth = ((month - 1) % 12) + 1;
const daysInMonth = dayjs()
.month(normalizedMonth - 1)
.daysInMonth();
calendar[normalizedMonth] = {
name: dayjs()
.month(normalizedMonth - 1)
.format("MMMM"),
};
calendar[normalizedMonth] = {};
for (let day = 1; day <= daysInMonth; day++) {
calendar[normalizedMonth][day] = null;
@ -170,7 +166,7 @@ function createEmptyCalendar() {
return calendar;
}
async function getMergedDates(monthNumb, dates) {
async function getCurrentSeasonCalendar(monthNumb, dates) {
const calendar = createEmptyCalendar();
const requestParams = {
@ -187,7 +183,6 @@ async function getMergedDates(monthNumb, dates) {
requestOptions
);
const json = await response.json();
console.log("calendar", json);
return json;
}