Loading state dusccefully added.

This commit is contained in:
Lucid Kobold
2022-06-20 19:24:25 -05:00
parent 099c71876b
commit 181c399899
6 changed files with 43 additions and 42 deletions

View File

@@ -5,6 +5,7 @@ import populate from "../../../lib/populateMonth";
interface CalenderSlice {
currDate: string;
selectedDateInfo: SelectedDateInfo;
isLoading: boolean;
}
const getCurrDate = (): Date => new Date();
@@ -17,7 +18,8 @@ const initialState: CalenderSlice = {
date: dateParse(getCurrDate()),
title: dateFormatter(getCurrDate()),
layout: populate(getCurrDate())
}
},
isLoading: true
};
// TODO: Add a function that validated if a month has at least one sticker in it. Use that within the nav function (when filter is enabled).
@@ -50,9 +52,15 @@ const calenderSlice = createSlice({
// Update current date
updateCurrDate(state: CalenderSlice) {
state.currDate = dateParse(new Date());
},
// Update isLoading
updateLoading(state: CalenderSlice, action: PayloadAction<boolean>) {
const { payload } = action;
state.isLoading = payload;
}
}
});
export const { updateMonth, updateCurrDate } = calenderSlice.actions;
export const { updateMonth, updateCurrDate, updateLoading } =
calenderSlice.actions;
export default calenderSlice.reducer;