Skip to content

Commit

Permalink
Merge pull request #8155 from ethereum/updatePaperformLinks
Browse files Browse the repository at this point in the history
Update paperform url
  • Loading branch information
minimalsm committed Oct 4, 2022
2 parents 21468d8 + 96a61d5 commit 1105546
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
7 changes: 2 additions & 5 deletions src/components/FeedbackCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import React, { ReactNode, useState } from "react"
import { Icon } from "@chakra-ui/react"
import styled from "@emotion/styled"
// Component imports
import Button from "./Button"
import Translation from "./Translation"
// SVG imports
import ThumbsUp from "../assets/feedback-thumbs-up.svg"
// Utility imports
import { trackCustomEvent } from "../utils/matomo"
// import { getFeedbackSurveyUrl } from "../utils/getFeedbackSurveyUrl"
import { useSurvey } from "../hooks/useSurvey"
import Button from "./Button"

const Card = styled.div`
border: 1px solid ${({ theme }) => theme.colors.border};
Expand Down Expand Up @@ -53,8 +52,7 @@ const FeedbackCard: React.FC<IProps> = ({
className,
}) => {
const [feedbackSubmitted, setFeedbackSubmitted] = useState(false)
const [isHelpful, setIsHelpful] = useState(false)
const surveyUrl = useSurvey(feedbackSubmitted, isHelpful)
const surveyUrl = useSurvey(feedbackSubmitted)

const location = typeof window !== "undefined" ? window.location.href : ""
const isTutorial = location.includes("tutorials")
Expand All @@ -75,7 +73,6 @@ const FeedbackCard: React.FC<IProps> = ({
eventAction: `Clicked`,
eventName: String(choice),
})
setIsHelpful(choice)
setFeedbackSubmitted(true)
}
const handleSurveyOpen = (): void => {
Expand Down
5 changes: 1 addition & 4 deletions src/components/FeedbackWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,17 @@ const FeedbackWidget: React.FC<IProps> = ({ className }) => {
const [location, setLocation] = useState("")
const [isOpen, setIsOpen] = useState<boolean>(false)
const [feedbackSubmitted, setFeedbackSubmitted] = useState<boolean>(false)
const [isHelpful, setIsHelpful] = useState<boolean | null>(null)

useEffect(() => {
if (typeof window !== "undefined") {
setLocation(window.location.href)
// Reset component state when path (location) changes
setIsOpen(false)
setFeedbackSubmitted(false)
setIsHelpful(null)
}
}, [])

const surveyUrl = useSurvey(feedbackSubmitted, isHelpful)
const surveyUrl = useSurvey(feedbackSubmitted)

const bottomOffset = useMemo(() => {
const pathsWithBottomNav = ["/staking", "/dao", "/defi", "/nft"]
Expand Down Expand Up @@ -204,7 +202,6 @@ const FeedbackWidget: React.FC<IProps> = ({ className }) => {
eventAction: `Clicked`,
eventName: String(choice),
})
setIsHelpful(choice)
setFeedbackSubmitted(true)
}
const handleSurveyOpen = (): void => {
Expand Down
30 changes: 3 additions & 27 deletions src/hooks/useSurvey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,8 @@ export type Survey = {
prompt: string
}

export const useSurvey = (
feedbackSubmitted: boolean,
isHelpful: boolean | null
) =>
export const useSurvey = (feedbackSubmitted: boolean) =>
useMemo((): string | null => {
if (!feedbackSubmitted) return null
const [YES, NO] = ["yes", "no"]
const surveyUrls = {
__default: {
[YES]: `https://czvgzauj.paperform.co/?url=${location}`,
[NO]: `https://xlljh5l3.paperform.co/?url=${location}`,
},
staking: {
[YES]: `https://gzmn3wgk.paperform.co/?url=${location}`,
[NO]: `https://zlj83p6l.paperform.co/?url=${location}`,
},
"find-wallet": {
[YES]: "https://wsf1ubwu.paperform.co",
[NO]: "https://wsf1ubwu.paperform.co,",
},
}
let url = surveyUrls.__default[isHelpful ? YES : NO]
Object.keys(surveyUrls).forEach((key) => {
if (location.includes(key)) {
url = surveyUrls[key][isHelpful ? YES : NO]
}
})
return url
}, [feedbackSubmitted, isHelpful, location])
return `https://iwokuhuz.paperform.co//?url=${location}`
}, [feedbackSubmitted, location])

0 comments on commit 1105546

Please sign in to comment.