root.tsx 2.7 KB

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