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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export interface RPGDate {
|
||||
day: number
|
||||
month: number
|
||||
@@ -6,23 +8,8 @@ export interface RPGDate {
|
||||
|
||||
export type RPGDateOrder = 'asc' | 'desc'
|
||||
|
||||
// export function getRelativeDate(baseDate: RPGDate, relativeDate: RPGDate) {
|
||||
// let newDay: number
|
||||
// let newMonth: number
|
||||
// let newYear: number
|
||||
// let newPeriod: RPGPeriod
|
||||
|
||||
// const differenceInDays = getDifferenceInDays(baseDate, relativeDate)
|
||||
|
||||
// // console.log(baseDate, substractionDate)
|
||||
// console.log(getRelativeString(baseDate, relativeDate))
|
||||
|
||||
// return differenceInDays
|
||||
|
||||
// // return {
|
||||
// // day: newDay,
|
||||
// // month: newMonth,
|
||||
// // year: newYear,
|
||||
// // period: newPeriod
|
||||
// // }
|
||||
// }
|
||||
export const dateSchema = z.object({
|
||||
day: z.number().int().positive(),
|
||||
month: z.number().int(),
|
||||
year: z.number().int()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user