From f52b52b16779003035533393287b944ba6cfb227 Mon Sep 17 00:00:00 2001 From: feitianbubu Date: Sat, 4 Jul 2026 23:12:58 +0800 Subject: [PATCH] fix: align dynamic pricing style with log details dialog sections --- .../components/dynamic-pricing-breakdown.tsx | 115 ++++++++++++------ .../components/dialogs/details-dialog.tsx | 5 +- 2 files changed, 83 insertions(+), 37 deletions(-) diff --git a/web/default/src/features/pricing/components/dynamic-pricing-breakdown.tsx b/web/default/src/features/pricing/components/dynamic-pricing-breakdown.tsx index 214007bf..79be84dd 100644 --- a/web/default/src/features/pricing/components/dynamic-pricing-breakdown.tsx +++ b/web/default/src/features/pricing/components/dynamic-pricing-breakdown.tsx @@ -59,6 +59,11 @@ type DynamicPricingBreakdownProps = { * call they are inspecting. Defaults to false (show all configured prices). */ hideCacheColumns?: boolean + /** + * Dense rendering for the usage-log details dialog: drops the colored + * icon header and uses the dialog's small text sizes. Defaults to false. + */ + compact?: boolean } const VAR_LABELS: Record = { @@ -152,6 +157,7 @@ export function DynamicPricingBreakdown({ billingExpr, matchedTierLabel, hideCacheColumns = false, + compact = false, }: DynamicPricingBreakdownProps) { const { t } = useTranslation() const expr = billingExpr || '' @@ -190,20 +196,22 @@ export function DynamicPricingBreakdown({ if (!hasTiers) { return ( -
-
- - - -
-
- {t('Special billing expression')} -
-
- {t('Unable to parse structured pricing')} +
+ {!compact && ( +
+ + + +
+
+ {t('Special billing expression')} +
+
+ {t('Unable to parse structured pricing')} +
-
+ )}
{t('Raw expression')}
@@ -223,24 +231,32 @@ export function DynamicPricingBreakdown({ }) return ( -
-
- - - -
-
- {t('Dynamic Pricing')} -
-
- {t('Prices vary by usage tier and request conditions')} +
+ {!compact && ( +
+ + + +
+
+ {t('Dynamic Pricing')} +
+
+ {t('Prices vary by usage tier and request conditions')} +
-
+ )} {hasTiers && ( -
-
+
+
{t('Tiered price table')}
@@ -289,7 +305,12 @@ export function DynamicPricingBreakdown({
{t(v.shortLabel)}
-
+
{value > 0 ? `${symbol}${(value * rate).toFixed(4)}` : '-'} @@ -304,7 +325,11 @@ export function DynamicPricingBreakdown({
`tier-${index}`} @@ -321,8 +346,11 @@ export function DynamicPricingBreakdown({ { id: 'tier', header: t('Tier'), - className: 'text-muted-foreground py-2 font-medium', - cellClassName: 'py-2.5 align-top', + className: cn( + 'text-muted-foreground py-2 font-medium', + compact && 'h-8' + ), + cellClassName: cn('align-top', compact ? 'py-2' : 'py-2.5'), cell: (tier) => { const condSummary = formatConditionSummary(tier.conditions, t) const isMatched = @@ -359,14 +387,20 @@ export function DynamicPricingBreakdown({ ...visiblePriceFields.map((v, index) => ({ id: v.field ?? `price-${index}`, header: t(v.shortLabel), - className: 'text-muted-foreground py-2 text-right font-medium', - cellClassName: 'py-2.5 text-right align-top font-mono', + className: cn( + 'text-muted-foreground py-2 text-right font-medium', + compact && 'h-8' + ), + cellClassName: cn( + 'text-right align-top font-mono', + compact ? 'py-2' : 'py-2.5' + ), cell: (tier: ParsedTier) => { const value = Number( tier[v.field as string as keyof ParsedTier] || 0 ) return value > 0 ? ( - + {`${symbol}${(value * rate).toFixed(4)}`} ) : ( @@ -381,7 +415,13 @@ export function DynamicPricingBreakdown({ {hasRules && (
-
+
{t('Conditional multipliers')}
    @@ -390,7 +430,12 @@ export function DynamicPricingBreakdown({ key={`group-${gi}`} className='bg-muted/50 flex items-center justify-between gap-3 rounded-md px-3 py-2' > - + {describeGroup(group, t)} + -
+ )} {/* Admin billing mode indicator for non-consume */}