import React, { Component } from 'react' import { Steps } from 'intro.js-react' import { withTranslation } from 'react-i18next' import { MangoAccount } from '@blockworks-foundation/mango-client' import DepositModal from './DepositModal' export const SHOW_TOUR_KEY = 'showTour' interface Props { connected: boolean mangoAccount: MangoAccount t: any } interface State { steps: any stepsEnabled: boolean initialStep: number showDeposit: boolean } class IntroTips extends Component { steps: any constructor(props) { super(props) this.state = { showDeposit: false, stepsEnabled: true, initialStep: 0, steps: [ { element: '#connect-wallet-tip', intro: (

{this.props.t('connect-wallet-tip-title')}

{this.props.t('connect-wallet-tip-desc')}

), position: 'left', tooltipClass: 'intro-tooltip', highlightClass: 'intro-highlight', }, { element: '#profile-menu-tip', intro: (

{this.props.t('profile-menu-tip-title')}

{this.props.t('profile-menu-tip-desc')}

), tooltipClass: 'intro-tooltip', highlightClass: 'intro-highlight', disableInteraction: true, }, { element: '#data-refresh-tip', intro: (

{this.props.t('data-refresh-tip-title')}

{this.props.t('data-refresh-tip-desc')}

), tooltipClass: 'intro-tooltip', highlightClass: 'intro-highlight', disableInteraction: true, }, { element: '#layout-tip', intro: (

{this.props.t('layout-tip-title')}

{this.props.t('layout-tip-desc')}

), tooltipClass: 'intro-tooltip', highlightClass: 'intro-highlight', disableInteraction: true, }, { element: '#perp-positions-tip', intro: (

{this.props.t('perp-positions-tip-title')}

{this.props.t('perp-positions-tip-desc')}{' '} {this.props.t('read-more')}

), position: 'left', tooltipClass: 'intro-tooltip', highlightClass: 'intro-highlight', disableInteraction: true, }, { element: '#account-details-tip', intro: (

{this.props.t('account-details-tip-title')}

{this.props.t('account-details-tip-desc')}

), position: 'left', tooltipClass: 'intro-tooltip', highlightClass: 'intro-highlight', disableInteraction: true, }, { element: '#account-details-tip', intro: (

{this.props.t('collateral-available-tip-title')}

{this.props.t('collateral-available-tip-desc')}{' '} {this.props.t('read-more')}

), position: 'left', tooltipClass: 'intro-tooltip', highlightClass: 'intro-highlight', disableInteraction: true, }, { element: '#account-details-tip', intro: (

{this.props.t('account-health-tip-title')}

{this.props.t('account-health-tip-desc')}{' '} {this.props.t('read-more')}

), position: 'left', tooltipClass: 'intro-tooltip', highlightClass: 'intro-highlight', disableInteraction: true, }, ], } } closeCreateAccountModal = () => { this.setState({ showDeposit: false }) } handleEndTour = () => { localStorage.setItem('showTour', 'false') this.setState({ stepsEnabled: false }) if (!this.props.mangoAccount) { this.setState({ showDeposit: true }) } } onBeforeChange = (nextStepIndex) => { if (nextStepIndex === 1) { this.steps.updateStepElement(nextStepIndex) const el = document.querySelector('.introjs-nextbutton') if (el) { el.style.pointerEvents = 'auto' el.style.opacity = '100%' } } } componentDidUpdate(prevProps) { if (this.props.connected !== prevProps.connected) { this.steps.introJs.nextStep() } } render() { const { initialStep, showDeposit, stepsEnabled, steps } = this.state return ( <> this.handleEndTour()} options={{ doneLabel: this.props.t('get-started'), exitOnOverlayClick: false, nextLabel: this.props.t('next'), overlayOpacity: 0.6, scrollToElement: true, showBullets: false, showProgress: true, skipLabel: this.props.t('close'), }} ref={(steps) => (this.steps = steps)} /> {showDeposit ? ( ) : null} ) } } export default withTranslation()(IntroTips)