import { Stack, Typography } from '@mui/material'; import type { TLineItemExpanded } from '@blocklet/payment-types'; import { useLocaleContext } from '@arcblock/ux/lib/Locale/context'; import { INTERVAL_LOCALE_KEY } from '../../utils/format'; interface TrialInfoProps { trial: { active: boolean; days: number; afterTrialPrice: string | null; afterTrialInterval: string | null; }; mode: string; items: TLineItemExpanded[]; } export default function TrialInfo({ trial, mode, items }: TrialInfoProps) { const { t } = useLocaleContext(); // Trial: "Then X/month after trial" if (trial.active && trial.afterTrialPrice) { return ( {t('common.nextCharge')} {trial.afterTrialPrice} {trial.afterTrialInterval ? ` ${t(INTERVAL_LOCALE_KEY[trial.afterTrialInterval] || '')}` : ''} ); } // Metered next charge (non-trial) if (!trial.active && ['subscription', 'setup'].includes(mode)) { const meteredItem = items.find( (item: any) => ((item as any).upsell_price || item.price)?.recurring?.usage_type === 'metered' ); if (!meteredItem) return null; const meteredInterval = ((meteredItem as any).upsell_price || meteredItem.price)?.recurring?.interval; if (!meteredInterval) return null; const recurringText = t('common.per', { interval: t(`common.${meteredInterval}`) }); return ( {t('common.nextCharge')} {t('payment.checkout.metered', { recurring: recurringText })} ); } return null; }