2
0
Files
bot/packages/schemas/features/blocks/inputs/rating.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-06-07 19:09:08 +02:00
import { z } from 'zod'
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
import { defaultButtonLabel } from './constants'
import { InputBlockType } from './enums'
2022-06-07 19:09:08 +02:00
export const defaultRatingInputOptions: RatingInputOptions = {
buttonType: 'Numbers',
length: 10,
labels: { button: defaultButtonLabel },
customIcon: { isEnabled: false },
}
export const ratingInputOptionsSchema = optionBaseSchema.merge(
2022-06-07 19:09:08 +02:00
z.object({
buttonType: z.literal('Icons').or(z.literal('Numbers')),
length: z.number(),
labels: z.object({
left: z.string().optional(),
right: z.string().optional(),
button: z.string(),
}),
customIcon: z.object({
isEnabled: z.boolean(),
svg: z.string().optional(),
}),
isOneClickSubmitEnabled: z.boolean().optional(),
2022-06-07 19:09:08 +02:00
})
)
export const ratingInputBlockSchema = blockBaseSchema.merge(
2022-06-07 19:09:08 +02:00
z.object({
2022-06-11 07:27:38 +02:00
type: z.literal(InputBlockType.RATING),
2022-06-07 19:09:08 +02:00
options: ratingInputOptionsSchema,
})
)
2022-06-11 07:27:38 +02:00
export type RatingInputBlock = z.infer<typeof ratingInputBlockSchema>
2022-06-07 19:09:08 +02:00
export type RatingInputOptions = z.infer<typeof ratingInputOptionsSchema>