root.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 useWaitForI18n from '../../../shared/hooks/use-wait-for-i18n'
  18. import useScrollToIdOnLoad from '../../../shared/hooks/use-scroll-to-id-on-load'
  19. import { ExposedSettings } from '../../../../../types/exposed-settings'
  20. import { SSOAlert } from './emails/sso-alert'
  21. function SettingsPageRoot() {
  22. const { isReady } = useWaitForI18n()
  23. useScrollToIdOnLoad()
  24. useEffect(() => {
  25. eventTracking.sendMB('settings-view')
  26. }, [])
  27. return (
  28. <div className="container">
  29. <div className="row">
  30. <div className="col-md-12 col-lg-10 col-lg-offset-1">
  31. {isReady ? <SettingsPageContent /> : null}
  32. </div>
  33. </div>
  34. </div>
  35. )
  36. }
  37. function SettingsPageContent() {
  38. const { t } = useTranslation()
  39. const { isOverleaf, labsEnabled } = getMeta(
  40. 'ol-ExposedSettings'
  41. ) as ExposedSettings
  42. return (
  43. <UserProvider>
  44. <div className="card">
  45. <div className="page-header">
  46. <h1>{t('account_settings')}</h1>
  47. </div>
  48. <div>
  49. <ManagedAccountAlert />
  50. <EmailsSection />
  51. <SSOAlert />
  52. <div className="row">
  53. <div className="col-md-5">
  54. <AccountInfoSection />
  55. </div>
  56. <div className="col-md-5 col-md-offset-1">
  57. <PasswordSection />
  58. </div>
  59. </div>
  60. <hr />
  61. <SSOProvider>
  62. <LinkingSection />
  63. </SSOProvider>
  64. {isOverleaf ? (
  65. <>
  66. <BetaProgramSection />
  67. <hr />
  68. </>
  69. ) : null}
  70. {labsEnabled ? (
  71. <>
  72. <LabsProgramSection />
  73. <hr />
  74. </>
  75. ) : null}
  76. <SessionsSection />
  77. {isOverleaf ? (
  78. <>
  79. <hr />
  80. <NewsletterSection />
  81. <hr />
  82. <LeaveSection />
  83. </>
  84. ) : null}
  85. </div>
  86. </div>
  87. </UserProvider>
  88. )
  89. }
  90. export default SettingsPageRoot