From 95da1c3505997cac4613b95e4bef3b3a6feb8b4a Mon Sep 17 00:00:00 2001 From: Vainakh Date: Sun, 12 May 2024 18:27:09 -0600 Subject: [PATCH 1/8] #1267 Remove Feedback Feature --- app/components/listing/ActionBar.tsx | 2 +- app/components/listing/FeedbackModal.tsx | 28 ---- .../listing/feedback/FeedbackForm.module.scss | 50 ------ .../listing/feedback/FeedbackForm.tsx | 139 ----------------- .../feedback/FeedbackSteps.module.scss | 130 ---------------- .../listing/feedback/FeedbackSteps.tsx | 144 ------------------ app/components/listing/feedback/constants.ts | 35 ----- app/models/Organization.ts | 4 - 8 files changed, 1 insertion(+), 531 deletions(-) delete mode 100644 app/components/listing/FeedbackModal.tsx delete mode 100644 app/components/listing/feedback/FeedbackForm.module.scss delete mode 100644 app/components/listing/feedback/FeedbackForm.tsx delete mode 100644 app/components/listing/feedback/FeedbackSteps.module.scss delete mode 100644 app/components/listing/feedback/FeedbackSteps.tsx delete mode 100644 app/components/listing/feedback/constants.ts diff --git a/app/components/listing/ActionBar.tsx b/app/components/listing/ActionBar.tsx index 15325c05a..ae2760e36 100644 --- a/app/components/listing/ActionBar.tsx +++ b/app/components/listing/ActionBar.tsx @@ -20,7 +20,7 @@ const ActionButton = ({ const content = ( <> {icon} diff --git a/app/components/listing/FeedbackModal.tsx b/app/components/listing/FeedbackModal.tsx deleted file mode 100644 index e96efa441..000000000 --- a/app/components/listing/FeedbackModal.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from "react"; -import Modal from "react-modal"; -import { Organization, Service } from "../../models"; -import { FeedbackForm } from "./feedback/FeedbackForm"; - -export const FeedbackModal = ({ - organization, - service, - isOpen, - setIsOpen, -}: { - isOpen: boolean; - setIsOpen: (val: boolean) => void; - organization: Organization; - service?: Service; -}) => ( - - setIsOpen(!isOpen)} - resource={organization} - service={service} - /> - -); diff --git a/app/components/listing/feedback/FeedbackForm.module.scss b/app/components/listing/feedback/FeedbackForm.module.scss deleted file mode 100644 index ae0fb0300..000000000 --- a/app/components/listing/feedback/FeedbackForm.module.scss +++ /dev/null @@ -1,50 +0,0 @@ -@import "../../../styles/utils/colors"; - -.feedbackModalBody { - display: flex; - flex-direction: column; - align-items: center; - text-align: center; -} -.closeModal { - position: absolute; - right: 25px; - top: 15px; - cursor: pointer; - @media screen and (max-width: 767px) { - top: 45px; - } -} - -.feedbackHeader { - font-weight: 600; - font-size: 20px; - color: $color-brand; - @media screen and (max-width: 767px) { - width: 100%; - text-align: start; - } -} - -.feedbackSubheader { - width: 200px; - font-size: 15px; - @media screen and (max-width: 767px) { - width: 100%; - margin-top: 5px; - text-align: start; - font-size: 16px; - font-weight: bold; - } -} - -.stepsContainer { - display: flex; - flex-direction: column; - align-items: center; - @media screen and (max-width: 767px) { - height: 450px; - justify-content: center; - margin-top: 10px; - } -} diff --git a/app/components/listing/feedback/FeedbackForm.tsx b/app/components/listing/feedback/FeedbackForm.tsx deleted file mode 100644 index b77ed95d6..000000000 --- a/app/components/listing/feedback/FeedbackForm.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import React, { useState } from "react"; -import { cloneDeep } from "lodash"; -import { icon } from "assets"; -import { TAG_LIST } from "./constants"; -import type { StepState, SubmittedState, TagType, VoteType } from "./constants"; -import { Organization, Service } from "../../../models"; -import { addFeedback } from "../../../utils/DataService"; -import { - VoteButtons, - FeedbackTags, - Review, - SubmitMessage, - NavigationButtons, -} from "./FeedbackSteps"; -import styles from "./FeedbackForm.module.scss"; - -export const FeedbackForm = ({ - service, - resource, - closeModal, -}: { - service?: Service; - resource: Organization; - closeModal: () => void; -}) => { - const [vote, setVote] = useState("neither"); - const [tagOptions, setTags] = useState(TAG_LIST); - const [review, setReview] = useState(""); - const [step, setStep] = useState("start"); - const [isSubmitted, setIsSubmitted] = useState(null); - const handleVoteChange = (voteType: VoteType) => { - setStep("start"); - setVote(voteType); - }; - - /** - * Toggle selected tags state with given position - * - * @param {int} pos - position of tag in array of tagOptions. - */ - const toggleSelectedTag = (pos: number) => { - const updatedTags = cloneDeep(tagOptions); - updatedTags[pos].selected = !updatedTags[pos].selected; - setTags(updatedTags); - }; - - const handleReviewChange = (e: React.ChangeEvent) => { - e.preventDefault(); - setReview(e.target.value); - }; - - const handleNextStep = () => - vote === "downvote" && step === "start" - ? setStep("tags") - : setStep("review"); - - const handlePrevStep = () => - vote === "downvote" && step === "review" - ? setStep("tags") - : setStep("start"); - - const handleSubmit = () => { - setIsSubmitted("submitting"); - const tags = tagOptions - .filter(({ selected }) => selected) - .map(({ tag }) => tag); - - const feedback = { - rating: vote, - tags, - review, - }; - - const [source, sourceId] = !service - ? (["resources", resource.id] as const) - : (["services", service.id] as const); - - addFeedback(source, sourceId, feedback) - .then(() => { - setIsSubmitted("submitted"); - }) - .catch((err) => console.log(err)); // eslint-disable-line no-console - }; - - const isReviewRequired = - tagOptions.some(({ tag, selected }) => tag === "Other" && selected) && - vote === "downvote"; - - const STEPS = { - start: null, - tags: ( - - ), - review: ( - - ), - }; - - return ( -
-
- close -
-
- feedback - Share your Feedback -
-
- The team usually replies within a day. -
- {isSubmitted === "submitted" ? ( - - ) : ( -
- - {STEPS[step]} - -
- )} -
- ); -}; diff --git a/app/components/listing/feedback/FeedbackSteps.module.scss b/app/components/listing/feedback/FeedbackSteps.module.scss deleted file mode 100644 index e990227f6..000000000 --- a/app/components/listing/feedback/FeedbackSteps.module.scss +++ /dev/null @@ -1,130 +0,0 @@ -@import "../../../styles/utils/colors"; - -.voteIcons { - display: flex; - justify-content: space-between; - width: 110px; - height: 35px; - margin-top: 15px; - img { - cursor: pointer; - } -} - -.stepsPrompt { - font-weight: 600; - margin-top: 20px; - font-size: 18px; - line-height: 1.5; - @media screen and (max-width: 767px) { - font-weight: bold; - margin-bottom: 15px; - } -} -.votePrompt { - @media screen and (max-width: 767px) { - width: 215px; - } -} - -.feedbackTags { - margin-top: 10px; -} - -.feedbackTagsContainer { - display: flex; - flex-wrap: wrap; -} - -.feedbackTag { - flex: 1 0 auto; - border: 2px solid $color-brand; - box-sizing: border-box; - border-radius: 20px; - cursor: pointer; - margin: 10px; - padding: 7px 24px; - color: $color-brand; - font-weight: 600; - font-size: 16px; - @media screen and (max-width: 767px) { - margin: 10px; - padding: 8px 15px; - font-size: 18px; - } -} - -.selectedTag { - color: $color-white; - background: $color-brand; -} - -.feedbackReview { - margin-top: 10px; -} -.feedbackTextarea { - resize: none !important; - width: 450px; - height: 165px; - margin-top: 10px; - background: $color-grey1; - border: 2px solid $color-brand; - box-sizing: border-box; - border-radius: 20px; - &::-webkit-scrollbar { - width: 0%; - } - @media screen and (max-width: 767px) { - max-width: 350px; - height: 180px; - margin-top: 7px; - } -} - -.feedbackSubmitHeader { - font-weight: 600; - font-size: 24px; - line-height: 33px; - margin-top: 3.5em; -} - -.feedbackSubmitSubheader { - font-size: 18px; - line-height: 25px; - margin-top: 15px; - width: 80%; - margin-bottom: 3.5em; - @media screen and (max-width: 767px) { - font-weight: 600; - } -} - -.navButtonsContainer { - display: flex; - justify-content: space-between; - width: 340px; - margin-top: 30px; - @media screen and (max-width: 767px) { - position: absolute; - bottom: 40px; - } -} - -.navButtons { - background: $color-brand; - width: 150px; - border-radius: 3px; - &:disabled { - opacity: 0.5; - } - &:only-child { - margin: 0 auto; - } -} - -.backButton { - composes: navButtons; - background: $color-white; - border: 2px solid $color-brand; - color: $color-brand; -} diff --git a/app/components/listing/feedback/FeedbackSteps.tsx b/app/components/listing/feedback/FeedbackSteps.tsx deleted file mode 100644 index c4ad49c55..000000000 --- a/app/components/listing/feedback/FeedbackSteps.tsx +++ /dev/null @@ -1,144 +0,0 @@ -import React from "react"; - -import { icon } from "assets"; -import type { SubmittedState, StepState, TagType, VoteType } from "./constants"; -import styles from "./FeedbackSteps.module.scss"; - -export const VoteButtons = ({ - vote, - onVoteChange, -}: { - vote: VoteType; - onVoteChange: (v: VoteType) => void; -}) => ( - <> -
- How was your experience on this site? -
-
-
onVoteChange("upvote")} role="button" tabIndex={-1}> - upvote -
-
onVoteChange("downvote")} role="button" tabIndex={-2}> - downvote -
-
- -); - -export const FeedbackTags = ({ - tagOptions, - onSelectTag, -}: { - tagOptions: readonly TagType[]; - onSelectTag: (i: number) => void; -}) => ( -
-
What can be improved?
-
- {tagOptions.map(({ tag, selected }, pos) => { - const selectedStyle = selected ? styles.selectedTag : ""; - return ( -
onSelectTag(pos)} - > - {tag} -
- ); - })} -
-
-); - -export const Review = ({ - reviewValue, - onReviewChange, - isReviewRequired, -}: { - reviewValue: string; - onReviewChange: (e: React.ChangeEvent) => void; - isReviewRequired: boolean; -}) => ( -
-
- Please provide your feedback below: -
-