feat: event editing, light/dark theme, device animations, 7-day forecast
Some checks failed
Deploy / deploy (push) Has been cancelled
Some checks failed
Deploy / deploy (push) Has been cancelled
This commit is contained in:
@@ -155,6 +155,54 @@ export async function POST(req: Request) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function PUT(req: Request) {
|
||||
const body = await req.json()
|
||||
const { eventId, title, date, startTime, endTime, allDay, calendarId } = body
|
||||
|
||||
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 })
|
||||
|
||||
let start: any, end: any
|
||||
if (allDay) {
|
||||
start = { date }
|
||||
end = { date }
|
||||
} else {
|
||||
start = { dateTime: , timeZone: 'Europe/Moscow' }
|
||||
end = { dateTime: , timeZone: 'Europe/Moscow' }
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await calendarClient.events.patch({
|
||||
calendarId: targetCalendarId,
|
||||
eventId,
|
||||
requestBody: {
|
||||
summary: title,
|
||||
start,
|
||||
end,
|
||||
},
|
||||
})
|
||||
const e = res.data
|
||||
return NextResponse.json({
|
||||
event: {
|
||||
id: e.id,
|
||||
title: e.summary || title,
|
||||
start: e.start?.dateTime || e.start?.date,
|
||||
end: e.end?.dateTime || e.end?.date,
|
||||
allDay: !e.start?.dateTime,
|
||||
}
|
||||
})
|
||||
} catch (err: any) {
|
||||
return NextResponse.json({ error: err.message || 'Failed to update event' }, { status: 500 })
|
||||
}
|
||||
}
|
||||
export async function DELETE(req: Request) {
|
||||
const { searchParams } = new URL(req.url)
|
||||
const eventId = searchParams.get('eventId')
|
||||
|
||||
Reference in New Issue
Block a user