root.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. function SettingsPageRoot() {
  19. const { isReady } = useWaitForI18n()
  20. useScrollToIdOnLoad()
  21. useEffect(() => {
  22. eventTracking.sendMB('settings-view')
  23. }, [])
  24. return (
  25. <div className="container">
  26. <div className="row">
  27. <div className="col-md-12 col-lg-10 col-lg-offset-1">
  28. {isReady ? <SettingsPageContent /> : null}
  29. </div>
  30. </div>
  31. </div>
  32. )
  33. }
  34. function SettingsPageContent() {
  35. const { t } = useTranslation()
  36. const { isOverleaf } = getMeta('ol-ExposedSettings') as ExposedSettings
  37. return (
  38. <UserProvider>
  39. <div className="card">
  40. <div className="page-header">
  41. <h1>{t('account_settings')}</h1>
  42. </div>
  43. <div>
  44. <EmailsSection />
  45. <div className="row">
  46. <div className="col-md-5">
  47. <AccountInfoSection />
  48. </div>
  49. <div className="col-md-5 col-md-offset-1">
  50. <PasswordSection />
  51. </div>
  52. </div>
  53. <hr />
  54. <SSOProvider>
  55. <LinkingSection />
  56. </SSOProvider>
  57. {isOverleaf ? (
  58. <>
  59. <BetaProgramSection />
  60. <hr />
  61. </>
  62. ) : null}
  63. <SessionsSection />
  64. {isOverleaf ? (
  65. <>
  66. <hr />
  67. <NewsletterSection />
  68. <hr />
  69. <LeaveSection />
  70. </>
  71. ) : null}
  72. </div>
  73. </div>
  74. </UserProvider>
  75. )
  76. }
  77. export default SettingsPageRoot