add-collaborators-upgrade.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { useState } from 'react'
  2. import { Trans } from 'react-i18next'
  3. import { Button } from 'react-bootstrap'
  4. import PropTypes from 'prop-types'
  5. import { useUserContext } from '../../../shared/context/user-context'
  6. import { upgradePlan } from '../../../main/account-upgrade'
  7. import StartFreeTrialButton from '../../../shared/components/start-free-trial-button'
  8. import AddCollaboratorsUpgradeContentDefault from './add-collaborators-upgrade-content-default'
  9. import AddCollaboratorsUpgradeContentVariant from './add-collaborators-upgrade-content-variant'
  10. import { useSplitTestContext } from '../../../shared/context/split-test-context'
  11. export default function AddCollaboratorsUpgrade() {
  12. const user = useUserContext({
  13. allowedFreeTrial: PropTypes.bool,
  14. })
  15. const [startedFreeTrial, setStartedFreeTrial] = useState(false)
  16. const { splitTestVariants } = useSplitTestContext({
  17. splitTestVariants: PropTypes.object,
  18. })
  19. const variant = splitTestVariants['project-share-modal-paywall']
  20. return (
  21. <div className={variant === 'default' ? 'add-collaborators-upgrade' : ''}>
  22. {!variant || variant === 'default' ? (
  23. <AddCollaboratorsUpgradeContentDefault />
  24. ) : (
  25. <AddCollaboratorsUpgradeContentVariant />
  26. )}
  27. <p className="text-center row-spaced-thin">
  28. {user.allowedFreeTrial ? (
  29. <StartFreeTrialButton
  30. buttonProps={{ bsStyle: 'success' }}
  31. handleClick={() => setStartedFreeTrial(true)}
  32. source="project-sharing"
  33. />
  34. ) : (
  35. <Button
  36. bsStyle="primary"
  37. onClick={() => {
  38. upgradePlan('project-sharing')
  39. setStartedFreeTrial(true)
  40. }}
  41. >
  42. <Trans i18nKey="upgrade" />
  43. </Button>
  44. )}
  45. </p>
  46. {startedFreeTrial && (
  47. <p className="small">
  48. <Trans i18nKey="refresh_page_after_starting_free_trial" />
  49. </p>
  50. )}
  51. </div>
  52. )
  53. }