import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import { me } from '../initial_state' import { openModal } from '../actions/modal' import { CX, BREAKPOINT_EXTRA_SMALL, MODAL_CHAT_CONVERSATION_CREATE, } from '../constants' import Layout from './layout' import Responsive from '../features/ui/util/responsive_component' import List from '../components/list' import ResponsiveClassesComponent from '../features/ui/util/responsive_classes_component' import ChatConversationsSearch from '../features/messages/components/chat_conversations_search' import ChatConversationsList from '../features/messages/components/chat_conversations_list' import ChatSettingsHeader from '../features/messages/components/chat_settings_header' import ChatConversationRequestsListItem from '../features/messages/components/chat_conversations_requests_list_item' class MessagesLayout extends React.PureComponent { onClickAdd = () => { this.props.onOpenChatConversationCreateModal() } render() { const { title, children, isSettings, showBackBtn, source, currentConversationIsRequest, } = this.props const mainBlockClasses = CX({ d: 1, w1015PX: 1, h100PC: 1, flexRow: 1, jcEnd: 1, }) console.log("currentConversationIsRequest:",currentConversationIsRequest) return ( this.onClickAdd(), }, ]} >
{ (isSettings || currentConversationIsRequest) && } { !isSettings && !currentConversationIsRequest &&
}
{children}
) } } const mapStateToProps = (state) => { const selectedId = state.getIn(['chats', 'selectedChatConversationId'], null) const currentConversationIsRequest = selectedId ? !state.getIn(['chat_conversations', selectedId, 'is_approved'], true) : false return { currentConversationIsRequest } } const mapDispatchToProps = (dispatch) => ({ onOpenChatConversationCreateModal() { dispatch(openModal(MODAL_CHAT_CONVERSATION_CREATE)) } }) MessagesLayout.propTypes = { title: PropTypes.string, children: PropTypes.node, isSettings: PropTypes.bool, showBackBtn: PropTypes.bool, source: PropTypes.string, onOpenChatConversationCreateModal: PropTypes.func.isRequired, } export default connect(mapStateToProps, mapDispatchToProps)(MessagesLayout)