MainLayout.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import loadable from '@loadable/component'
  2. import React, { useEffect } from 'react'
  3. import { Route, Routes } from 'react-router-dom'
  4. import { StudioLoading, TopbarBase } from '@/components'
  5. import { BASE_PATHS } from '@/config/routes'
  6. import { isBrowserOutdated } from '@/utils/browser'
  7. import { useDialog } from './providers'
  8. import { AdminView } from './views/admin'
  9. import { LegalLayout } from './views/legal'
  10. import { PlaygroundLayout } from './views/playground'
  11. import { ViewerLayout } from './views/viewer'
  12. const LoadableStudioLayout = loadable(() => import('./views/studio/StudioLayout'), {
  13. fallback: (
  14. <>
  15. <TopbarBase variant="studio" />
  16. <StudioLoading />
  17. </>
  18. ),
  19. })
  20. export const MainLayout: React.FC = () => {
  21. const [openDialog, closeDialog] = useDialog({
  22. title: 'Outdated browser detected',
  23. description:
  24. 'It seems the browser version you are using is not fully supported by Joystream. Some of the features may be broken or not accessible. For the best experience, please upgrade your browser to the latest version.',
  25. variant: 'warning',
  26. primaryButton: {
  27. text: 'Click here to see instructions',
  28. onClick: () => window.open('https://www.whatismybrowser.com/guides/how-to-update-your-browser/auto'),
  29. },
  30. onExitClick: () => closeDialog(),
  31. })
  32. useEffect(() => {
  33. if (isBrowserOutdated) {
  34. openDialog()
  35. }
  36. }, [openDialog])
  37. return (
  38. <Routes>
  39. <Route path={BASE_PATHS.viewer + '/*'} element={<ViewerLayout />} />
  40. <Route path={BASE_PATHS.legal + '/*'} element={<LegalLayout />} />
  41. <Route path={BASE_PATHS.studio + '/*'} element={<LoadableStudioLayout />} />
  42. <Route path={BASE_PATHS.playground + '/*'} element={<PlaygroundLayout />} />
  43. <Route path={BASE_PATHS.admin + '/*'} element={<AdminView />} />
  44. </Routes>
  45. )
  46. }