root.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 useWaitForI18n from '../../../shared/hooks/use-wait-for-i18n'
  19. import useScrollToIdOnLoad from '../../../shared/hooks/use-scroll-to-id-on-load'
  20. import { SSOAlert } from './emails/sso-alert'
  21. import OLRow from '@/shared/components/ol/ol-row'
  22. import OLCol from '@/shared/components/ol/ol-col'
  23. import OLPageContentCard from '@/shared/components/ol/ol-page-content-card'
  24. import { isSplitTestEnabled } from '@/utils/splitTestUtils'
  25. import NotificationsSection from './notifications-section'
  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('ol-ExposedSettings')
  45. const inNotificationsSplitTest = isSplitTestEnabled('email-notifications')
  46. return (
  47. <UserProvider>
  48. <OLPageContentCard>
  49. <div className="page-header">
  50. <h1>{t('account_settings')}</h1>
  51. </div>
  52. <div>
  53. <ManagedAccountAlert />
  54. <EmailsSection />
  55. <SSOAlert />
  56. <OLRow>
  57. <OLCol lg={5}>
  58. <AccountInfoSection />
  59. </OLCol>
  60. <OLCol lg={{ span: 5, offset: 1 }}>
  61. <PasswordSection />
  62. </OLCol>
  63. </OLRow>
  64. <hr />
  65. <SecuritySection />
  66. <SSOProvider>
  67. <LinkingSection />
  68. </SSOProvider>
  69. {isOverleaf ? (
  70. <>
  71. <BetaProgramSection />
  72. <hr />
  73. </>
  74. ) : null}
  75. {labsEnabled ? (
  76. <>
  77. <LabsProgramSection />
  78. </>
  79. ) : null}
  80. <SessionsSection />
  81. {isOverleaf ? (
  82. <>
  83. <hr />
  84. {inNotificationsSplitTest ? (
  85. <NotificationsSection />
  86. ) : (
  87. <NewsletterSection />
  88. )}
  89. <hr />
  90. <LeaveSection />
  91. </>
  92. ) : null}
  93. </div>
  94. </OLPageContentCard>
  95. </UserProvider>
  96. )
  97. }
  98. export default SettingsPageRoot