From f9040f8beda10b3969572cf8764e49f9b24b222a Mon Sep 17 00:00:00 2001 From: Sebastien Castiel Date: Thu, 18 Jan 2024 15:46:50 -0500 Subject: Merge feedback and support dialogs --- .../feedback-button/feedback-button-client.tsx | 206 --------------------- 1 file changed, 206 deletions(-) delete mode 100644 src/components/feedback-button/feedback-button-client.tsx (limited to 'src/components/feedback-button/feedback-button-client.tsx') diff --git a/src/components/feedback-button/feedback-button-client.tsx b/src/components/feedback-button/feedback-button-client.tsx deleted file mode 100644 index 96a1758..0000000 --- a/src/components/feedback-button/feedback-button-client.tsx +++ /dev/null @@ -1,206 +0,0 @@ -'use client' -import { formSchema } from '@/components/feedback-button/feedback-button-common' -import { Button } from '@/components/ui/button' -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, - DialogTrigger, -} from '@/components/ui/dialog' -import { - Drawer, - DrawerContent, - DrawerDescription, - DrawerHeader, - DrawerTitle, - DrawerTrigger, -} from '@/components/ui/drawer' -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '@/components/ui/form' -import { Input } from '@/components/ui/input' -import { Textarea } from '@/components/ui/textarea' -import { useToast } from '@/components/ui/use-toast' -import { useMediaQuery } from '@/lib/hooks' -import { zodResolver } from '@hookform/resolvers/zod' -import { Loader2, MessageCircle } from 'lucide-react' -import { useState } from 'react' -import { useForm } from 'react-hook-form' -import * as z from 'zod' - -type FormValues = z.infer - -type Props = { - sendFeedback: (values: FormValues) => Promise -} - -export function FeedbackButtonClient({ sendFeedback }: Props) { - const { toast } = useToast() - const isDesktop = useMediaQuery('(min-width: 768px)') - - async function onSubmit(values: FormValues) { - await sendFeedback(values) - toast({ - title: 'Thank you for your feedback!', - description: - 'We will have a look at it as soon as possible, and will get back to you if needed.', - }) - } - - return ( -
- {isDesktop ? ( - - ) : ( - - )} -
- ) -} - -function FeedbackDrawer({ - onSubmit, -}: { - onSubmit: (values: FormValues) => Promise -}) { - const [open, setOpen] = useState(false) - - return ( -
- - - - - - - Give us your feedback! - - We are always working to improve the user experience, and your - feedback helps us a lot. - - -
- { - await onSubmit(values) - setOpen(false) - }} - /> -
-
-
-
- ) -} - -function FeedbackDialog({ - onSubmit, -}: { - onSubmit: (values: FormValues) => Promise -}) { - const [open, setOpen] = useState(false) - - return ( -
- - - - - - - Give us your feedback! - - We are always working to improve the user experience, and your - feedback helps us a lot. - - - { - await onSubmit(values) - setOpen(false) - }} - /> - - -
- ) -} - -function FeedbackForm({ - onSubmit, -}: { - onSubmit: (values: FormValues) => Promise -}) { - const form = useForm({ - resolver: zodResolver(formSchema), - defaultValues: { email: '', message: '' }, - }) - - const isSubmitting = form.formState.isSubmitting - return ( -
- -
- ( - - Your email address - - - - - Optional. Provide it if you want us to get back to you. - - - - )} - /> - ( - - Your feedback - -