import type {ReactNode} from 'react'; import {Fragment} from 'react'; import styled from '@emotion/styled'; import {IconArrow} from 'sentry/icons'; import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {DataCategory} from 'sentry/types/core'; import type {Organization} from 'sentry/types/organization'; import {getFormattedDate} from 'sentry/utils/dates'; import type {PreviewData, Subscription} from 'getsentry/types'; import {formatReservedWithUnits} from 'getsentry/utils/billing'; import {displayPriceWithCents} from 'getsentry/views/amCheckout/utils'; import type {Reservations} from './types'; type Props = { organization: Organization; previewData: PreviewData; reservations: Reservations; subscription: Subscription; }; function PlanTable({organization, previewData, reservations, subscription}: Props) { const hasBillingAccess = organization.access?.includes('org:billing'); const planName = subscription.planDetails.name; const abbr = {isAbbreviated: true}; const {billedAmount, creditApplied, effectiveAt} = previewData; const effectiveNow = new Date(effectiveAt).getTime() <= new Date().getTime() + 3600; return ( {t('Plan Type')} {t('Errors')} {t('Performance Units')} {t('Replays')} {t('Attachments')} {billedAmount === 0 ? null : ( {t('Price Change')} )} {t('Total Due')} {hasBillingAccess && !effectiveNow ? ( {tct('Effective on [date]', {date: getFormattedDate(effectiveAt, 'll')})} ) : null} ); } function TableItem({ children, next, prev, isTotal, }: { children: ReactNode; next: string | number; prev: string | number; isTotal?: boolean; }) { if (prev === next) { return ( {children} {next} ); } return ( {children} {prev} {next} ); } const Wrapper = styled('dl')` display: grid; grid-template-columns: max-content minmax(max-content, auto); `; const PlanLabel = styled('dt')<{hasChanged?: boolean; isTotal?: boolean}>` padding: ${p => (p.isTotal ? space(1) : `${space(0.5)} ${space(1)}`)}; font-weight: ${p => (p.hasChanged || p.isTotal ? 'bold' : 'normal')}; background: ${p => (p.isTotal ? p.theme.purple100 : 'transparent')}; `; const PlanValue = styled(PlanLabel)` text-align: right; & > svg { position: relative; top: 1px; margin-inline: ${space(0.5)}; } `; const EffectiveDate = styled('span')` font-size: ${p => p.theme.fontSizeExtraSmall}; text-align: right; `; export default PlanTable;