betterstart-cli 0.0.91 → 0.0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "betterstart-cli",
3
- "version": "0.0.91",
3
+ "version": "0.0.93",
4
4
  "description": "A production ready dashboard,
tailored for you in 5 Minutes.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,128 +0,0 @@
1
- 'use client'
2
-
3
- import { upsertFormSettings } from '@admin/actions/forms'
4
- import { Button } from '@admin/components/ui/button'
5
- import {
6
- Dialog,
7
- DialogBody,
8
- DialogContent,
9
- DialogDescription,
10
- DialogFooter,
11
- DialogHeader,
12
- DialogTitle
13
- } from '@admin/components/ui/dialog'
14
- import {
15
- Form,
16
- FormControl,
17
- FormDescription,
18
- FormField,
19
- FormItem,
20
- FormLabel,
21
- FormMessage
22
- } from '@admin/components/ui/form'
23
- import { Textarea } from '@admin/components/ui/textarea'
24
- import { standardSchemaResolver } from '@hookform/resolvers/standard-schema'
25
- import { useMutation, useQueryClient } from '@tanstack/react-query'
26
- import { LoaderCircle } from 'lucide-react'
27
- import { useForm } from 'react-hook-form'
28
- import { toast } from 'sonner'
29
- import { z } from 'zod/v3'
30
-
31
- const notificationsSchema = z.object({
32
- notificationEmails: z.string().trim()
33
- })
34
-
35
- type NotificationsFormValues = z.infer<typeof notificationsSchema>
36
-
37
- interface EditFormNotificationsDialogProps {
38
- formLabel: string
39
- settingsKey: string
40
- initialEmails: string
41
- open: boolean
42
- onOpenChange: (open: boolean) => void
43
- }
44
-
45
- export function EditFormNotificationsDialog({
46
- formLabel,
47
- settingsKey,
48
- initialEmails,
49
- open,
50
- onOpenChange
51
- }: EditFormNotificationsDialogProps) {
52
- const queryClient = useQueryClient()
53
-
54
- const form = useForm<NotificationsFormValues>({
55
- resolver: standardSchemaResolver(notificationsSchema),
56
- defaultValues: { notificationEmails: initialEmails }
57
- })
58
-
59
- const mutation = useMutation({
60
- mutationFn: async (values: NotificationsFormValues) => {
61
- const result = await upsertFormSettings(settingsKey, {
62
- notificationEmails: values.notificationEmails || null
63
- })
64
- if (!result.success) {
65
- throw new Error(result.error || 'Failed to save notification emails')
66
- }
67
-
68
- return result
69
- },
70
- onSuccess: async () => {
71
- toast.success('Notification emails saved')
72
- await queryClient.invalidateQueries({ queryKey: ['form-settings'] })
73
- onOpenChange(false)
74
- },
75
- onError: (error: Error) => {
76
- toast.error(error.message || 'An unexpected error occurred')
77
- }
78
- })
79
-
80
- const isPending = mutation.isPending
81
-
82
- return (
83
- <Dialog open={open} onOpenChange={onOpenChange}>
84
- <DialogContent className="sm:max-w-135">
85
- <Form {...form}>
86
- <form onSubmit={form.handleSubmit((values) => mutation.mutate(values))}>
87
- <DialogHeader>
88
- <DialogTitle>{formLabel} notifications</DialogTitle>
89
- <DialogDescription>
90
- Send an email to these addresses when a submission arrives
91
- </DialogDescription>
92
- </DialogHeader>
93
-
94
- <DialogBody>
95
- <FormField
96
- control={form.control}
97
- name="notificationEmails"
98
- render={({ field }) => (
99
- <FormItem>
100
- <FormLabel>Notification emails</FormLabel>
101
- <FormControl>
102
- <Textarea
103
- placeholder="sales@example.com, team@example.com"
104
- disabled={isPending}
105
- {...field}
106
- />
107
- </FormControl>
108
- <FormDescription>
109
- Comma-separated email addresses. Leave empty to disable notifications.
110
- </FormDescription>
111
- <FormMessage />
112
- </FormItem>
113
- )}
114
- />
115
- </DialogBody>
116
-
117
- <DialogFooter showCloseButton={true}>
118
- <Button type="submit" disabled={isPending || !form.formState.isDirty} size="lg">
119
- {isPending && <LoaderCircle className="animate-spin" />}
120
- Save
121
- </Button>
122
- </DialogFooter>
123
- </form>
124
- </Form>
125
- </DialogContent>
126
- </Dialog>
127
- )
128
- }