MainLayout.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import loadable from '@loadable/component'
  2. import React, { useEffect } from 'react'
  3. import { Route, Routes } from 'react-router-dom'
  4. import { StudioLoading } from '@/components/StudioEntrypoint'
  5. import { TopbarBase } from '@/components/Topbar'
  6. import { BASE_PATHS } from '@/config/routes'
  7. import { isBrowserOutdated } from '@/utils/browser'
  8. import { useDialog } from './providers/dialogs'
  9. import { AdminView } from './views/admin'
  10. import { LegalLayout } from './views/legal'
  11. import { PlaygroundLayout } from './views/playground'
  12. import { ViewerLayout } from './views/viewer/ViewerLayout'
  13. const LoadableStudioLayout = loadable(() => import('./views/studio/StudioLayout'), {
  14. fallback: (
  15. <>
  16. <TopbarBase variant="studio" />
  17. <StudioLoading />
  18. </>
  19. ),
  20. })
  21. export const MainLayout: React.FC = () => {
  22. const [openDialog, closeDialog] = useDialog({
  23. title: 'Outdated browser detected',
  24. description:
  25. '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.',
  26. variant: 'warning',
  27. primaryButton: {
  28. text: 'Click here to see instructions',
  29. onClick: () => window.open('https://www.whatismybrowser.com/guides/how-to-update-your-browser/auto'),
  30. },
  31. onExitClick: () => closeDialog(),
  32. })
  33. useEffect(() => {
  34. if (isBrowserOutdated) {
  35. openDialog()
  36. }
  37. }, [openDialog])
  38. return (
  39. <Routes>
  40. <Route path={BASE_PATHS.viewer + '/*'} element={<ViewerLayout />} />
  41. <Route path={BASE_PATHS.legal + '/*'} element={<LegalLayout />} />
  42. <Route path={BASE_PATHS.studio + '/*'} element={<LoadableStudioLayout />} />
  43. <Route path={BASE_PATHS.playground + '/*'} element={<PlaygroundLayout />} />
  44. <Route path={BASE_PATHS.admin + '/*'} element={<AdminView />} />
  45. </Routes>
  46. )
  47. }