Tudor Stanciu c05de1a7dc Merged PR 108: Frontend full upgrade and migration to Typescript
- feat: Add session management components and improve system overview
- feat: Update dependencies and replace react-flags with react-country-flag
- Update dependencies in package.json: reintroduce react-dom and upgrade redux to version 5.0.1
- refactor: update chatbot implementation and dependencies
- refactor: migrate to Redux Toolkit and update dependencies
- feat: enhance ReactCountryFlag component with SVG support
- refactor: remove Bootstrap dependency and update Node engine requirement; add LabelValue component for better UI consistency
- refactor: enhance LabelValue component usage in ServerSummary for improved readability and tooltip support
- refactor: replace inline text with LabelValue component in ActiveSessionSummary and SessionSummary for improved consistency and readability
- refactor: update components to use LabelValue for improved consistency and readability
- refactor: optimize LabelValue component for improved readability and structure
- refactor: improve code readability in SessionForwardsComponent by standardizing arrow function syntax and adjusting styling properties
2025-09-27 23:24:55 +00:00

73 lines
1.6 KiB
TypeScript

import { useEffect, useState } from "react";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { botType, bots, userKey } from "../constants";
import Wizard from "./Wizard";
import { Box } from '@mui/material';
import {
dismissBot,
loadBotSession,
closeChat,
saveMessage
} from "../actionCreators";
interface Props {
bot: {
type: string;
};
actions: {
dismissBot: () => void;
loadBotSession: (bot: string, userKey: string, type: string) => void;
closeChat: () => void;
saveMessage: (message: any) => void;
};
}
const BotsManager: React.FC<Props> = ({ bot, actions }) => {
const [type, setType] = useState(bot.type);
useEffect(() => {
if (!bot.type) return;
setType(bot.type);
if (bot.type === botType.none) return;
actions.loadBotSession(bots.Zirhan, userKey.unknown, bot.type);
}, [actions, bot.type]);
const dismissBot = () => {
actions.closeChat();
actions.dismissBot();
};
return (
<Box
sx={{
position: "fixed",
bottom: 2,
right: 2,
zIndex: 1
}}
>
{type === botType.wizard && (
<Wizard dismissBot={dismissBot} saveMessage={actions.saveMessage} />
)}
</Box>
);
};
function mapStateToProps(state: any) {
return {
bot: state.bot
};
}
function mapDispatchToProps(dispatch: any) {
return {
actions: bindActionCreators(
{ dismissBot, loadBotSession, closeChat, saveMessage },
dispatch
)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(BotsManager as any);