FMHY-Website/website/types/Feedback.ts
taskylizard 16bf6230c0
k
2025-06-27 22:54:07 +00:00

35 lines
834 B
TypeScript

import z from 'zod'
export const FeedbackSchema = z.object({
message: z.string().min(5).max(1000),
type: z.enum(['suggestion', 'appreciation', 'other']),
page: z.string().min(3).max(20),
// For heading based feedback
heading: z.string().min(3).max(20).optional()
})
export interface Option {
label: string
value: FeedbackType['type']
}
export const feedbackOptions: Option[] = [
{
label: '💡 I have a suggestion',
value: 'suggestion'
},
{
label: '👍 I appreciate the work',
value: 'appreciation'
},
{ label: '📂 Something else', value: 'other' }
]
export function getFeedbackOption(
value: FeedbackType['type']
): Option | undefined {
return feedbackOptions.find((option) => option.value === value)
}
// prettier-ignore
export type FeedbackType = z.infer<typeof FeedbackSchema>;