-
Notifications
You must be signed in to change notification settings - Fork 0
/
activities.ts
95 lines (88 loc) · 3.19 KB
/
activities.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { z } from '@hono/zod-openapi';
export const activitySchema = z.object({
id: z.coerce.number(),
name: z.string().max(50),
description: z.string().max(255).nullable(),
max_participants: z.coerce.number().min(1),
min_participants: z.coerce.number().min(1),
days_of_week: z
.array(z.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']))
.nullable(),
frequency: z.enum(['weekly', 'monthly', 'yearly', 'daily']),
start_date: z.string().date().nullable(),
end_date: z.string().date().nullable(),
start_time: z.string().time().nullable(),
end_time: z.string().time().nullable(),
id_sport: z.coerce.number().nullable(),
id_address: z.coerce.number().nullable(),
});
export const createActivitySchema = z.object({
name: z.string().max(50),
description: z.string().max(255).optional(),
max_participants: z.coerce.number().min(1),
min_participants: z.coerce.number().min(1),
days_of_week: z
.array(z.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']))
.optional(),
frequency: z.enum(['weekly', 'monthly', 'yearly', 'daily']),
start_date: z.string().date().optional(),
end_date: z.string().date().optional(),
start_time: z.string().time().optional(),
end_time: z.string().time().optional(),
id_sport: z.coerce.number().optional(),
id_address: z.coerce.number().optional(),
image: z.instanceof(File),
});
export const activitySchemaReponse = z.object({
id: z.coerce.number(),
name: z.string().max(50),
description: z.string().max(255).nullable(),
max_participants: z.coerce.number().min(1),
min_participants: z.coerce.number().min(1),
days_of_week: z
.array(z.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']))
.nullable(),
frequency: z.enum(['weekly', 'monthly', 'yearly', 'daily']).nullable(),
start_date: z.string().date().nullable(),
end_date: z.string().date().nullable(),
start_time: z.string().time().nullable(),
end_time: z.string().time().nullable(),
id_sport: z.coerce.number().nullable(),
id_address: z.coerce.number().nullable(),
sport: z
.object({
id: z.coerce.number(),
name: z.string().max(50),
})
.nullable(),
});
export const userActivities = z.object({
active: z.boolean(),
created_at: z.string(),
id_user: z.number(),
id_activity: z.number(),
activity: activitySchemaReponse.omit({ sport: true }).nullable(),
});
export const activityExceptionSchema = z.object({
id: z.coerce.number().min(1),
id_activity: z.coerce.number().min(1),
date: z.string().date(),
max_participants: z.coerce.number().min(1).nullable(),
min_participants: z.coerce.number().min(1).nullable(),
});
export const queryActivitiesExceptionSchema = z.object({
start_date: z.string().date(),
end_date: z.string().date(),
all: z.coerce.boolean().optional().default(false),
});
export const activityOccurencesSchema = z.object({
activity: activitySchemaReponse,
occurences: z.array(
z.object({
id_exception: z.coerce.number().min(1).nullable(),
date: z.string().date(),
max_participants: z.coerce.number().min(1).nullable(),
min_participants: z.coerce.number().min(1).nullable(),
}),
),
});