Skip to content

Commit 2513b56

Browse files
committed
Changing calname and response format
1 parent 7992251 commit 2513b56

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/api/ics/[id]/ics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const getAbsenceEvents = async (): Promise<EventAttributes[]> => {
2929
title: `${absence.subject.name}: ${absence.absentTeacher.firstName} ${absence.absentTeacher.lastName[0]}${substituteTeacherString}`,
3030
description: `Subject: ${absence.subject.name}\nLesson Plan: ${lessonString}${notesLine}`,
3131
location: absence.location.name,
32+
calName: 'Sistema Absences',
3233
};
3334
});
3435
} catch (err) {

app/api/ics/[id]/route.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,16 @@ export async function GET(
2424
return NextResponse.json({ error: 'File not found' }, { status: 404 });
2525
}
2626

27-
return new Response(icsFile, {
28-
headers: { 'Content-Type': 'text/calendar' },
27+
// convert file to response
28+
const buffer = await icsFile.arrayBuffer();
29+
const blob = new Blob([buffer], { type: 'text/calendar' });
30+
31+
return new Response(blob, {
32+
status: 200,
33+
headers: {
34+
'Content-Type': 'text/calendar',
35+
'Content-Disposition': `attachment; filename=${id}`,
36+
},
2937
});
3038
} catch (error) {
3139
console.error('Error fetching ICS file:', error);

0 commit comments

Comments
 (0)