Files
bodyshop/client/src/components/chat-window/chat-window.container.jsx
2020-02-10 13:52:02 -08:00

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>;
});