From fcce6ae6bf50a91b78f6ce3dea1d0a29df3ea691 Mon Sep 17 00:00:00 2001 From: Maria Elisabeth Schreiber Date: Mon, 3 Jun 2024 10:50:29 -0600 Subject: [PATCH 01/13] Add starting point --- src/components/Feedback.js | 194 +++++++++++++++++++++++++++++++++++++ src/components/Page.js | 2 + 2 files changed, 196 insertions(+) create mode 100644 src/components/Feedback.js diff --git a/src/components/Feedback.js b/src/components/Feedback.js new file mode 100644 index 000000000..4fe7b580a --- /dev/null +++ b/src/components/Feedback.js @@ -0,0 +1,194 @@ +import React, {useState} from 'react'; +import { + Box, + Button, + FormControl, + FormLabel, + Input, + Select, + Textarea, + useToast +} from '@chakra-ui/react'; + +const FeedbackWidget = () => { + const [feedbackGiven, setFeedbackGiven] = useState(false); + const [showSurvey, setShowSurvey] = useState(false); + const [thumbsUp, setThumbsUp] = useState(false); + const [surveyResponses, setSurveyResponses] = useState({ + helpfulAspect: '', + easeOfUse: '', + additionalComments: '', + issue: '', + issueDetails: '', + pageStructure: '' + }); + + const toast = useToast(); + + const handleThumbsUp = () => { + setFeedbackGiven(true); + setThumbsUp(true); + setShowSurvey(true); + }; + + const handleThumbsDown = () => { + setFeedbackGiven(true); + setThumbsUp(false); + setShowSurvey(true); + }; + + const handleInputChange = e => { + const {name, value} = e.target; + setSurveyResponses(prevResponses => ({ + ...prevResponses, + [name]: value + })); + }; + + const handleSubmit = e => { + e.preventDefault(); + console.log('Survey responses:', surveyResponses); + // Here you would send the surveyResponses to your backend or API. + setShowSurvey(false); + toast({ + title: 'Thank you for your feedback!', + status: 'success', + duration: 3000, + isClosable: true + }); + }; + + return ( + + {!feedbackGiven ? ( + + + Was this page helpful? + + + + + ) : ( + + {thumbsUp + ? 'Thank you for your feedback! Could you tell us more?' + : "We're sorry to hear that. Could you help us improve?"} + + )} + + {showSurvey && ( + +
+ {thumbsUp ? ( + <> + + + What did you find most helpful about this page? + + + + + + How easy was it to find the information you were looking + for? + + + + + + Any additional comments or suggestions for improvement? + +