|
|
|
@ -1,18 +1,27 @@ |
|
|
|
|
import React from "react"; |
|
|
|
|
import React, { useEffect, useRef } from "react"; |
|
|
|
|
import sendIcon from "../../assets/img/vuesax-linear-direct-left.svg"; |
|
|
|
|
import avatar6 from "../../assets/img/avatar/sarah-brown-tTdC88_6a_I-unsplash.jpg"; |
|
|
|
|
import avatar5 from "../../assets/img/avatar/nicolas-horn-MTZTGvDsHFY-unsplash.jpg"; |
|
|
|
|
import { BsCheck2All, BsTelephone, } from "react-icons/bs"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
|
|
|
|
|
const ChatPage = ({ |
|
|
|
|
messages, |
|
|
|
|
user, |
|
|
|
|
contact, |
|
|
|
|
isMobile |
|
|
|
|
}) => { |
|
|
|
|
const messagesEndRef = useRef(null) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
messagesEndRef.current.scrollIntoView({behavior: 'smooth'}) |
|
|
|
|
}, []) |
|
|
|
|
const textareaHanler=(e)=>{ |
|
|
|
|
e.target.style.height = `3rem`; |
|
|
|
|
let scHeight = e.target.scrollHeight; |
|
|
|
|
e.target.style.height = `${scHeight}px`; |
|
|
|
|
} |
|
|
|
|
return( |
|
|
|
|
return(isMobile && |
|
|
|
|
<div className="w-full flex flex-col items-center py-20"> |
|
|
|
|
<div className="bg-gray-100 w-11/12 text-right p-3 text-blue3A text-sm"> |
|
|
|
|
{contact.name} |
|
|
|
@ -27,15 +36,15 @@ const ChatPage = ({ |
|
|
|
|
<div className={` mt-2 w-full flex items-center ${message.userId == user.id ?'justify-end' : 'justify-start'} text-xs`}> |
|
|
|
|
{ |
|
|
|
|
message.userId == user.id &&
|
|
|
|
|
<> |
|
|
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> |
|
|
|
|
<path d="M7.75 12L10.58 14.83L16.25 9.17004" stroke="#979797" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" /> |
|
|
|
|
|
|
|
|
|
</svg> |
|
|
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" style={{marginRight: '-12px'}}> |
|
|
|
|
<path d="M7.75 12L10.58 14.83L16.25 9.17004" stroke="#979797" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" /> |
|
|
|
|
<BsCheck2All |
|
|
|
|
className="text-lg " |
|
|
|
|
style={ |
|
|
|
|
{ color: "#979797" } |
|
|
|
|
|
|
|
|
|
</svg></> |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
} |
|
|
|
|
<p>{message.sendTime}</p> |
|
|
|
|
|
|
|
|
@ -44,7 +53,7 @@ const ChatPage = ({ |
|
|
|
|
</div> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<div ref={messagesEndRef} /> |
|
|
|
|
<div className="Messages-main-box-footer w-full bg-gray-200 px-4 flex items-center justify-between flex-row-reverse fixed bottom-0 "> |
|
|
|
|
<textarea |
|
|
|
|
name="Messages-main-box-footer-textarea" |
|
|
|
@ -132,5 +141,11 @@ ChatPage.defaultProps = { |
|
|
|
|
|
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
|
isMobile: state.publicApi.isMobile, |
|
|
|
|
cart: state.userProduct.list |
|
|
|
|
}); |
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export default ChatPage |
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ChatPage); |