state/user/hooks#useUserPredictionChartDisclaimerShow TypeScript Examples

The following examples show how to use state/user/hooks#useUserPredictionChartDisclaimerShow. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChartDisclaimer.tsx    From vvs-ui with GNU General Public License v3.0 5 votes vote down vote up
ChartDisclaimer: React.FC<InjectedModalProps> = ({ onDismiss }) => {
  const [showDisclaimer, setShowDisclaimer] = useUserPredictionChartDisclaimerShow()
  const { t } = useTranslation()

  const handleConfirm = () => {
    onDismiss()
  }

  return (
    <ModalContainer minWidth="320px">
      <ModalBody p="24px" maxWidth="400px">
        <Flex justifyContent="center" mb="32px">
          <Image src="/images/chartwarning.svg" width={190} height={118} />
        </Flex>
        <Heading as="h3" size="sm">
          {t('Warning')}:
        </Heading>
        <Heading as="h4" size="sm" mb="24px">
          {t('Prices shown on cards and charts are different')}:
        </Heading>
        <Text as="p" fontSize="14px" color="textSubtle">
          {t('The price you see come from difference places')}:
        </Text>
        <Ul>
          <li>{t('Prices on cards come from Chainlink’s verifiable price oracle.')}</li>
          <li>{t("Prices on charts come from Binance.com. Chart's are provided for your reference only.")}</li>
        </Ul>
        <Text as="p" mb="16px" fontSize="14px" color="textSubtle">
          {t("Only the price from Chainlink (shown on the cards) determines the round's result.")}
        </Text>
        <LinkExternal
          href="https://docs.vvs.finance/products/prediction/prediction-faq#what-are-you-using-for-your-price-feed"
          external
          mb="24px"
        >
          {t('Learn More')}
        </LinkExternal>
        <Box>
          <Button width="100%" onClick={handleConfirm} mb="16px">
            {t('I understand')}
          </Button>
        </Box>
        <label htmlFor="checkbox" style={{ display: 'block', cursor: 'pointer', marginBottom: '24px' }}>
          <Flex alignItems="center">
            <div style={{ flex: 'none' }}>
              <Checkbox
                id="checkbox"
                scale="sm"
                checked={!showDisclaimer}
                onChange={() => setShowDisclaimer(!showDisclaimer)}
              />
            </div>
            <Text ml="8px">{t("Don't show this again")}</Text>
          </Flex>
        </label>
      </ModalBody>
    </ModalContainer>
  )
}
Example #2
Source File: index.tsx    From vvs-ui with GNU General Public License v3.0 5 votes vote down vote up
Predictions = () => {
  const { isDesktop } = useMatchBreakpoints()
  const [hasAcceptedRisk, setHasAcceptedRisk] = useUserPredictionAcceptedRisk()
  const [showDisclaimer] = useUserPredictionChartDisclaimerShow()
  const { account } = useWeb3React()
  const status = useGetPredictionsStatus()
  const isChartPaneOpen = useIsChartPaneOpen()
  const dispatch = useAppDispatch()
  const initialBlock = useInitialBlock()
  const handleAcceptRiskSuccess = () => setHasAcceptedRisk(true)
  const [onPresentRiskDisclaimer] = useModal(<RiskDisclaimer onSuccess={handleAcceptRiskSuccess} />, false)
  const [onPresentChartDisclaimer] = useModal(<ChartDisclaimer />, false)

  // TODO: memoize modal's handlers
  const onPresentRiskDisclaimerRef = useRef(onPresentRiskDisclaimer)
  const onPresentChartDisclaimerRef = useRef(onPresentChartDisclaimer)

  // Disclaimer
  useEffect(() => {
    if (!hasAcceptedRisk) {
      onPresentRiskDisclaimerRef.current()
    }
  }, [hasAcceptedRisk, onPresentRiskDisclaimerRef])

  // Chart Disclaimer
  useEffect(() => {
    if (isChartPaneOpen && showDisclaimer) {
      onPresentChartDisclaimerRef.current()
    }
  }, [onPresentChartDisclaimerRef, isChartPaneOpen, showDisclaimer])

  useEffect(() => {
    if (initialBlock > 0) {
      // Do not start initialization until the first block has been retrieved
      dispatch(initializePredictions(account))
    }
  }, [initialBlock, dispatch, account])

  usePollPredictions()
  usePollOraclePrice()

  if (status === PredictionStatus.INITIAL) {
    return <PageLoader />
  }

  return (
    <>
      <Helmet>
        <script src="https://s3.tradingview.com/tv.js" type="text/javascript" id="tradingViewWidget" />
      </Helmet>
      <SEOHead />
      <SwiperProvider>
        <Container>
          {isDesktop ? <Desktop /> : <Mobile />}
          <CollectWinningsPopup />
        </Container>
      </SwiperProvider>
    </>
  )
}