upgrade-track-changes-modal.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import { useTranslation } from 'react-i18next'
  2. import Icon from '../../../../shared/components/icon'
  3. import { useProjectContext } from '../../../../shared/context/project-context'
  4. import { useUserContext } from '../../../../shared/context/user-context'
  5. import { startFreeTrial, upgradePlan } from '@/main/account-upgrade'
  6. import { memo } from 'react'
  7. import { useFeatureFlag } from '@/shared/context/split-test-context'
  8. import OLModal, {
  9. OLModalBody,
  10. OLModalFooter,
  11. OLModalHeader,
  12. OLModalTitle,
  13. } from '@/features/ui/components/ol/ol-modal'
  14. import OLButton from '@/features/ui/components/ol/ol-button'
  15. import OLRow from '@/features/ui/components/ol/ol-row'
  16. import OLCol from '@/features/ui/components/ol/ol-col'
  17. import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
  18. import MaterialIcon from '@/shared/components/material-icon'
  19. type UpgradeTrackChangesModalProps = {
  20. show: boolean
  21. setShow: React.Dispatch<React.SetStateAction<boolean>>
  22. }
  23. function UpgradeTrackChangesModal({
  24. show,
  25. setShow,
  26. }: UpgradeTrackChangesModalProps) {
  27. const { t } = useTranslation()
  28. const project = useProjectContext()
  29. const user = useUserContext()
  30. const hasNewPaywallCta = useFeatureFlag('paywall-cta')
  31. return (
  32. <OLModal show={show} onHide={() => setShow(false)}>
  33. <OLModalHeader closeButton>
  34. <OLModalTitle>{t('upgrade_to_track_changes')}</OLModalTitle>
  35. </OLModalHeader>
  36. <OLModalBody>
  37. <div className="teaser-video-container">
  38. {/* eslint-disable-next-line jsx-a11y/media-has-caption */}
  39. <video className="teaser-video" autoPlay loop>
  40. <source
  41. src="/img/teasers/track-changes/teaser-track-changes.mp4"
  42. type="video/mp4"
  43. />
  44. <img
  45. src="/img/teasers/track-changes/teaser-track-changes.gif"
  46. alt={t('demonstrating_track_changes_feature')}
  47. />
  48. </video>
  49. </div>
  50. <h4 className="teaser-title">
  51. {t('see_changes_in_your_documents_live')}
  52. </h4>
  53. <OLRow>
  54. <OLCol lg={{ span: 10, offset: 1 }}>
  55. <ul className="list-unstyled">
  56. {[
  57. t('track_any_change_in_real_time'),
  58. t('review_your_peers_work'),
  59. t('accept_or_reject_each_changes_individually'),
  60. ].map(translation => (
  61. <li key={translation}>
  62. <BootstrapVersionSwitcher
  63. bs3={<Icon type="check" />}
  64. bs5={
  65. <MaterialIcon
  66. type="check"
  67. className="align-text-bottom"
  68. />
  69. }
  70. />
  71. &nbsp;{translation}
  72. </li>
  73. ))}
  74. </ul>
  75. </OLCol>
  76. </OLRow>
  77. <p className="small">
  78. {t('already_subscribed_try_refreshing_the_page')}
  79. </p>
  80. {project.owner && (
  81. <div className="text-center">
  82. {project.owner._id === user.id ? (
  83. user.allowedFreeTrial ? (
  84. <OLButton
  85. variant="primary"
  86. onClick={() => startFreeTrial('track-changes')}
  87. >
  88. {hasNewPaywallCta
  89. ? t('get_track_changes')
  90. : t('try_it_for_free')}
  91. </OLButton>
  92. ) : (
  93. <OLButton
  94. variant="primary"
  95. onClick={() => upgradePlan('project-sharing')}
  96. >
  97. {t('upgrade')}
  98. </OLButton>
  99. )
  100. ) : (
  101. <p>
  102. <strong>
  103. {t(
  104. 'please_ask_the_project_owner_to_upgrade_to_track_changes'
  105. )}
  106. </strong>
  107. </p>
  108. )}
  109. </div>
  110. )}
  111. </OLModalBody>
  112. <OLModalFooter>
  113. <OLButton variant="secondary" onClick={() => setShow(false)}>
  114. {t('close')}
  115. </OLButton>
  116. </OLModalFooter>
  117. </OLModal>
  118. )
  119. }
  120. export default memo(UpgradeTrackChangesModal)