root.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 MiscSection from './misc-section'
  10. import LeaveSection from './leave-section'
  11. import * as eventTracking from '../../../infrastructure/event-tracking'
  12. import { UserProvider } from '../../../shared/context/user-context'
  13. import { SSOProvider } from '../context/sso-context'
  14. import useWaitForI18n from '../../../shared/hooks/use-wait-for-i18n'
  15. function SettingsPageRoot() {
  16. const { isReady } = useWaitForI18n()
  17. useEffect(() => {
  18. eventTracking.sendMB('settings-view')
  19. }, [])
  20. return (
  21. <div className="container">
  22. <div className="row">
  23. <div className="col-md-12 col-lg-10 col-lg-offset-1">
  24. {isReady ? <SettingsPageContent /> : null}
  25. </div>
  26. </div>
  27. </div>
  28. )
  29. }
  30. function SettingsPageContent() {
  31. const { t } = useTranslation()
  32. const ssoError = getMeta('ol-ssoError') as string
  33. return (
  34. <UserProvider>
  35. {ssoError ? (
  36. <Alert bsStyle="danger">
  37. {t('sso_link_error')}: {t(ssoError)}
  38. </Alert>
  39. ) : null}
  40. <div className="card">
  41. <div className="page-header">
  42. <h1>{t('account_settings')}</h1>
  43. </div>
  44. <div>
  45. <EmailsSection />
  46. <div className="row">
  47. <div className="col-md-5">
  48. <AccountInfoSection />
  49. </div>
  50. <div className="col-md-5 col-md-offset-1">
  51. <PasswordSection />
  52. </div>
  53. </div>
  54. <hr />
  55. <SSOProvider>
  56. <LinkingSection />
  57. </SSOProvider>
  58. <MiscSection />
  59. <hr />
  60. <LeaveSection />
  61. </div>
  62. </div>
  63. </UserProvider>
  64. )
  65. }
  66. export default SettingsPageRoot