Show endcustomer event allowance on dashboard
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-16 14:17:27 +01:00
parent 4c37f874bd
commit 30c653913d
4 changed files with 39 additions and 17 deletions

View File

@@ -168,8 +168,8 @@ export default function MobileDashboardPage() {
const activePackage =
packagesOverview?.activePackage ?? packagesOverview?.packages?.find((pkg) => pkg.active) ?? null;
const remainingEvents = activePackage?.remaining_events ?? null;
const isResellerPackage = activePackage?.package_type === 'reseller';
const remainingEvents = isResellerPackage ? (activePackage?.remaining_events ?? null) : null;
const summarySeenPackageId =
summarySeenOverride ?? onboardingStatus?.steps?.summary_seen_package_id ?? null;
const hasSummaryPackage =
@@ -586,10 +586,17 @@ function PackageSummarySheet({
</Text>
</YStack>
<YStack space="$2" marginTop="$2">
<SummaryRow
label={t('mobileDashboard.packageSummary.remaining', 'Remaining events')}
value={formatPackageLimit(remainingEvents, t)}
/>
{packageType === 'reseller' ? (
<SummaryRow
label={t('mobileDashboard.packageSummary.remaining', 'Remaining events')}
value={formatPackageLimit(remainingEvents, t)}
/>
) : (
<SummaryRow
label={t('mobileDashboard.packageSummary.eventAllowance', 'Event allowance')}
value={t('mobileDashboard.packageSummary.eventPerPurchase', '1 event per purchase')}
/>
)}
<SummaryRow label={t('mobileDashboard.packageSummary.purchased', 'Purchased')} value={formatDate(purchasedAt)} />
{expiresAt ? (
<SummaryRow label={t('mobileDashboard.packageSummary.expires', 'Expires')} value={formatDate(expiresAt)} />
@@ -672,19 +679,28 @@ function PackageSummaryBanner({
const { textStrong, muted, border, surface, accentSoft, primary, surfaceMuted, shadow } = useAdminTheme();
const text = textStrong;
const packageName = activePackage.package_name ?? t('mobileDashboard.packageSummary.fallbackTitle', 'Package summary');
const remainingEvents = typeof activePackage.remaining_events === 'number' ? activePackage.remaining_events : null;
const remainingEvents =
activePackage.package_type === 'reseller' && typeof activePackage.remaining_events === 'number'
? activePackage.remaining_events
: null;
const hasLimit = remainingEvents !== null;
const totalEvents = hasLimit ? activePackage.used_events + remainingEvents : null;
const showProgress = hasLimit && (totalEvents ?? 0) > 0;
const usageLabel = hasLimit
? t('mobileDashboard.packageSummary.bannerUsage', '{{used}} of {{total}} events used', {
used: activePackage.used_events,
total: totalEvents ?? 0,
})
: t('mobileDashboard.packageSummary.bannerUnlimited', 'Unlimited events');
const remainingLabel = hasLimit
? t('mobileDashboard.packageSummary.bannerRemaining', '{{count}} remaining', { count: remainingEvents })
: t('mobileDashboard.packageSummary.bannerRemainingUnlimited', 'No limit');
const usageLabel =
activePackage.package_type === 'reseller'
? hasLimit
? t('mobileDashboard.packageSummary.bannerUsage', '{{used}} of {{total}} events used', {
used: activePackage.used_events,
total: totalEvents ?? 0,
})
: t('mobileDashboard.packageSummary.bannerUnlimited', 'Unlimited events')
: t('mobileDashboard.packageSummary.eventPerPurchase', '1 event per purchase');
const remainingLabel =
activePackage.package_type === 'reseller'
? hasLimit
? t('mobileDashboard.packageSummary.bannerRemaining', '{{count}} remaining', { count: remainingEvents })
: t('mobileDashboard.packageSummary.bannerRemainingUnlimited', 'No limit')
: t('mobileDashboard.packageSummary.eventPerPurchaseShort', 'Per purchase');
const progressMax = totalEvents ?? 0;
const progressValue = Math.min(activePackage.used_events, progressMax);

View File

@@ -20,7 +20,7 @@ const fixtures = vi.hoisted(() => ({
id: 1,
package_id: 1,
package_name: 'Standard',
package_type: 'standard',
package_type: 'reseller',
included_package_slug: null,
active: true,
used_events: 2,
@@ -240,7 +240,7 @@ describe('MobileDashboardPage', () => {
eventContext.hasEvents = true;
eventContext.hasMultipleEvents = false;
fixtures.activePackage.package_type = 'standard';
fixtures.activePackage.package_type = 'reseller';
fixtures.activePackage.remaining_events = 3;
navigateMock.mockClear();
});