Lots of UI fixes
This commit is contained in:
parent
1f7a0f40c0
commit
e8e3b84276
24 changed files with 3652 additions and 1770 deletions
62
server/api/admin/series.put.js
Normal file
62
server/api/admin/series.put.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import Series from '../../models/series.js'
|
||||
import Event from '../../models/event.js'
|
||||
import { connectDB } from '../../utils/mongoose.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
await connectDB()
|
||||
|
||||
const body = await readBody(event)
|
||||
const { id, title, description, type, totalEvents } = body
|
||||
|
||||
if (!id || !title) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'Series ID and title are required'
|
||||
})
|
||||
}
|
||||
|
||||
// Update the series record
|
||||
const updatedSeries = await Series.findOneAndUpdate(
|
||||
{ id },
|
||||
{
|
||||
title,
|
||||
description,
|
||||
type,
|
||||
totalEvents: totalEvents || null
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
|
||||
if (!updatedSeries) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: 'Series not found'
|
||||
})
|
||||
}
|
||||
|
||||
// Update all events in this series with the new metadata
|
||||
await Event.updateMany(
|
||||
{
|
||||
'series.id': id,
|
||||
'series.isSeriesEvent': true
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
'series.title': title,
|
||||
'series.description': description,
|
||||
'series.type': type,
|
||||
'series.totalEvents': totalEvents || null
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return updatedSeries
|
||||
} catch (error) {
|
||||
console.error('Error updating series:', error)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: 'Failed to update series'
|
||||
})
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue