Created
August 29, 2017 13:44
-
-
Save anonymous/bc0121ab23652513c2639a0aa55c4390 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AgentDashboard extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
username: "", | |
roles: [], | |
joyrideOverlay: true, | |
joyrideType: "continuous", | |
isReady: false, | |
isRunning: false, | |
stepIndex: 0, | |
steps: [], | |
selector: "" | |
}; | |
} | |
componentDidMount() { | |
this.setState({ | |
isReady: true, | |
isRunning: true, | |
}); | |
} | |
addSteps(steps) { | |
let newSteps = steps; | |
if (!Array.isArray(newSteps)) { | |
newSteps = [newSteps]; | |
} | |
if (!newSteps.length) { | |
return; | |
} | |
this.setState(currentState => { | |
currentState.steps = currentState.steps.concat(newSteps); | |
return currentState; | |
}); | |
} | |
callback(data) { | |
this.setState({ | |
selector: data.type === "tooltip:before" ? data.step.selector : "" | |
}); | |
} | |
next() { | |
this.joyride.next(); | |
} | |
render() { | |
const { | |
isReady, | |
isRunning, | |
joyrideOverlay, | |
joyrideType, | |
selector, | |
stepIndex, | |
steps | |
} = this.state; | |
let html; | |
if (isReady) { | |
html = ( | |
<div> | |
<Joyride | |
ref={c => (this.joyride = c)} | |
callback={data => this.callback(data)} | |
debug={false} | |
disableOverlay={selector === ".card-tickets"} | |
locale={{ | |
back: <span>Back</span>, | |
close: <span>Close</span>, | |
last: <span>Last</span>, | |
next: <span>Next</span>, | |
skip: <span>Skip</span> | |
}} | |
run={isRunning} | |
showOverlay={joyrideOverlay} | |
showSkipButton={true} | |
showStepsProgress={true} | |
stepIndex={stepIndex} | |
steps={steps} | |
type={joyrideType} | |
/> | |
<TopNavigation | |
username={this.state.username ? this.state.username : ""} | |
} | |
roles={this.state.roles} | |
/> | |
<main className="imp"> | |
<SideNavigation | |
currentNav={this.props.location.pathname.substring(1)} | |
addSteps={steps => this.addSteps(steps)} | |
selector={selector} | |
next={() => this.next()} | |
/> | |
</main> | |
</div> | |
); | |
} | |
return ( | |
<div> | |
{html} | |
</div> | |
); | |
} | |
} | |
export default connect(mapStateToProps, mapDispatchToProps)(AgentDashboard); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment