index.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Grid from '@mui/material/Grid'
  2. import { makeStyles } from '@material-ui/core'
  3. import { useSelector } from 'react-redux'
  4. import { useState,useRef } from 'react'
  5. import LeftBar from './LeftBar'
  6. import CentralBar from './CentralBar'
  7. import RightBar from './RightBar'
  8. import CallBar from './CallBar';
  9. import { getRightIsOpen } from '../../redux/control/selector'
  10. import { getChatMemo } from '../../redux/chat/selector'
  11. import { getNightMode } from '../../redux/authorization/selector'
  12. import wallpaper from '../../img/wallpaper.jpg'
  13. import wallpaperNight from '../../img/wallpaperNight.jpg'
  14. const useStyles = makeStyles({
  15. container: {
  16. minHeight: '100vh',
  17. maxHeight: '100vh',
  18. },
  19. centralAndRight: {
  20. display:'flex'
  21. },
  22. })
  23. const HomePage = () => {
  24. const classes = useStyles()
  25. const rightIsOpen = useSelector(getRightIsOpen)
  26. const nightMode = useSelector(getNightMode)
  27. const { companionId } = useSelector(getChatMemo)
  28. const chatDivRef = useRef<any>(null)
  29. const [callStatus,setCallStatus] = useState<string>('')
  30. const backgroundImage = `url(${nightMode ? wallpaperNight : wallpaper})`
  31. const handleStartCall = () => setCallStatus('requesting...')
  32. return (
  33. <Grid className={classes.container} container spacing={0} >
  34. <CallBar callStatus={callStatus} setCallStatus={setCallStatus}/>
  35. <LeftBar chatDivRef={chatDivRef} />
  36. {companionId ?
  37. <Grid item lg={9} className={classes.centralAndRight}>
  38. <CentralBar rightIsOpen={rightIsOpen} chatDivRef={chatDivRef}
  39. companionId={companionId} backgroundImage={backgroundImage}
  40. handleStartCall={handleStartCall}/>
  41. <RightBar rightIsOpen={rightIsOpen} chatDivRef={chatDivRef} />
  42. </Grid> :
  43. <Grid item lg={9} style={{backgroundImage}}/>}
  44. </Grid>
  45. )
  46. }
  47. export default HomePage