index.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {css} from '@emotion/react';
  2. import styled from '@emotion/styled';
  3. import type {ModalRenderProps} from 'sentry/actionCreators/modal';
  4. import {closeModal} from 'sentry/actionCreators/modal';
  5. import HighlightModalContainer from 'sentry/components/highlightModalContainer';
  6. import {t, tn} from 'sentry/locale';
  7. import {space} from 'sentry/styles/space';
  8. import type {Organization} from 'sentry/types/organization';
  9. import withSubscription from 'getsentry/components/withSubscription';
  10. import type {Subscription} from 'getsentry/types';
  11. import {getTrialDaysLeft, getTrialLength, hasPerformance} from 'getsentry/utils/billing';
  12. import Details from './details';
  13. type Props = ModalRenderProps & {
  14. organization: Organization;
  15. source: string;
  16. subscription: Subscription;
  17. };
  18. function UpsellModal({source, organization, subscription}: Props) {
  19. const canTrial = subscription.canTrial && !subscription.isTrial;
  20. const headerMessage = subscription.isTrial ? (
  21. <div>
  22. <Subheader>
  23. {tn(
  24. 'Trial Active - %s Day Left',
  25. 'Trial Active - %s Days Left',
  26. getTrialDaysLeft(subscription)
  27. )}
  28. </Subheader>
  29. <Header>{t('Your trial is currently active')}</Header>
  30. </div>
  31. ) : hasPerformance(subscription.planDetails) ? (
  32. <div>
  33. <Subheader>
  34. {canTrial
  35. ? t('%s-day Business Trial', getTrialLength(organization))
  36. : t('Next stop - Business Plan')}
  37. </Subheader>
  38. <Header>{t('Try the upgrade. Regret less.')}</Header>
  39. </div>
  40. ) : (
  41. <div>
  42. <Subheader>
  43. {canTrial
  44. ? t('%s-day Performance Trial', getTrialLength(organization))
  45. : t("But wait there's more")}
  46. </Subheader>
  47. <Header>{t('Get a Performance Boost')}</Header>
  48. </div>
  49. );
  50. return (
  51. <HighlightModalContainer>
  52. <div data-test-id="try-business-modal">
  53. {headerMessage}
  54. <Details
  55. source={source}
  56. subscription={subscription}
  57. organization={organization}
  58. onCloseModal={() => closeModal()}
  59. />
  60. </div>
  61. </HighlightModalContainer>
  62. );
  63. }
  64. const Header = styled('div')`
  65. font-size: ${p => p.theme.headerFontSize};
  66. font-weight: bold;
  67. margin: ${space(1)} 0;
  68. `;
  69. const Subheader = styled('div')`
  70. text-transform: uppercase;
  71. font-weight: bold;
  72. color: ${p => p.theme.purple300};
  73. font-size: ${p => p.theme.fontSizeExtraSmall};
  74. `;
  75. export const modalCss = css`
  76. width: 100%;
  77. max-width: 980px;
  78. [role='document'] {
  79. position: relative;
  80. padding: 70px 80px;
  81. overflow: hidden;
  82. }
  83. `;
  84. export default withSubscription(UpsellModal);