2020-06-06 01:42:11 +03:00
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import { connect } from "react-redux";
|
|
|
|
import { botType } from "../botType";
|
|
|
|
import Wizard from "./Wizard";
|
2020-06-06 02:07:04 +03:00
|
|
|
import { makeStyles } from "@material-ui/core/styles";
|
|
|
|
|
|
|
|
const useStyles = makeStyles(theme => ({
|
|
|
|
bot: {
|
|
|
|
position: "fixed",
|
|
|
|
bottom: theme.spacing(2),
|
|
|
|
right: theme.spacing(2),
|
|
|
|
zIndex: 1
|
|
|
|
},
|
|
|
|
botPosition: {
|
|
|
|
position: "absolute"
|
|
|
|
}
|
|
|
|
}));
|
2020-06-06 01:42:11 +03:00
|
|
|
|
|
|
|
const BotsManager = ({ bot }) => {
|
|
|
|
const [type, setType] = useState(bot.type);
|
2020-06-06 02:07:04 +03:00
|
|
|
const classes = useStyles();
|
2020-06-06 01:42:11 +03:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (bot.type) setType(bot.type);
|
|
|
|
}, [bot.type]);
|
|
|
|
|
|
|
|
return (
|
2020-06-06 02:07:04 +03:00
|
|
|
<div className={classes.botPosition}>
|
|
|
|
<div className={classes.bot}>{type === botType.wizard && <Wizard />}</div>
|
2020-06-06 01:42:11 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
BotsManager.propTypes = {
|
|
|
|
bot: PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
bot: state.bot
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps() {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(BotsManager);
|