import React from "react"; import { connect } from 'react-redux'; import { selectUserState } from '../../../user/reducers/user/selector'; import Toast from './Toast'; // @ts-ignore import styles from "./toast.module.scss"; import { useTranslation } from 'react-i18next'; type Props = { user?: any; } const mapStateToProps = (state: any): any => { return { user: selectUserState(state), }; }; const UserToast = (props: Props) => { const messages = props.user?.get('toastMessages'); const { t } = useTranslation(); const msgs = messages ? Array.from(messages).map((m: any) => { if (m.args.userAdded) return {m.user.name} {t('common:toast.joined')}; else if (m.args.userRemoved) return {m.user.name} {t('common:toast.left')}; }) : []; return ( ); }; export default connect(mapStateToProps)(UserToast);