25 lines
821 B
JavaScript
25 lines
821 B
JavaScript
import React from "react";
|
|
import { connect } from "react-redux";
|
|
import { createStructuredSelector } from "reselect";
|
|
import { toggleChatVisible } from "../../redux/messaging/messaging.actions";
|
|
import { selectChatVisible } from "../../redux/messaging/messaging.selectors";
|
|
import ChatWindowComponent from "./chat-window.component";
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
|
chatVisible: selectChatVisible
|
|
});
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
toggleChatVisible: () => dispatch(toggleChatVisible())
|
|
});
|
|
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps
|
|
)(function ChatWindowContainer({ chatVisible, toggleChatVisible }) {
|
|
if (chatVisible)
|
|
return <ChatWindowComponent toggleChatVisible={toggleChatVisible} />;
|
|
|
|
return <div onClick={() => toggleChatVisible()}>Chat</div>;
|
|
});
|