From e8fd472ef6789715ac733b8545669652ce3869db Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Tue, 21 Mar 2023 16:31:12 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A2=20Add=20a=20feedback=20form=20(#59?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/declarations/environment.d.ts | 4 + apps/web/public/locales/en/app.json | 8 ++ apps/web/src/components/feedback.tsx | 108 ++++++++++++++++++ .../components/layouts/standard-layout.tsx | 4 + .../src/components/participant-dropdown.tsx | 1 - apps/web/src/pages/_app.tsx | 1 + apps/web/src/server/routers/_app.ts | 2 + apps/web/src/server/routers/feedback.ts | 37 ++++++ packages/emails/src/send-email.tsx | 14 ++- turbo.json | 1 + 10 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 apps/web/src/components/feedback.tsx create mode 100644 apps/web/src/server/routers/feedback.ts diff --git a/apps/web/declarations/environment.d.ts b/apps/web/declarations/environment.d.ts index c81634c42..b87872505 100644 --- a/apps/web/declarations/environment.d.ts +++ b/apps/web/declarations/environment.d.ts @@ -33,6 +33,10 @@ declare global { * Crisp website ID */ NEXT_PUBLIC_CRISP_WEBSITE_ID?: string; + /** + * When defined users will be able to send feedback to this email address + */ + NEXT_PUBLIC_FEEDBACK_EMAIL?: string; /** * Users of your instance will see this as their support email */ diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json index 682557112..7a1e28605 100644 --- a/apps/web/public/locales/en/app.json +++ b/apps/web/public/locales/en/app.json @@ -18,6 +18,12 @@ "comment": "Comment", "commentPlaceholder": "Leave a comment on this poll (visible to everyone)", "comments": "Comments", + "feedbackSent": "Thank you! Your feedback has been sent.", + "feedbackFormLabel": "How can we improve ?", + "feedbackFormPlaceholder": "Share your thoughts…", + "feedbackFormFooter": "Need help? Visit the support page.", + "feedbackFormTitle": "Feedback Form", + "close": "Close", "continue": "Continue", "copied": "Copied", "copyLink": "Copy link", @@ -123,6 +129,8 @@ "response": "Response", "save": "Save", "saveInstruction": "Select your availability and click {{action}}", + "send": "Send", + "sendFeedback": "Send Feedback", "share": "Share", "shareDescription": "Give this link to your participants to allow them to vote on your poll.", "shareLink": "Share via link", diff --git a/apps/web/src/components/feedback.tsx b/apps/web/src/components/feedback.tsx new file mode 100644 index 000000000..1b6b49cb0 --- /dev/null +++ b/apps/web/src/components/feedback.tsx @@ -0,0 +1,108 @@ +import Link from "next/link"; +import { Trans, useTranslation } from "next-i18next"; +import { useForm } from "react-hook-form"; + +import { Button } from "@/components/button"; +import CheckCircle from "@/components/icons/check-circle.svg"; +import Speakerphone from "@/components/icons/speakerphone.svg"; +import { Logo } from "@/components/logo"; +import { useModalState } from "@/components/modal/use-modal"; +import Tooltip from "@/components/tooltip"; +import { trpc } from "@/utils/trpc"; + +const FeedbackForm = (props: { onClose: () => void }) => { + const { t } = useTranslation("app"); + const sendFeedback = trpc.feedback.send.useMutation(); + const { handleSubmit, register, formState } = useForm<{ content: string }>(); + + return ( +
{ + await sendFeedback.mutateAsync(data); + })} + className="shadow-huge animate-popIn fixed bottom-8 right-8 z-20 w-[460px] max-w-full origin-bottom-right space-y-2 overflow-hidden rounded-md border bg-white p-3" + > + {formState.isSubmitted ? ( +
+
+ +
{t("feedbackSent")}
+
+ +
+
+
+ ) : null} +
+ {t("feedbackFormTitle")} +
+
+ +