import {Fragment} from 'react'; import {css} from '@emotion/react'; import styled from '@emotion/styled'; import partnerMigrationHero from 'getsentry-images/partnership/plan-ending.svg'; import moment from 'moment-timezone'; import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator'; import type {ModalRenderProps} from 'sentry/actionCreators/modal'; import {Client} from 'sentry/api'; import {Tag} from 'sentry/components/core/badge/tag'; import {Button, LinkButton} from 'sentry/components/core/button'; import {IconBusiness} from 'sentry/icons'; import {IconClock} from 'sentry/icons/iconClock'; import {t, tct, tn} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Organization} from 'sentry/types/organization'; import withSubscription from 'getsentry/components/withSubscription'; import type {Subscription} from 'getsentry/types'; import {getContractDaysLeft, isTeamPlanFamily} from 'getsentry/utils/billing'; import trackGetsentryAnalytics from 'getsentry/utils/trackGetsentryAnalytics'; type Props = Pick & { organization: Organization; subscription: Subscription; }; function DeveloperItem(text: string, index: number) { return (
-
{text}
); } function UpgradeItem(text: string, index: number) { return ( {text} ); } function PartnerPlanEndingModal({organization, subscription, closeModal}: Props) { const daysLeft = getContractDaysLeft(subscription); const partnerName = subscription.partner?.partnership.displayName; const api = new Client(); const endpoint = `/organizations/${organization.slug}/partner-migration-request/?referrer=partner_plan_ending_modal`; const handleRequest = () => { api.request(endpoint, { method: 'POST', success: () => { addSuccessMessage(t('Request sent.')); closeModal(); }, error: () => { addErrorMessage(t('Could not send request')); }, }); }; if (daysLeft < 0) { closeModal(); return null; } const isTeam = isTeamPlanFamily(subscription.planDetails); const hasBillingAccess = organization.access?.includes('org:billing'); const endDate = moment(subscription.contractPeriodEnd).add(1, 'days').format('ll'); const lastDay = daysLeft === 0; const returnPlan = isTeam ? t('Team') : t('Business'); const leftColumnItems = [ t('One user'), t('Error monitoring and tracing'), t('Email only notifications'), ]; const rightColumnItems = isTeam ? [ t('Unlimited users'), t('Event volume controls'), t('SSO via Google and Github'), t('Third party integrations'), t('Extended data retention'), t('Custom alerts'), t('And more…'), ] : [ t('Unlimited users'), t('Application Insights'), t('Advanced event volume controls'), t('Custom dashboards'), t('SAML2 & SCIM'), t('Third party integrations'), t('Extended data retention'), t('And more…'), ]; return (
} type={'promotion'}> {tn('%s day left', '%s days left', daysLeft)}

{tct(`Your promotional plan with [partnerName] ends soon`, { partnerName, })}

{tct( ` Your Sentry promotional plan with [partnerName] ends [date]. To keep full functionality, upgrade to stay on your [planName] plan. `, { partnerName, date: lastDay ? 'today' : `on ${moment(subscription.contractPeriodEnd).format('ll')}`, planName: returnPlan, } )}

{tct(`New Plan on [endDate]`, {endDate})} {t('Developer')}

{t('For solo devs working on small projects')}

{leftColumnItems.map(DeveloperItem)}
{t('Recommended Plan')} {tct(`[returnPlan]`, {returnPlan})}

{t('For multiple teams that operate at scale')}

{rightColumnItems.map(UpgradeItem)}
{hasBillingAccess ? ( trackGetsentryAnalytics('partner_billing_migration.modal.clicked_cta', { subscription, organization, daysLeft, partner: subscription.partner?.partnership.id, }) } > {t('Upgrade Now')} ) : ( )}
); } const PartnerPlanHeading = styled('div')` padding: ${space(3)} 0; p { font-size: ${p => p.theme.fontSizeLarge}; margin: 0; } h2 { font-size: 1.5em; } `; const PathWrapper = styled('div')` display: flex; justify-content: space-between; `; const PathContainer = styled('div')` padding: ${space(3)}; grid-auto-rows: max-content; border: 1px solid ${p => p.theme.gray300}; margin-left: auto; margin-right: auto; border-radius: 5px; width: 250px; &:first-of-type { border: 1px solid ${p => p.theme.gray100}; } `; const StyledButtonBar = styled('div')` margin-top: ${space(2)}; display: flex; flex-direction: row; column-gap: 20px; text-align: right; justify-content: right; `; const ImageHeader = styled('div')` margin: -${space(4)} -${space(4)} 0 -${space(4)}; border-radius: ${p => p.theme.borderRadius} ${p => p.theme.borderRadius} 0 0; background-image: url(${partnerMigrationHero}); background-size: cover; background-repeat: no-repeat; background-position: top; height: 200px; @media (max-width: ${p => p.theme.breakpoints.medium}) { margin: -${space(4)} -${space(4)} 0 -${space(4)}; } `; const Bullets = styled('div')` display: grid; grid-template-columns: max-content 1fr; grid-auto-rows: max-content; gap: ${space(1)} ${space(1.5)}; align-items: center; font-size: ${p => p.theme.fontSizeMedium}; margin-bottom: ${space(1)}; `; const PathHeading = styled('h5')` font-weight: bold; margin-bottom: 0; `; const SubHeading = styled('div')` font-weight: bold; font-size: ${p => p.theme.fontSizeMedium}; color: ${p => p.theme.gray300}; text-transform: uppercase; `; export const modalCss = css` width: 100%; max-width: 630px; `; export default withSubscription(PartnerPlanEndingModal);