Created
August 21, 2021 08:39
-
-
Save hieptl/1bb9938555f83d9c9ac930d8b5a44858 to your computer and use it in GitHub Desktop.
Chat - Uber Clone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import useContext. | |
import { useContext } from 'react'; | |
// import Context. | |
import Context from '../Context'; | |
// import cometchat ui. | |
import { CometChatMessages } from '../cometchat-pro-react-ui-kit/CometChatWorkspace/src'; | |
function Chat() { | |
const { user, currentRide } = useContext(Context); | |
const findUser = () => { | |
if (user && currentRide) { | |
if (user.role === 'user' && currentRide.driver && currentRide.driver.id) { | |
return currentRide.driver.id; | |
} else if (user.role === 'driver' && currentRide.requestor && currentRide.requestor.id) { | |
return currentRide.requestor.id; | |
} | |
} | |
} | |
return ( | |
<div style={{width: '100vw', height:'100vh' }}> | |
<CometChatMessages chatWithUser={findUser()} /> | |
</div> | |
); | |
} | |
export default Chat; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment