root.tsx 2.9 KB

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