docs/.vitepress/types/Feedback.ts
49 lines · 1411 bytes
1/**
2 * Copyright (c) 2024 taskylizard
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import z from 'zod'
17
18export const FeedbackSchema = z.object({
19 message: z.string().min(5).max(1000),
20 type: z.enum(['suggestion', 'appreciation', 'other']),
21 page: z.string().url(),
22 // For heading based feedback
23 heading: z.string().min(3).max(20).optional()
24})
25
26export interface Option {
27 label: string
28 value: FeedbackType['type']
29}
30
31export const feedbackOptions: Option[] = [
32 {
33 label: '💡 I have a suggestion',
34 value: 'suggestion'
35 },
36 {
37 label: '👍 I appreciate the work',
38 value: 'appreciation'
39 },
40 { label: '📂 Something else', value: 'other' }
41]
42
43export function getFeedbackOption(
44 value: FeedbackType['type']
45): Option | undefined {
46 return feedbackOptions.find((option) => option.value === value)
47}
48
49export type FeedbackType = z.infer<typeof FeedbackSchema>