root.tsx 2.5 KB

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