37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
import React from "react";
|
|
import { connect } from "react-redux";
|
|
import { toggleConversationVisible } from "../../redux/messaging/messaging.actions";
|
|
import AlertComponent from "../alert/alert.component";
|
|
import ChatMessageListComponent from "../chat-messages-list/chat-message-list.component";
|
|
import ChatSendMessage from "../chat-send-message/chat-send-message.component";
|
|
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
|
import { ShrinkOutlined } from "@ant-design/icons";
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
toggleConversationVisible: conversation =>
|
|
dispatch(toggleConversationVisible(conversation))
|
|
});
|
|
|
|
export function ChatConversationOpenComponent({
|
|
conversation,
|
|
messages,
|
|
subState,
|
|
toggleConversationVisible
|
|
}) {
|
|
const [loading, error] = subState;
|
|
|
|
if (loading) return <LoadingSpinner />;
|
|
if (error) return <AlertComponent message={error.message} type='error' />;
|
|
|
|
return (
|
|
<div className='chat-conversation-open'>
|
|
<ShrinkOutlined
|
|
onClick={() => toggleConversationVisible(conversation.id)}
|
|
/>
|
|
<ChatMessageListComponent messages={messages} />
|
|
<ChatSendMessage conversation={conversation} />
|
|
</div>
|
|
);
|
|
}
|
|
export default connect(null, mapDispatchToProps)(ChatConversationOpenComponent);
|