access-attempt-screen.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { FC } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import InviteNotValid from '@/features/share-project/invite-not-valid'
  4. import getMeta from '@/utils/meta'
  5. import { useFeatureFlag } from '@/shared/context/split-test-context'
  6. export const AccessAttemptScreen: FC<{
  7. loadingScreenBrandHeight: string
  8. inflight: boolean
  9. accessError: string | boolean
  10. }> = ({ loadingScreenBrandHeight, inflight, accessError }) => {
  11. const { t } = useTranslation()
  12. const user = getMeta('ol-user')
  13. const isSharingUpdatesEnabled = useFeatureFlag('sharing-updates')
  14. if (isSharingUpdatesEnabled) {
  15. if (accessError) {
  16. return <InviteNotValid email={user?.email} />
  17. }
  18. return (
  19. <div className="vertically-centered-content">
  20. <div className="loading-screen">
  21. <div className="loading-screen-brand-container">
  22. <div
  23. className="loading-screen-brand"
  24. style={{ height: loadingScreenBrandHeight }}
  25. />
  26. </div>
  27. <h3 className="loading-screen-label text-center">
  28. {t('join_project')}
  29. {inflight && <LoadingScreenEllipses />}
  30. </h3>
  31. </div>
  32. </div>
  33. )
  34. }
  35. return (
  36. <div className="loading-screen">
  37. <div className="loading-screen-brand-container">
  38. <div
  39. className="loading-screen-brand"
  40. style={{ height: loadingScreenBrandHeight }}
  41. />
  42. </div>
  43. <h3 className="loading-screen-label text-center">
  44. {t('join_project')}
  45. {inflight && <LoadingScreenEllipses />}
  46. </h3>
  47. {accessError && (
  48. <div className="global-alerts text-center">
  49. <div>
  50. <br />
  51. {accessError === 'not_found' ? (
  52. <div>
  53. <h4 aria-live="assertive">Project not found</h4>
  54. </div>
  55. ) : (
  56. <div>
  57. <div className="alert alert-danger" aria-live="assertive">
  58. {t('token_access_failure')}
  59. </div>
  60. <p>
  61. <a href="/">{t('home')}</a>
  62. </p>
  63. </div>
  64. )}
  65. </div>
  66. </div>
  67. )}
  68. </div>
  69. )
  70. }
  71. const LoadingScreenEllipses = () => (
  72. <span aria-hidden>
  73. <span className="loading-screen-ellip">.</span>
  74. <span className="loading-screen-ellip">.</span>
  75. <span className="loading-screen-ellip">.</span>
  76. </span>
  77. )