root.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import SecuritySection from '@/features/settings/components/security-section'
  2. import { useEffect } from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import getMeta from '../../../utils/meta'
  5. import EmailsSection from './emails-section'
  6. import AccountInfoSection from './account-info-section'
  7. import ManagedAccountAlert from './managed-account-alert'
  8. import PasswordSection from './password-section'
  9. import LinkingSection from './linking-section'
  10. import BetaProgramSection from './beta-program-section'
  11. import LabsProgramSection from './labs-program-section'
  12. import SessionsSection from './sessions-section'
  13. import NewsletterSection from './newsletter-section'
  14. import LeaveSection from './leave-section'
  15. import * as eventTracking from '../../../infrastructure/event-tracking'
  16. import { UserProvider } from '../../../shared/context/user-context'
  17. import { SSOProvider } from '../context/sso-context'
  18. import { SplitTestProvider } from '@/shared/context/split-test-context'
  19. import useWaitForI18n from '../../../shared/hooks/use-wait-for-i18n'
  20. import useScrollToIdOnLoad from '../../../shared/hooks/use-scroll-to-id-on-load'
  21. import { ExposedSettings } from '../../../../../types/exposed-settings'
  22. import { SSOAlert } from './emails/sso-alert'
  23. import OLRow from '@/features/ui/components/ol/ol-row'
  24. import OLCol from '@/features/ui/components/ol/ol-col'
  25. import OLCard from '@/features/ui/components/ol/ol-card'
  26. function SettingsPageRoot() {
  27. const { isReady } = useWaitForI18n()
  28. useScrollToIdOnLoad()
  29. useEffect(() => {
  30. eventTracking.sendMB('settings-view')
  31. }, [])
  32. return (
  33. <div className="container">
  34. <OLRow>
  35. <OLCol xl={{ span: 10, offset: 1 }}>
  36. {isReady ? <SettingsPageContent /> : null}
  37. </OLCol>
  38. </OLRow>
  39. </div>
  40. )
  41. }
  42. function SettingsPageContent() {
  43. const { t } = useTranslation()
  44. const { isOverleaf, labsEnabled } = getMeta(
  45. 'ol-ExposedSettings'
  46. ) as ExposedSettings
  47. return (
  48. <UserProvider>
  49. <OLCard>
  50. <div className="page-header">
  51. <h1>{t('account_settings')}</h1>
  52. </div>
  53. <div>
  54. <ManagedAccountAlert />
  55. <EmailsSection />
  56. <SSOAlert />
  57. <OLRow>
  58. <OLCol lg={5}>
  59. <AccountInfoSection />
  60. </OLCol>
  61. <OLCol lg={{ span: 5, offset: 1 }}>
  62. <PasswordSection />
  63. </OLCol>
  64. </OLRow>
  65. <hr />
  66. <SecuritySection />
  67. <SplitTestProvider>
  68. <SSOProvider>
  69. <LinkingSection />
  70. </SSOProvider>
  71. </SplitTestProvider>
  72. {isOverleaf ? (
  73. <>
  74. <BetaProgramSection />
  75. <hr />
  76. </>
  77. ) : null}
  78. {labsEnabled ? (
  79. <>
  80. <LabsProgramSection />
  81. <hr />
  82. </>
  83. ) : null}
  84. <SessionsSection />
  85. {isOverleaf ? (
  86. <>
  87. <hr />
  88. <NewsletterSection />
  89. <hr />
  90. <LeaveSection />
  91. </>
  92. ) : null}
  93. </div>
  94. </OLCard>
  95. </UserProvider>
  96. )
  97. }
  98. export default SettingsPageRoot