-
-
Notifications
You must be signed in to change notification settings - Fork 778
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): feedback dialog default to user email
- Loading branch information
Showing
8 changed files
with
209 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { type FC } from 'react'; | ||
import AnimateHeight from 'react-animate-height'; | ||
import { useForm } from 'react-hook-form'; | ||
import { useUser } from '@clerk/nextjs'; | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { type TRPCErrorResponse } from '@trpc/server/rpc'; | ||
import { z } from 'zod'; | ||
|
@@ -32,13 +34,13 @@ const formSchema = z.object({ | |
message: z.string().min(3), | ||
}); | ||
|
||
export const FeedbackDialog = () => { | ||
const FeedbackForm: FC<{ email?: string | undefined }> = ({ email }) => { | ||
const { mutateAsync, isLoading, isSuccess } = api.feedback.add.useMutation(); | ||
|
||
const form = useForm<z.infer<typeof formSchema>>({ | ||
resolver: zodResolver(formSchema), | ||
defaultValues: { | ||
email: '', | ||
email: email ?? '', | ||
message: '', | ||
}, | ||
}); | ||
|
@@ -56,10 +58,75 @@ export const FeedbackDialog = () => { | |
} | ||
}; | ||
|
||
return ( | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="pt-6" noValidate> | ||
<div className="space-y-8"> | ||
<FormField | ||
control={form.control} | ||
name="email" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Email Address</FormLabel> | ||
<FormControl> | ||
<Input | ||
placeholder="[email protected]" | ||
type="email" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
control={form.control} | ||
name="message" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Message</FormLabel> | ||
<FormControl> | ||
<Textarea | ||
className="min-h-[120px] resize-none" | ||
placeholder="Your message" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
</div> | ||
|
||
<FormMessage className="pt-2"> | ||
{form.formState.errors.root?.message} | ||
</FormMessage> | ||
|
||
<AnimateHeight height={isSuccess ? 'auto' : 0}> | ||
<Typography.P className="text-teal-10 dark:text-tealdark-10 flex items-center gap-2 pt-2"> | ||
<Icon name="check" /> | ||
Thanks for your feedback! | ||
</Typography.P> | ||
</AnimateHeight> | ||
|
||
<DialogFooter className="pt-6"> | ||
<Button type="submit" variant="inverse" disabled={isLoading}> | ||
{isLoading ? 'Sending...' : 'Send Message'} | ||
</Button> | ||
</DialogFooter> | ||
</form> | ||
</Form> | ||
); | ||
}; | ||
|
||
export const FeedbackDialog = () => { | ||
const { user } = useUser(); | ||
|
||
return ( | ||
<Dialog> | ||
<DialogTrigger asChild> | ||
<Button variant="secondary" className="w-full"> | ||
<Button variant="muted" className="w-full"> | ||
<Icon name="badge-help" /> | ||
Provide feedback | ||
</Button> | ||
|
@@ -73,69 +140,9 @@ export const FeedbackDialog = () => { | |
</DialogDescription> | ||
</DialogHeader> | ||
|
||
<Form {...form}> | ||
<form | ||
// eslint-disable-next-line @typescript-eslint/no-misused-promises | ||
onSubmit={form.handleSubmit(onSubmit)} | ||
className="pt-6" | ||
noValidate | ||
> | ||
<div className="space-y-8"> | ||
<FormField | ||
control={form.control} | ||
name="email" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Email Address</FormLabel> | ||
<FormControl> | ||
<Input | ||
placeholder="[email protected]" | ||
type="email" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
control={form.control} | ||
name="message" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Message</FormLabel> | ||
<FormControl> | ||
<Textarea | ||
className="min-h-[120px] resize-none" | ||
placeholder="Your message" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
</div> | ||
|
||
<FormMessage className="pt-2"> | ||
{form.formState.errors.root?.message} | ||
</FormMessage> | ||
|
||
<AnimateHeight height={isSuccess ? 'auto' : 0}> | ||
<Typography.P className="text-teal-10 dark:text-tealdark-10 flex items-center gap-2 pt-2"> | ||
<Icon name="check" /> | ||
Thanks for your feedback! | ||
</Typography.P> | ||
</AnimateHeight> | ||
|
||
<DialogFooter className="pt-6"> | ||
<Button type="submit" variant="inverse" disabled={isLoading}> | ||
{isLoading ? 'Sending...' : 'Send Message'} | ||
</Button> | ||
</DialogFooter> | ||
</form> | ||
</Form> | ||
{user && ( | ||
<FeedbackForm email={user.primaryEmailAddress?.emailAddress} /> | ||
)} | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Typography } from '@noodle/ui'; | ||
|
||
import { DashboardLayout } from '@/layouts/dashboard'; | ||
import { type NextPageWithLayout } from '@/utils/NextPageWithLayout'; | ||
|
||
const ModulesPage: NextPageWithLayout = () => { | ||
return ( | ||
<main className="flex flex-1 items-center justify-center"> | ||
<div className="text-center"> | ||
<Typography.H1>😪</Typography.H1> | ||
<Typography.H1>It's a bit lonely here</Typography.H1> | ||
<Typography.P className="max-w-[50ch]"> | ||
We are hard at work getting the dashboard up and running, we are still | ||
in very much early days of the development of Noodle. | ||
</Typography.P> | ||
</div> | ||
</main> | ||
); | ||
}; | ||
|
||
ModulesPage.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>; | ||
|
||
export default ModulesPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.