feat: add calendar event deletion with confirmation
All checks were successful
Deploy / deploy (push) Successful in 4m37s
All checks were successful
Deploy / deploy (push) Successful in 4m37s
This commit is contained in:
@@ -145,3 +145,31 @@ export async function POST(req: Request) {
|
||||
return NextResponse.json({ error: err.message || 'Failed to create event' }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(req: Request) {
|
||||
const { searchParams } = new URL(req.url)
|
||||
const eventId = searchParams.get('eventId')
|
||||
const calendarId = searchParams.get('calendarId')
|
||||
|
||||
if (!eventId) {
|
||||
return NextResponse.json({ error: 'eventId is required' }, { status: 400 })
|
||||
}
|
||||
|
||||
const auth = getAuth(false)
|
||||
if (!auth) {
|
||||
return NextResponse.json({ error: 'not_configured' }, { status: 500 })
|
||||
}
|
||||
|
||||
const targetCalendarId = calendarId || process.env.DANIIL_CALENDAR_ID || 'daniilklimov25@gmail.com'
|
||||
const calendarClient = google.calendar({ version: 'v3', auth: auth as any })
|
||||
|
||||
try {
|
||||
await calendarClient.events.delete({
|
||||
calendarId: targetCalendarId,
|
||||
eventId,
|
||||
})
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (err: any) {
|
||||
return NextResponse.json({ error: err.message || 'Failed to delete event' }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user