mirror of
https://github.com/ArthurDanjou/arthome.git
synced 2026-01-14 12:14:33 +01:00
29 lines
682 B
TypeScript
29 lines
682 B
TypeScript
import { useValidatedBody } from 'h3-zod'
|
|
import { UpdateTabSchema } from '~~/types/types'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
const { id } = await getRouterParams(event)
|
|
const body = await useValidatedBody(event, UpdateTabSchema)
|
|
await useDrizzle()
|
|
.update(tables.tabs)
|
|
.set({
|
|
name: body.name,
|
|
icon: body.icon,
|
|
color: body.color,
|
|
primary: body.primary,
|
|
link: body.link,
|
|
})
|
|
.where(
|
|
and(
|
|
eq(tables.tabs.id, id),
|
|
eq(tables.tabs.categoryId, body.categoryId),
|
|
),
|
|
)
|
|
return { statusCode: 200 }
|
|
}
|
|
catch (err) {
|
|
return { err }
|
|
}
|
|
})
|