diff --git a/src/components/Chapter.js b/src/components/Chapter.js index a2e6ba3..8e23b7d 100644 --- a/src/components/Chapter.js +++ b/src/components/Chapter.js @@ -8,6 +8,7 @@ import TableOfContents from "./TableOfContents"; import Footer from "./Footer"; +import ChapterFeedback from "./ChapterFeedback"; const Chapter = ({ children: chapter }) => { const Content = chapter.content; @@ -33,6 +34,7 @@ const Chapter = ({ children: chapter }) => { + {!chapter.frontMatter.fullWidth && } diff --git a/src/components/ChapterFeedback.tsx b/src/components/ChapterFeedback.tsx new file mode 100644 index 0000000..a20e42c --- /dev/null +++ b/src/components/ChapterFeedback.tsx @@ -0,0 +1,96 @@ +import { useEffect, useState } from "react"; + +const ratings = [ + { value: 0, emoji: "ðŸ˜" }, + { value: 1, emoji: "😕" }, + { value: 2, emoji: "🙂" }, + { value: 3, emoji: "🤩" }, +] + +function ChapterFeedback({ chapter }: { chapter: string }) { + const [rating, setRating] = useState(undefined); + const [feedback, setFeedback] = useState(""); + const [feedbackSent, setFeedbackSent] = useState(false); + function handleRatingClick(v: number) { + setRating(o => o === v ? undefined : v); + } + useEffect(() => { + return () => { + // send face feedback if exists + } + }) + function handleSendFeedback() { + const toSend = { + chapter, + feedback, + rating, + }; + fetch("https://account.lingdocs.com/feedback", { + method: "PUT", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(toSend), + }).then(res => res.json()).then(res => { + console.log(res); + if (res.ok) { + setFeedbackSent(true); + } else { + alert("error sending feedback"); + } + }).catch(() => { + alert("connect to the internet to send feedback"); + setFeedbackSent(true); + }); + } + if (feedbackSent) { + return + + + Thanks for your feedback! + + + } + return + + + Was this chapter helpful? + + {ratings.map(({ value, emoji }) => ( + handleRatingClick(value)} + > + {emoji} + + ))} + + {rating !== undefined && + + Feedback: + setFeedback(e.target.value)} + /> + + + Send + + } + + ; +} + + + +export default ChapterFeedback; \ No newline at end of file diff --git a/src/games/sub-cores/EquativeIdentify.tsx b/src/games/sub-cores/EquativeIdentify.tsx index 93937e0..4c64e65 100644 --- a/src/games/sub-cores/EquativeIdentify.tsx +++ b/src/games/sub-cores/EquativeIdentify.tsx @@ -40,7 +40,6 @@ export default function EquativeIdentify({ inChapter, id, link, level }: { inCha }; function Display({ question, callback }: QuestionDisplayProps) { - console.log({ question }); const [selected, setSelected] = useState([]); useEffect(() => { setSelected([]); diff --git a/src/lib/entry-feeder.ts b/src/lib/entry-feeder.ts index dc5c5dd..171c858 100644 --- a/src/lib/entry-feeder.ts +++ b/src/lib/entry-feeder.ts @@ -7,8 +7,6 @@ import { adverbs, } from "../words/words"; -console.log({ locativeAdverbs }); - const entryFeeder: T.EntryFeeder = { nouns, verbs, diff --git a/src/lib/useDictionary.ts b/src/lib/useDictionary.ts index 32bd38b..4ef79fa 100644 --- a/src/lib/useDictionary.ts +++ b/src/lib/useDictionary.ts @@ -8,12 +8,10 @@ import { useEffect, useState } from "react"; function useDictionary() { const [dictionaryStatus, setDictionaryStatus] = useState("loading"); useEffect(() => { - console.log("starting here"); setDictionaryStatus("loading"); dictionary.initialize().then(() => { setDictionaryStatus("ready"); }).catch((err) => { - console.log("out of fetch", err); console.error(err); setDictionaryStatus("error loading"); });