badge.tsx 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import styled from '@emotion/styled';
  2. import {Tag} from 'sentry/components/core/badge/tag';
  3. import {t, tn} from 'sentry/locale';
  4. import type {Organization} from 'sentry/types/organization';
  5. import type {Subscription} from 'getsentry/types';
  6. import {getTrialDaysLeft, getTrialLength} from 'getsentry/utils/billing';
  7. type Props = {
  8. organization: Organization;
  9. subscription: Subscription;
  10. };
  11. const TAG_TYPE = 'promotion';
  12. function TrialBadge({subscription, organization}: Props) {
  13. if (subscription.isTrial) {
  14. return (
  15. <Tag type={TAG_TYPE}>
  16. <TrialText>
  17. {tn('%s Day Left', '%s Days Left', getTrialDaysLeft(subscription) || 0)}
  18. </TrialText>
  19. </Tag>
  20. );
  21. }
  22. if (subscription.canTrial) {
  23. return (
  24. <Tag type={TAG_TYPE}>
  25. <TrialText>{t('%s Day Trial', getTrialLength(organization))}</TrialText>
  26. </Tag>
  27. );
  28. }
  29. return null;
  30. }
  31. const TrialText = styled('span')`
  32. font-weight: 400;
  33. `;
  34. export default TrialBadge;