diff --git a/client/src/components/chat-conversation-list/chat-conversation-list.component.jsx b/client/src/components/chat-conversation-list/chat-conversation-list.component.jsx index 1f9f66e7b..3568a4d20 100644 --- a/client/src/components/chat-conversation-list/chat-conversation-list.component.jsx +++ b/client/src/components/chat-conversation-list/chat-conversation-list.component.jsx @@ -1,120 +1,116 @@ -import {Badge, List, Space, Tag} from "antd"; +import {Badge, Card, List, Space, Tag} from "antd"; import React from "react"; -import { connect } from "react-redux"; -import { - AutoSizer, - CellMeasurer, - CellMeasurerCache, - List as VirtualizedList, -} from "react-virtualized"; -import { createStructuredSelector } from "reselect"; -import { setSelectedConversation } from "../../redux/messaging/messaging.actions"; -import { selectSelectedConversation } from "../../redux/messaging/messaging.selectors"; -import { TimeAgoFormatter } from "../../utils/DateFormatter"; +import {connect} from "react-redux"; +import {AutoSizer, CellMeasurer, CellMeasurerCache, List as VirtualizedList,} from "react-virtualized"; +import {createStructuredSelector} from "reselect"; +import {setSelectedConversation} from "../../redux/messaging/messaging.actions"; +import {selectSelectedConversation} from "../../redux/messaging/messaging.selectors"; +import {TimeAgoFormatter} from "../../utils/DateFormatter"; import PhoneFormatter from "../../utils/PhoneFormatter"; -import OwnerNameDisplay from "../owner-name-display/owner-name-display.component"; - +import OwnerNameDisplay, {OwnerNameDisplayFunction} from "../owner-name-display/owner-name-display.component"; +import _ from "lodash"; import "./chat-conversation-list.styles.scss"; const mapStateToProps = createStructuredSelector({ - selectedConversation: selectSelectedConversation, + selectedConversation: selectSelectedConversation, }); const mapDispatchToProps = (dispatch) => ({ - setSelectedConversation: (conversationId) => - dispatch(setSelectedConversation(conversationId)), + setSelectedConversation: (conversationId) => + dispatch(setSelectedConversation(conversationId)), }); function ChatConversationListComponent({ - conversationList, - selectedConversation, - setSelectedConversation, - loadMoreConversations, -}) { - const cache = new CellMeasurerCache({ - fixedWidth: true, - defaultHeight: 60, - }); + conversationList, + selectedConversation, + setSelectedConversation, + loadMoreConversations, + }) { + const cache = new CellMeasurerCache({ + fixedWidth: true, + defaultHeight: 60, + }); + + const rowRenderer = ({index, key, style, parent}) => { + const item = conversationList[index]; + const cardContentRight = + {item.updated_at}; + const cardContentLeft = item.job_conversations.length > 0 + ? item.job_conversations.map((j, idx) => ( + {j.job.ro_number} + )) + : null; + + const names = <>{_.uniq(item.job_conversations.map((j, idx) => + OwnerNameDisplayFunction(j.job) + ))} + + const cardTitle = <> + {item.label && {item.label}} + {item.job_conversations.length > 0 ? ( + + {names} + + ) : ( + + {item.phone_num} + + )} + + const cardExtra = + const cardStyle = index % 2 === 0 ? {backgroundColor: '#f0f2f5'} : {backgroundColor: '#ffffff'}; + return ( + + setSelectedConversation(item.id)} + style={style} + className={`chat-list-item + ${ + item.id === selectedConversation + ? "chat-list-selected-conversation" + : null + }`} + > + +
+ {cardContentLeft} +
+
{cardContentRight}
+
+
+
+ ); + }; - const rowRenderer = ({ index, key, style, parent }) => { - const item = conversationList[index]; return ( - - setSelectedConversation(item.id)} - style={style} - className={`chat-list-item - ${ - item.id === selectedConversation - ? "chat-list-selected-conversation" - : null - }`} - > - - - {item.label && {item.label}} - {item.job_conversations.length > 0 ? ( - - {item.job_conversations.map((j, idx) => ( - - ))} - - ) : ( - - {item.phone_num} - +
+ + {({height, width}) => ( + { + if (scrollTop + clientHeight === scrollHeight) { + loadMoreConversations(); + } + }} + /> )} - - - - {item.job_conversations.length > 0 - ? item.job_conversations.map((j, idx) => ( - {j.job.ro_number} - )) - : null} - - - {item.updated_at} - - - - - - - - + +
); - }; - - return ( -
- - {({ height, width }) => ( - { - if (scrollTop + clientHeight === scrollHeight) { - loadMoreConversations(); - } - }} - /> - )} - -
- ); } export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(ChatConversationListComponent); diff --git a/client/src/components/chat-conversation-list/chat-conversation-list.styles.scss b/client/src/components/chat-conversation-list/chat-conversation-list.styles.scss index 44f6f8ec8..a63474c04 100644 --- a/client/src/components/chat-conversation-list/chat-conversation-list.styles.scss +++ b/client/src/components/chat-conversation-list/chat-conversation-list.styles.scss @@ -7,10 +7,11 @@ border: 1px solid gainsboro; } .chat-list-item { + .ant-card-head { + border: none; + } &:hover { cursor: pointer; color: #ff7a00; } - - border-bottom: 1px solid gainsboro; -} \ No newline at end of file +}