2022-06-07 08:49:12 +02:00
|
|
|
import { z } from 'zod'
|
2023-01-25 11:27:47 +01:00
|
|
|
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
|
|
|
import { defaultButtonLabel } from './constants'
|
|
|
|
import { InputBlockType } from './enums'
|
2022-06-07 08:49:12 +02:00
|
|
|
import { textInputOptionsBaseSchema } from './text'
|
|
|
|
|
|
|
|
export const emailInputOptionsSchema = optionBaseSchema
|
2023-03-14 16:42:12 +01:00
|
|
|
.merge(textInputOptionsBaseSchema)
|
|
|
|
.merge(
|
2022-06-07 08:49:12 +02:00
|
|
|
z.object({
|
2023-08-17 09:39:11 +02:00
|
|
|
retryMessageContent: z.string().optional(),
|
2022-06-07 08:49:12 +02:00
|
|
|
})
|
|
|
|
)
|
|
|
|
|
2023-03-14 16:42:12 +01:00
|
|
|
export const emailInputSchema = blockBaseSchema.merge(
|
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,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
2023-08-17 09:39:11 +02:00
|
|
|
export const invalidEmailDefaultRetryMessage =
|
|
|
|
"This email doesn't seem to be valid. Can you type it again?"
|
|
|
|
|
2022-06-07 08:49:12 +02:00
|
|
|
export const defaultEmailInputOptions: EmailInputOptions = {
|
|
|
|
labels: {
|
|
|
|
button: defaultButtonLabel,
|
|
|
|
placeholder: 'Type your email...',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
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>
|