From 822cb53bf30a5456089c63d0782521a9cee55c6a Mon Sep 17 00:00:00 2001 From: XiaoYhun Date: Wed, 19 Jul 2023 12:58:29 +0700 Subject: [PATCH] UI for feedback survey kyberAI --- .../TrueSightV2/components/FeedbackSurvey.tsx | 171 ++++++++++++++++++ .../TrueSightV2/pages/TokenAnalysisList.tsx | 2 + src/pages/TrueSightV2/types/index.tsx | 2 + src/state/user/hooks.tsx | 9 +- 4 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 src/pages/TrueSightV2/components/FeedbackSurvey.tsx diff --git a/src/pages/TrueSightV2/components/FeedbackSurvey.tsx b/src/pages/TrueSightV2/components/FeedbackSurvey.tsx new file mode 100644 index 0000000000..714826eca1 --- /dev/null +++ b/src/pages/TrueSightV2/components/FeedbackSurvey.tsx @@ -0,0 +1,171 @@ +import { Trans } from '@lingui/macro' +import { useEffect, useMemo, useState } from 'react' +import { X } from 'react-feather' +import { Text } from 'rebass' +import styled, { css } from 'styled-components' + +import { ButtonOutlined, ButtonPrimary } from 'components/Button' +import Modal from 'components/Modal' +import { RowBetween, RowFit } from 'components/Row' +import useTheme from 'hooks/useTheme' +import { useGetParticipantKyberAIInfo } from 'state/user/hooks' + +import { ParticipantStatus } from '../types' + +const Wrapper = styled.div` + width: min(95vw, 480px); + border-radius: 20px; + padding: 20px; + display: flex; + gap: 20px; + flex-direction: column; + b { + color: ${({ theme }) => theme.text}; + } +` + +const WidgetWrapper = styled.div<{ show?: boolean }>` + position: fixed; + right: 0; + top: 310px; + transition: filter 0.1s ease-out, right 1s ease-out, visibility 1s; + z-index: 20; + transform-origin: 100% 100%; + transform: rotate(-90deg); + border-radius: 8px 8px 0px 0px; + background: ${({ theme }) => theme.primary + '32'}; + padding: 4px 8px; + color: ${({ theme }) => theme.primary}; + cursor: pointer; + ${({ show }) => + !show && + css` + right: -25px; + visibility: hidden; + `}; + + :hover { + filter: brightness(1.2); + } +` + +const XWrapper = styled.span` + padding: 2px; + border-radius: 50%; + transition: all 0.1s; + svg { + display: block; + } + :hover { + background-color: ${({ theme }) => theme.primary + '36'}; + } +` + +const LOCALSTORAGE_MODAL_SHOWED = 'showedKyberAIFeedbackSurvey' +const LOCALSTORAGE_WIDGET_SHOWED = 'showedKyberAIFeedbackSurveyWidget' + +export default function FeedbackSurvey() { + const [isOpen, setIsOpen] = useState(false) + const [isOpenWidget, setIsOpenWidget] = useState(false) + const theme = useTheme() + const { updatedAt, status } = useGetParticipantKyberAIInfo() + const isValid = useMemo(() => updatedAt < 1689768000 && status === ParticipantStatus.WHITELISTED, [updatedAt, status]) + useEffect(() => { + if (!isValid) return + if (!localStorage.getItem(LOCALSTORAGE_MODAL_SHOWED)) { + setIsOpen(true) + localStorage.setItem(LOCALSTORAGE_MODAL_SHOWED, '1') + } + if (!localStorage.getItem(LOCALSTORAGE_WIDGET_SHOWED)) { + setIsOpenWidget(true) + } + }, [isValid]) + + return ( + <> + + + + + KyberAI Feedback Survey + +
setIsOpen(false)} style={{ cursor: 'pointer' }}> + +
+
+ + + Hey KyberAI Beta Users,
+
+ Your feedback is vital to us! Help shape the future of KyberAI by completing our short Beta + Feedback Survey{' '} + + here + + . Your input will help us meet your trading needs better!
+
+ As a token of appreciation, we will distribute a total of 400 KNC among the top 20 feedback + respondents +
+
+ + setIsOpen(false)}> + Mabe later + + + window.open( + 'https://docs.google.com/forms/d/e/1FAIpQLSebHPpIP0mqtMb57v3N3rmUCzo87ur86ruTF5QchJiJ2sRmfw/viewform?pli=1', + '_blank', + ) + } + > + Fill survey + + +
+
+ { + window.open( + 'https://docs.google.com/forms/d/e/1FAIpQLSebHPpIP0mqtMb57v3N3rmUCzo87ur86ruTF5QchJiJ2sRmfw/viewform?pli=1', + '_blank', + ) + localStorage.setItem(LOCALSTORAGE_WIDGET_SHOWED, '1') + }} + > + + + + + + + + + + + + + Feedback + + { + e.stopPropagation() + setIsOpenWidget(false) + }} + > + + + + + + ) +} diff --git a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx index 4e3fe387b7..721a2ef413 100644 --- a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx +++ b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx @@ -27,6 +27,7 @@ import useTheme from 'hooks/useTheme' import { MEDIA_WIDTHS } from 'theme' import ChevronIcon from '../components/ChevronIcon' +import FeedbackSurvey from '../components/FeedbackSurvey' import KyberAIShareModal from '../components/KyberAIShareModal' import MultipleChainDropdown from '../components/MultipleChainDropdown' import NetworkSelect from '../components/NetworkSelect' @@ -1102,6 +1103,7 @@ export default function TokenAnalysisList() { }) } /> + ) } diff --git a/src/pages/TrueSightV2/types/index.tsx b/src/pages/TrueSightV2/types/index.tsx index 38a08251bf..613101d388 100644 --- a/src/pages/TrueSightV2/types/index.tsx +++ b/src/pages/TrueSightV2/types/index.tsx @@ -197,6 +197,8 @@ export type ParticipantInfo = { referralCode: string status: ParticipantStatus rankNo: number + updatedAt: number + createdAt: number } export enum KyberAIListType { diff --git a/src/state/user/hooks.tsx b/src/state/user/hooks.tsx index ff1dac0025..3d0a9d3ff1 100644 --- a/src/state/user/hooks.tsx +++ b/src/state/user/hooks.tsx @@ -497,7 +497,14 @@ export const useSlippageSettingByPage = (isCrossChain = false) => { return { setRawSlippage, rawSlippage, isSlippageControlPinned, togglePinSlippage } } -const participantDefault = { rankNo: 0, status: ParticipantStatus.UNKNOWN, referralCode: '', id: 0 } +const participantDefault = { + rankNo: 0, + status: ParticipantStatus.UNKNOWN, + referralCode: '', + id: 0, + updatedAt: 0, + createdAt: 0, +} export const useGetParticipantKyberAIInfo = (): ParticipantInfo => { const { userInfo } = useSessionInfo() const { data: data = participantDefault, isError } = useGetParticipantInfoQuery(undefined, {