Added post component for events

This needs RLS disabled, will work on that later, I don't like postgre
This commit is contained in:
Alexis
2024-06-01 11:07:07 +02:00
parent f2d5277c5f
commit a92edd6215
12 changed files with 474 additions and 100 deletions

View File

@@ -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