index.tsx 1.5 KB

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