2022-06-07 08:49:12 +02:00
|
|
|
import { z } from 'zod'
|
|
|
|
import {
|
|
|
|
defaultButtonLabel,
|
2022-06-11 07:27:38 +02:00
|
|
|
InputBlockType,
|
2022-06-07 08:49:12 +02:00
|
|
|
optionBaseSchema,
|
2022-06-11 07:27:38 +02:00
|
|
|
blockBaseSchema,
|
2022-06-07 08:49:12 +02:00
|
|
|
} from '../shared'
|
|
|
|
import { textInputOptionsBaseSchema } from './text'
|
|
|
|
|
|
|
|
export const emailInputOptionsSchema = optionBaseSchema
|
|
|
|
.and(textInputOptionsBaseSchema)
|
|
|
|
.and(
|
|
|
|
z.object({
|
2022-12-22 17:02:34 +01:00
|
|
|
// TODO: make it required once database migration is done
|
|
|
|
retryMessageContent: z.string().optional(),
|
2022-06-07 08:49:12 +02:00
|
|
|
})
|
|
|
|
)
|
|
|
|
|
2022-06-11 07:27:38 +02:00
|
|
|
export const emailInputSchema = blockBaseSchema.and(
|
2022-06-07 08:49:12 +02:00
|
|
|
z.object({
|
2022-06-11 07:27:38 +02:00
|
|
|
type: z.enum([InputBlockType.EMAIL]),
|
2022-06-07 08:49:12 +02:00
|
|
|
options: emailInputOptionsSchema,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
export const defaultEmailInputOptions: EmailInputOptions = {
|
|
|
|
labels: {
|
|
|
|
button: defaultButtonLabel,
|
|
|
|
placeholder: 'Type your email...',
|
|
|
|
},
|
|
|
|
retryMessageContent:
|
|
|
|
"This email doesn't seem to be valid. Can you type it again?",
|
|
|
|
}
|
|
|
|
|
2022-06-11 07:27:38 +02:00
|
|
|
export type EmailInputBlock = z.infer<typeof emailInputSchema>
|
2022-06-07 08:49:12 +02:00
|
|
|
export type EmailInputOptions = z.infer<typeof emailInputOptionsSchema>
|