import styled from '@emotion/styled'; import ButtonBar from 'sentry/components/buttonBar'; import {LinkButton} from 'sentry/components/core/button'; import ExternalLink from 'sentry/components/links/externalLink'; import {IconBusiness} from 'sentry/icons'; import {t, tn} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Organization} from 'sentry/types/organization'; import normalizeUrl from 'sentry/utils/url/normalizeUrl'; import withOrganization from 'sentry/utils/withOrganization'; import {openUpsellModal} from 'getsentry/actionCreators/modal'; import withSubscription from 'getsentry/components/withSubscription'; import type {Subscription} from 'getsentry/types'; import {getTrialDaysLeft} from 'getsentry/utils/billing'; import trackGetsentryAnalytics from 'getsentry/utils/trackGetsentryAnalytics'; type Props = { organization: Organization; source: string; subscription: Subscription; }; function TargetedOnboardingHeader({organization, source, subscription}: Props) { if (!organization) { return null; } const trackClickNeedHelp = () => trackGetsentryAnalytics('growth.onboarding_clicked_need_help', { organization, source, }); const trackClickUpgrade = () => { trackGetsentryAnalytics('growth.onboarding_clicked_upgrade', { source, organization, }); }; // if trial is active, show info on that // otherwise show help button const cta = subscription.isTrial ? ( openUpsellModal({organization, source: 'targeted-onboarding'})} > {t('Trial is Active')}
{tn('%s Day Left', '%s Days Left', getTrialDaysLeft(subscription) || 0)}
) : ( {t('Need help?')} ); return ( {cta} } priority="default" > {t('Upgrade Now')} ); } export default withSubscription(withOrganization(TargetedOnboardingHeader), { noLoader: true, }); const HeaderActionBar = styled(ButtonBar)` margin-left: ${space(2)}; `; const SecondaryCTAWrapper = styled('div')` @media (max-width: ${p => p.theme.breakpoints.small}) { display: none; } `; const NeedHelpLink = styled(ExternalLink)` white-space: nowrap; `; const ActiveTrialHeader = styled('div')` font-size: 14px; text-transform: uppercase; color: ${p => p.theme.purple300}; `; const ActiveTrialWrapper = styled('div')` cursor: pointer; line-height: normal; display: flex; flex-direction: column; align-items: end; `;