Added post component for events
This needs RLS disabled, will work on that later, I don't like postgre
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import type { Category } from './Category'
|
||||
import type { RPGDate } from './Date'
|
||||
import { dateSchema, type RPGDate } from './Date'
|
||||
|
||||
export interface CalendarEvent {
|
||||
id: number
|
||||
id?: number
|
||||
title: string
|
||||
startDate: RPGDate
|
||||
endDate?: RPGDate
|
||||
@@ -13,6 +14,19 @@ export interface CalendarEvent {
|
||||
wiki?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Body validation schema for post requests (insert and update)
|
||||
*/
|
||||
export const postEventBodySchema = z.object({
|
||||
event: z.object({
|
||||
title: z.string(),
|
||||
description: z.string().optional(),
|
||||
startDate: dateSchema.required(),
|
||||
endDate: dateSchema.optional()
|
||||
}),
|
||||
calendarId: z.number().int().positive()
|
||||
})
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function isCalendarEvent(object: any): object is CalendarEvent {
|
||||
return 'startDate' in object
|
||||
|
||||
Reference in New Issue
Block a user