fix: Replace unsafe .toFixed() calls with safeFixed() in analytics views

- AnalyticsView: avg_players, uptime_percentage
- WipeAnalyticsView: success_rate, population curve, durations, CSV export
- PlayerRetentionView: retention percentages, session duration, tooltip
- MapAnalyticsView: rotation effectiveness, performance metrics, table

All analytics views now use safe formatter utilities with optional chaining
to prevent null/undefined runtime errors when displaying numeric data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell
2026-02-15 21:56:04 -05:00
parent daa9c3035f
commit 26e717ac96
18 changed files with 111 additions and 53 deletions

View File

@@ -5,6 +5,7 @@ import * as echarts from 'echarts'
import type { ECharts } from 'echarts'
import { useApi } from '@/composables/useApi'
import type { StoreTransaction } from '@/types'
import { safeCurrency, safeDate } from '@/utils/formatters'
const api = useApi()
@@ -41,7 +42,7 @@ const filteredTransactions = computed(() => {
// Format currency properly
const formatCurrency = (amount: number, currency: string = 'USD'): string => {
const symbol = currency === 'USD' ? '$' : currency
return `${symbol}${amount.toFixed(2)}`
return safeCurrency(amount, symbol)
}
// Status badge color classes
@@ -58,13 +59,7 @@ const statusBadgeClass = (status: string): string => {
// Format date for display
const formatDate = (dateStr: string): string => {
return new Date(dateStr).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
})
return safeDate(dateStr, '—')
}
// Load transactions
@@ -122,8 +117,8 @@ const renderRevenueChart = () => {
borderColor: '#2a2a2a',
textStyle: { color: '#e5e5e5' },
formatter: (params: any) => {
const value = params[0].data
return `${params[0].axisValue}<br/>Revenue: $${value.toFixed(2)}`
const value = params[0]?.data
return `${params[0]?.axisValue ?? 'Unknown'}<br/>Revenue: ${safeCurrency(value, '$')}`
}
},
grid: {