1
- import React , { ReactNode , useState } from "react"
1
+ import { type ReactNode , useState } from "react"
2
2
import { useRouter } from "next/router"
3
3
import { useTranslation } from "next-i18next"
4
- import { Flex , FlexProps , Heading } from "@chakra-ui/react"
4
+ import { Flex , type FlexProps , Heading } from "@chakra-ui/react"
5
5
6
- import { Button } from "./Buttons"
7
- import { FeedbackThumbsUpIcon } from "./icons"
6
+ import { Button } from "@/components/Buttons"
7
+ import { FeedbackThumbsUpIcon } from "@/components/icons"
8
+ import Link from "@/components/Link"
8
9
9
- // TODO: add trackCustomEvent when util is migrated
10
- // import { trackCustomEvent } from "../utils/matomo"
10
+ import { trackCustomEvent } from "@/lib/utils/matomo"
11
11
12
- // TODO: add useSurvey after hook is migrated
13
- // import { useSurvey } from "../hooks/useSurvey"
12
+ import { useSurvey } from "@/hooks/useSurvey"
14
13
15
- export interface IProps extends FlexProps {
14
+ type FeedbackCardProps = FlexProps & {
16
15
prompt ?: string
17
16
isArticle ?: boolean
18
17
}
19
18
20
- const FeedbackCard : React . FC < IProps > = ( {
21
- prompt,
22
- isArticle = false ,
23
- ...props
24
- } ) => {
19
+ const FeedbackCard = ( { prompt, isArticle, ...props } : FeedbackCardProps ) => {
25
20
const { t } = useTranslation ( "common" )
26
21
const [ feedbackSubmitted , setFeedbackSubmitted ] = useState ( false )
27
- // const surveyUrl = useSurvey(feedbackSubmitted)
22
+ const surveyUrl = useSurvey ( feedbackSubmitted )
28
23
const { asPath } = useRouter ( )
29
24
30
25
const isTutorial = asPath ?. includes ( "tutorials" )
31
26
32
27
const getTitle = ( feedbackSubmitted : boolean ) : ReactNode => {
33
28
if ( ! feedbackSubmitted ) {
34
29
if ( prompt ) return prompt
35
-
36
30
if ( isTutorial ) return t ( "feedback-card-prompt-tutorial" )
37
31
if ( isArticle ) return t ( "feedback-card-prompt-article" )
38
32
@@ -43,23 +37,21 @@ const FeedbackCard: React.FC<IProps> = ({
43
37
}
44
38
45
39
const handleSubmit = ( choice : boolean ) : void => {
46
- // TODO: add trackCustomEvent when util is migrated
47
- // trackCustomEvent({
48
- // eventCategory: `Page is helpful feedback`,
49
- // eventAction: `Clicked`,
50
- // eventName: String(choice),
51
- // })
40
+ trackCustomEvent ( {
41
+ eventCategory : `Page is helpful feedback` ,
42
+ eventAction : `Clicked` ,
43
+ eventName : String ( choice ) ,
44
+ } )
52
45
setFeedbackSubmitted ( true )
53
46
}
54
47
55
48
const handleSurveyOpen = ( ) : void => {
56
- // TODO: add trackCustomEvent when util is migrated
57
- // trackCustomEvent({
58
- // eventCategory: `Feedback survey opened`,
59
- // eventAction: `Clicked`,
60
- // eventName: "Feedback survey opened",
61
- // })
62
- // window && surveyUrl && window.open(surveyUrl, "_blank")
49
+ trackCustomEvent ( {
50
+ eventCategory : `Feedback survey opened` ,
51
+ eventAction : `Clicked` ,
52
+ eventName : "Feedback survey opened" ,
53
+ } )
54
+ window && surveyUrl && window . open ( surveyUrl , "_blank" )
63
55
}
64
56
65
57
return (
@@ -68,28 +60,25 @@ const FeedbackCard: React.FC<IProps> = ({
68
60
borderColor = "border"
69
61
bg = "feedbackGradient"
70
62
borderRadius = "base"
71
- p = { 6 }
63
+ p = "6"
72
64
direction = "column"
73
- mb = { 4 }
74
- mt = { 8 }
65
+ mb = "4"
66
+ mt = "8"
75
67
w = "full"
76
68
{ ...props }
77
69
>
78
- < Flex direction = "column" gap = { 4 } >
79
- < Heading as = "h3" m = { 0 } mb = { 2 } fontSize = "1.375rem" fontWeight = "bold" >
70
+ < Flex direction = "column" gap = "4" >
71
+ < Heading as = "h3" m = "0" mb = "2" fontSize = "1.375rem" fontWeight = "bold" >
80
72
{ getTitle ( feedbackSubmitted ) }
81
73
</ Heading >
82
74
{ feedbackSubmitted && (
83
75
< p >
84
76
{ t ( "feedback-widget-thank-you-subtitle" ) } { " " }
85
77
{ t ( "feedback-widget-thank-you-subtitle-ext" ) } { " " }
86
- < a href = "https://discord.gg/rZz26QWfCg\" target = "_blank\" >
87
- Discord
88
- </ a >
89
- .
78
+ < Link href = "/discord/" > Discord</ Link > .
90
79
</ p >
91
80
) }
92
- < Flex gap = { 4 } >
81
+ < Flex gap = "4" >
93
82
{ ! feedbackSubmitted ? (
94
83
< >
95
84
< Button
0 commit comments