root.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 { SSOAlert } from './emails/sso-alert'
  22. import OLRow from '@/features/ui/components/ol/ol-row'
  23. import OLCol from '@/features/ui/components/ol/ol-col'
  24. import OLCard from '@/features/ui/components/ol/ol-card'
  25. function SettingsPageRoot() {
  26. const { isReady } = useWaitForI18n()
  27. useScrollToIdOnLoad()
  28. useEffect(() => {
  29. eventTracking.sendMB('settings-view')
  30. }, [])
  31. return (
  32. <div className="container">
  33. <OLRow>
  34. <OLCol xl={{ span: 10, offset: 1 }}>
  35. {isReady ? <SettingsPageContent /> : null}
  36. </OLCol>
  37. </OLRow>
  38. </div>
  39. )
  40. }
  41. function SettingsPageContent() {
  42. const { t } = useTranslation()
  43. const { isOverleaf, labsEnabled } = getMeta('ol-ExposedSettings')
  44. return (
  45. <UserProvider>
  46. <OLCard>
  47. <div className="page-header">
  48. <h1>{t('account_settings')}</h1>
  49. </div>
  50. <div>
  51. <ManagedAccountAlert />
  52. <EmailsSection />
  53. <SSOAlert />
  54. <OLRow>
  55. <OLCol lg={5}>
  56. <AccountInfoSection />
  57. </OLCol>
  58. <OLCol lg={{ span: 5, offset: 1 }}>
  59. <PasswordSection />
  60. </OLCol>
  61. </OLRow>
  62. <hr />
  63. <SecuritySection />
  64. <SplitTestProvider>
  65. <SSOProvider>
  66. <LinkingSection />
  67. </SSOProvider>
  68. </SplitTestProvider>
  69. {isOverleaf ? (
  70. <>
  71. <BetaProgramSection />
  72. <hr />
  73. </>
  74. ) : null}
  75. {labsEnabled ? (
  76. <>
  77. <LabsProgramSection />
  78. <hr />
  79. </>
  80. ) : null}
  81. <SessionsSection />
  82. {isOverleaf ? (
  83. <>
  84. <hr />
  85. <NewsletterSection />
  86. <hr />
  87. <LeaveSection />
  88. </>
  89. ) : null}
  90. </div>
  91. </OLCard>
  92. </UserProvider>
  93. )
  94. }
  95. export default SettingsPageRoot