Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update paperform url #8155

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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])