Skip to content

Instantly share code, notes, and snippets.

@vojtaholik
Last active February 10, 2025 11:28
Show Gist options
  • Save vojtaholik/0965d2d7eca895925813b2f52897386f to your computer and use it in GitHub Desktop.
Save vojtaholik/0965d2d7eca895925813b2f52897386f to your computer and use it in GitHub Desktop.
export const cohortProductFieldsSchema = z.object({
// Defaults
body: z.string().nullable().optional(),
description: z.string().optional(),
slug: z.string(),
state: ResourceStateSchema.default('draft'),
visibility: ResourceVisibilitySchema.default('unlisted'),
type: z.literal('live'),
// Cohort Details
startsAt: z.string().datetime().optional(),
endsAt: z.string().datetime().optional(),
maxParticipants: z.number().default(-1), // might not need this since Products already have quantityAvailable
// Schedule
schedule: z.array(z.object({
startsAt: z.string().datetime(),
endsAt: z.string().datetime(),
title: z.string(),
description: z.string().optional(),
})).nullish(),
// Access & Features
communityAccess: z.boolean().default(true),
hasLiveQA: z.boolean().default(true),
hasPeerWork: z.boolean().default(false),
hasOfficeHours: z.boolean().default(false),
// Communication
communicationChannels: z.array(z.enum(['email', 'discord', 'slack'])).default(['email', 'discord']),
timezone: z.string().default('America/Los_Angeles'),
// Instructors
instructors: z.array(z.object({
userId: z.string(),
role: z.enum(['lead', 'assistant', 'guest']),
bio: z.string().optional()
})).optional(),
// Waitlist
waitlistEnabled: z.boolean().default(false),
waitlistSize: z.number().default(-1),
})
export type CohortProductFields = z.infer<typeof cohortProductFieldsSchema>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment