reverse-proxy-frontend/src/features/chatbot/components/Wizard.js

102 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-06-06 01:42:11 +03:00
import React from "react";
2020-06-06 03:16:14 +03:00
import PropTypes from "prop-types";
2020-06-06 01:42:11 +03:00
import ChatBot from "react-simple-chatbot";
2020-06-06 02:47:03 +03:00
import { ThemeProvider } from "styled-components";
import { useTheme } from "@material-ui/core/styles";
2020-06-06 03:35:39 +03:00
import { useTranslation } from "react-i18next";
2020-06-06 01:42:11 +03:00
2020-06-06 03:16:14 +03:00
const Wizard = ({ dismissBot }) => {
2020-06-06 02:47:03 +03:00
const theme = useTheme();
2020-06-06 03:35:39 +03:00
const { t } = useTranslation();
2020-06-06 02:47:03 +03:00
const botTheme = {
background: "#f5f8fb",
fontFamily: "monospace",
headerBgColor: theme.palette.primary.main,
headerFontColor: "#fff",
headerFontSize: "16px",
botBubbleColor: theme.palette.primary.main,
botFontColor: "#fff",
userBubbleColor: "#fff",
userFontColor: "#4a4a4a"
};
2020-06-06 01:42:11 +03:00
const steps = [
{
2020-06-06 02:47:03 +03:00
id: "1",
2020-06-06 03:35:39 +03:00
message: t("Chatbot.Wizard.Message1"),
2020-06-06 02:47:03 +03:00
trigger: "2"
2020-06-06 01:42:11 +03:00
},
{
2020-06-06 02:47:03 +03:00
id: "2",
2020-06-06 03:35:39 +03:00
message: t("Chatbot.Wizard.Message2"),
2020-06-06 02:47:03 +03:00
trigger: "3"
},
{
id: "3",
2020-06-06 03:35:39 +03:00
message: t("Chatbot.Wizard.Message3"),
2020-06-06 02:47:03 +03:00
trigger: "4"
},
{
id: "4",
user: true,
trigger: "5"
},
{
id: "5",
2020-06-06 03:35:39 +03:00
message: t("Chatbot.Wizard.Message5"),
2020-06-06 03:16:14 +03:00
trigger: "6"
},
{
id: "6",
user: true,
trigger: "7"
},
{
id: "7",
2020-06-06 03:35:39 +03:00
message: t("Chatbot.Wizard.Message7"),
2020-06-06 03:16:14 +03:00
trigger: "8"
},
{
id: "8",
user: true,
trigger: "9"
},
{
id: "9",
2020-06-06 03:35:39 +03:00
message: t("Chatbot.Wizard.Message9"),
2020-06-06 01:42:11 +03:00
end: true
}
];
2020-06-06 03:16:14 +03:00
const handleEnd = () => {
setTimeout(dismissBot, 3000);
};
2020-06-06 14:21:54 +03:00
const getAvatar = () => {
const basePath = "public/icons/wizard.png";
if (process.env.PUBLIC_URL) {
return `${process.env.PUBLIC_URL}/${basePath}`;
} else {
return basePath;
}
};
2020-06-06 02:47:03 +03:00
return (
<ThemeProvider theme={botTheme}>
<ChatBot
2020-06-06 03:16:14 +03:00
handleEnd={handleEnd}
2020-06-06 02:47:03 +03:00
steps={steps}
2020-06-06 14:21:54 +03:00
botAvatar={getAvatar()}
2020-06-06 02:47:03 +03:00
headerTitle="Zirhan"
/>
</ThemeProvider>
);
2020-06-06 01:42:11 +03:00
};
2020-06-06 03:16:14 +03:00
Wizard.propTypes = {
dismissBot: PropTypes.func.isRequired
};
2020-06-06 01:42:11 +03:00
export default Wizard;