Skip to content

Commit 96a61d5

Browse files
committed
refactor to use new paperform url
1 parent ce5c2c0 commit 96a61d5

File tree

3 files changed

+6
-36
lines changed

3 files changed

+6
-36
lines changed

src/components/FeedbackCard.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import React, { ReactNode, useState } from "react"
33
import { Icon } from "@chakra-ui/react"
44
import styled from "@emotion/styled"
55
// Component imports
6+
import Button from "./Button"
67
import Translation from "./Translation"
78
// SVG imports
89
import ThumbsUp from "../assets/feedback-thumbs-up.svg"
910
// Utility imports
1011
import { trackCustomEvent } from "../utils/matomo"
11-
// import { getFeedbackSurveyUrl } from "../utils/getFeedbackSurveyUrl"
1212
import { useSurvey } from "../hooks/useSurvey"
13-
import Button from "./Button"
1413

1514
const Card = styled.div`
1615
border: 1px solid ${({ theme }) => theme.colors.border};
@@ -53,8 +52,7 @@ const FeedbackCard: React.FC<IProps> = ({
5352
className,
5453
}) => {
5554
const [feedbackSubmitted, setFeedbackSubmitted] = useState(false)
56-
const [isHelpful, setIsHelpful] = useState(false)
57-
const surveyUrl = useSurvey(feedbackSubmitted, isHelpful)
55+
const surveyUrl = useSurvey(feedbackSubmitted)
5856

5957
const location = typeof window !== "undefined" ? window.location.href : ""
6058
const isTutorial = location.includes("tutorials")
@@ -75,7 +73,6 @@ const FeedbackCard: React.FC<IProps> = ({
7573
eventAction: `Clicked`,
7674
eventName: String(choice),
7775
})
78-
setIsHelpful(choice)
7976
setFeedbackSubmitted(true)
8077
}
8178
const handleSurveyOpen = (): void => {

src/components/FeedbackWidget.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,17 @@ const FeedbackWidget: React.FC<IProps> = ({ className }) => {
156156
const [location, setLocation] = useState("")
157157
const [isOpen, setIsOpen] = useState<boolean>(false)
158158
const [feedbackSubmitted, setFeedbackSubmitted] = useState<boolean>(false)
159-
const [isHelpful, setIsHelpful] = useState<boolean | null>(null)
160159

161160
useEffect(() => {
162161
if (typeof window !== "undefined") {
163162
setLocation(window.location.href)
164163
// Reset component state when path (location) changes
165164
setIsOpen(false)
166165
setFeedbackSubmitted(false)
167-
setIsHelpful(null)
168166
}
169167
}, [])
170168

171-
const surveyUrl = useSurvey(feedbackSubmitted, isHelpful)
169+
const surveyUrl = useSurvey(feedbackSubmitted)
172170

173171
const bottomOffset = useMemo(() => {
174172
const pathsWithBottomNav = ["/staking", "/dao", "/defi", "/nft"]
@@ -204,7 +202,6 @@ const FeedbackWidget: React.FC<IProps> = ({ className }) => {
204202
eventAction: `Clicked`,
205203
eventName: String(choice),
206204
})
207-
setIsHelpful(choice)
208205
setFeedbackSubmitted(true)
209206
}
210207
const handleSurveyOpen = (): void => {

src/hooks/useSurvey.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,8 @@ export type Survey = {
77
prompt: string
88
}
99

10-
export const useSurvey = (
11-
feedbackSubmitted: boolean,
12-
isHelpful: boolean | null
13-
) =>
10+
export const useSurvey = (feedbackSubmitted: boolean) =>
1411
useMemo((): string | null => {
1512
if (!feedbackSubmitted) return null
16-
const [YES, NO] = ["yes", "no"]
17-
const surveyUrls = {
18-
__default: {
19-
[YES]: `https://czvgzauj.paperform.co/?url=${location}`,
20-
[NO]: `https://xlljh5l3.paperform.co/?url=${location}`,
21-
},
22-
staking: {
23-
[YES]: `https://gzmn3wgk.paperform.co/?url=${location}`,
24-
[NO]: `https://zlj83p6l.paperform.co/?url=${location}`,
25-
},
26-
"find-wallet": {
27-
[YES]: "https://wsf1ubwu.paperform.co",
28-
[NO]: "https://wsf1ubwu.paperform.co,",
29-
},
30-
}
31-
let url = surveyUrls.__default[isHelpful ? YES : NO]
32-
Object.keys(surveyUrls).forEach((key) => {
33-
if (location.includes(key)) {
34-
url = surveyUrls[key][isHelpful ? YES : NO]
35-
}
36-
})
37-
return url
38-
}, [feedbackSubmitted, isHelpful, location])
13+
return `https://iwokuhuz.paperform.co//?url=${location}`
14+
}, [feedbackSubmitted, location])

0 commit comments

Comments
 (0)