docs/.vitepress/types/Feedback.ts

5f20afcddd9bf446affeb450596a58cc0fe7e4ca
wotaku/docs/.vitepress/types/Feedback.ts history · blame · raw

70 lines · 1520 bytes

 1/**
 2 *  All Rights Reserved
 3 *
 4 *  Copyright (c) 2025 taskylizard
 5 *
 6 *  All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
 7 */
 8import z from 'zod'
 9
10export const FeedbackSchema = z.object({
11  message: z.string().min(5).max(1000),
12  type: z.enum([
13    'submit',
14    'update',
15    'report',
16    'suggestion',
17    'appreciation',
18    'other'
19  ]),
20  page: z.string().url(),
21  // For heading based feedback
22  heading: z.string().min(3).max(20).optional()
23})
24
25export interface Option {
26  label: string
27  icon: string
28  value: FeedbackType['type']
29}
30
31export const feedbackOptions: Option[] = [
32  {
33    label: 'Submit link',
34    icon: 'i-lucide:circle-plus',
35    value: 'submit'
36  },
37  {
38    label: 'Update link',
39    icon: 'i-lucide:circle-alert',
40    value: 'update'
41  },
42  {
43    label: 'Report bad / dead link',
44    icon: 'i-lucide:circle-x',
45    value: 'report'
46  },
47  {
48    label: 'Suggest edit',
49    icon: 'i-lucide:lightbulb',
50    value: 'suggestion'
51  },
52  {
53    label: 'Love the wiki',
54    icon: 'i-lucide:heart',
55    value: 'appreciation'
56  },
57  {
58    label: 'Something else',
59    icon: 'i-lucide:message-circle',
60    value: 'other'
61  }
62]
63
64export function getFeedbackOption(
65  value: FeedbackType['type']
66): Option | undefined {
67  return feedbackOptions.find((option) => option.value === value)
68}
69
70export type FeedbackType = z.infer<typeof FeedbackSchema>