[#30] Load data for the current month
This commit is contained in:
@@ -14,7 +14,12 @@ export async function getCalendars(userId: string, opaque_token: string) {
|
||||
return calendars;
|
||||
}
|
||||
|
||||
export async function getCalendar(id: string, opaque_token: string) {
|
||||
export async function getCalendar(
|
||||
id: string,
|
||||
opaque_token: string,
|
||||
match: { start: string; end: string }
|
||||
) {
|
||||
console.log(match)
|
||||
const response = await fetch(
|
||||
`${(window as any).CALENDAR_BASE_URL}/dav/calendars/${id}.json`,
|
||||
{
|
||||
@@ -24,7 +29,7 @@ export async function getCalendar(id: string, opaque_token: string) {
|
||||
Authorization: `Bearer ${opaque_token}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
match: { start: "20250525T000000", end: "20250708T000000" },
|
||||
match,
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -32,9 +32,9 @@ export const getCalendarsListAsync = createAsyncThunk<
|
||||
|
||||
export const getCalendarDetailAsync = createAsyncThunk<
|
||||
{ calId: string; events: CalendarEvent[] }, // Return type
|
||||
{ access_token: string; calId: string } // Arg type
|
||||
>("calendars/getCalendarDetails", async ({ access_token, calId }) => {
|
||||
const calendar = await getCalendar(calId, access_token);
|
||||
{ access_token: string; calId: string; match: { start: string; end: string } } // Arg type
|
||||
>("calendars/getCalendarDetails", async ({ access_token, calId, match }) => {
|
||||
const calendar = await getCalendar(calId, access_token, match);
|
||||
const color = calendar["apple:color"];
|
||||
const events: CalendarEvent[] = calendar._embedded["dav:item"].map(
|
||||
(eventdata: any) => {
|
||||
@@ -104,7 +104,9 @@ const CalendarSlice = createSlice({
|
||||
events: [] as CalendarEvent[],
|
||||
} as Calendars;
|
||||
}
|
||||
state.list[action.payload.calId].events = action.payload.events;
|
||||
action.payload.events.forEach((event) => {
|
||||
state.list[action.payload.calId].events.push(event);
|
||||
});
|
||||
state.list[action.payload.calId].events.forEach((event) => {
|
||||
event.color = state.list[action.payload.calId].color;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user