From 1ef4037075f2449b72e78ed59afd6cf631c7bf50 Mon Sep 17 00:00:00 2001 From: adueck Date: Tue, 11 Oct 2022 15:24:21 +0500 Subject: [PATCH] ability to send anonymous feedback --- src/components/ChapterFeedback.tsx | 37 ++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/components/ChapterFeedback.tsx b/src/components/ChapterFeedback.tsx index 3757b23..ef5249f 100644 --- a/src/components/ChapterFeedback.tsx +++ b/src/components/ChapterFeedback.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from "react"; +import { useUser } from "../user-context"; const ratings = [ { value: 0, emoji: "😭" }, @@ -8,7 +9,9 @@ const ratings = [ ] function ChapterFeedback({ chapter }: { chapter: string }) { + const { user } = useUser(); const [rating, setRating] = useState(undefined); + const [anonymous, setAnonymous] = useState(false); const [feedback, setFeedback] = useState(""); const [feedbackStatus, setFeedbackStatus] = useState<"unsent" | "sending" | "sent">("unsent") function handleRatingClick(v: number) { @@ -33,6 +36,7 @@ function ChapterFeedback({ chapter }: { chapter: string }) { chapter, feedback, rating, + anonymous, }; setFeedbackStatus("sending"); fetch("https://account.lingdocs.com/feedback", { @@ -85,23 +89,42 @@ function ChapterFeedback({ chapter }: { chapter: string }) { {rating !== undefined &&
- +