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 { ExposedSettings } from '../../../../../types/exposed-settings'
  22. import { SSOAlert } from './emails/sso-alert'
  23. function SettingsPageRoot() {
  24. const { isReady } = useWaitForI18n()
  25. useScrollToIdOnLoad()
  26. useEffect(() => {
  27. eventTracking.sendMB('settings-view')
  28. }, [])
  29. return (
  30. <div className="container">
  31. <div className="row">
  32. <div className="col-md-12 col-lg-10 col-lg-offset-1">
  33. {isReady ? <SettingsPageContent /> : null}
  34. </div>
  35. </div>
  36. </div>
  37. )
  38. }
  39. function SettingsPageContent() {
  40. const { t } = useTranslation()
  41. const { isOverleaf, labsEnabled } = getMeta(
  42. 'ol-ExposedSettings'
  43. ) as ExposedSettings
  44. return (
  45. <UserProvider>
  46. <div className="card">
  47. <div className="page-header">
  48. <h1>{t('account_settings')}</h1>
  49. </div>
  50. <div>
  51. <ManagedAccountAlert />
  52. <EmailsSection />
  53. <SSOAlert />
  54. <div className="row">
  55. <div className="col-md-5">
  56. <AccountInfoSection />
  57. </div>
  58. <div className="col-md-5 col-md-offset-1">
  59. <PasswordSection />
  60. </div>
  61. </div>
  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. </div>
  92. </UserProvider>
  93. )
  94. }
  95. export default SettingsPageRoot