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