root.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import { useEffect } from 'react'
  2. import { Alert } from 'react-bootstrap'
  3. import { useTranslation } from 'react-i18next'
  4. import getMeta from '../../../utils/meta'
  5. import EmailsSection from './emails-section'
  6. import AccountInfoSection from './account-info-section'
  7. import PasswordSection from './password-section'
  8. import LinkingSection from './linking-section'
  9. import BetaProgramSection from './beta-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 { ExposedSettings } from '../../../../../types/exposed-settings'
  18. function SettingsPageRoot() {
  19. const { isReady } = useWaitForI18n()
  20. useEffect(() => {
  21. eventTracking.sendMB('settings-view')
  22. }, [])
  23. return (
  24. <div className="container">
  25. <div className="row">
  26. <div className="col-md-12 col-lg-10 col-lg-offset-1">
  27. {isReady ? <SettingsPageContent /> : null}
  28. </div>
  29. </div>
  30. </div>
  31. )
  32. }
  33. function SettingsPageContent() {
  34. const { t } = useTranslation()
  35. const ssoError = getMeta('ol-ssoError') as string
  36. const { isOverleaf } = getMeta('ol-ExposedSettings') as ExposedSettings
  37. return (
  38. <UserProvider>
  39. {ssoError ? (
  40. <Alert bsStyle="danger">
  41. {t('sso_link_error')}: {t(ssoError)}
  42. </Alert>
  43. ) : null}
  44. <div className="card">
  45. <div className="page-header">
  46. <h1>{t('account_settings')}</h1>
  47. </div>
  48. <div>
  49. <EmailsSection />
  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. <SessionsSection />
  69. {isOverleaf ? (
  70. <>
  71. <hr />
  72. <NewsletterSection />
  73. <hr />
  74. <LeaveSection />
  75. </>
  76. ) : null}
  77. </div>
  78. </div>
  79. </UserProvider>
  80. )
  81. }
  82. export default SettingsPageRoot