docs/.vitepress/types/Feedback.ts

490d6e4b5ce773e89f3504db30dbc9ba656d4c8e
wotaku/docs/.vitepress/types/Feedback.ts history · blame · raw

58 lines · 1542 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: '➕ Submit link',
34    value: "suggestion"
35  },
36    {
37    label: '❌ Report bad / dead link',
38    value: "suggestion"
39  },
40  {
41    label: '💡 Suggest edit',
42    value: 'suggestion'
43  },
44  {
45    label: '❤️ Love the wiki',
46    value: 'appreciation'
47  },
48  { label: '💬 Something else', 
49    value: 'other' }
50]
51
52export function getFeedbackOption(
53  value: FeedbackType['type']
54): Option | undefined {
55  return feedbackOptions.find((option) => option.value === value)
56}
57
58export type FeedbackType = z.infer<typeof FeedbackSchema>