({ collectionInfo, recentSessions }: StatsSummaryGridProps)
| 41 | } |
| 42 | |
| 43 | const StatsSummaryGrid = ({ collectionInfo, recentSessions }: StatsSummaryGridProps) => { |
| 44 | const { t } = useTranslation() |
| 45 | |
| 46 | const averageAccuracy = calculateAverageAccuracy(recentSessions) |
| 47 | const learningTrend = calculateLearningTrend(recentSessions) |
| 48 | |
| 49 | const formattedTrend = |
| 50 | learningTrend !== null ? `${learningTrend > 0 ? '+' : ''}${learningTrend}%` : '-' |
| 51 | |
| 52 | return ( |
| 53 | <SimpleGrid columns={{ base: 1, md: 2, lg: 4 }} gap={4}> |
| 54 | <StatCard label={t('general.words.totalCards')} value={collectionInfo.total_cards} /> |
| 55 | <StatCard |
| 56 | label={t('components.stats.practiceSessions')} |
| 57 | value={collectionInfo.total_practice_sessions} |
| 58 | /> |
| 59 | <StatCard |
| 60 | label={t('components.stats.averageAccuracy')} |
| 61 | value={averageAccuracy !== null ? `${averageAccuracy}%` : '-'} |
| 62 | helpText={ |
| 63 | averageAccuracy !== null |
| 64 | ? t('components.stats.allSessions') |
| 65 | : t('components.stats.noRecentSessions') |
| 66 | } |
| 67 | /> |
| 68 | <StatCard |
| 69 | label={t('components.stats.learningTrend')} |
| 70 | value={formattedTrend} |
| 71 | helpText={ |
| 72 | learningTrend !== null |
| 73 | ? t('components.stats.comparedToPrevious') |
| 74 | : t('components.stats.notEnoughData') |
| 75 | } |
| 76 | valueColor={ |
| 77 | learningTrend !== null |
| 78 | ? learningTrend > 0 |
| 79 | ? 'green.500' |
| 80 | : learningTrend < 0 |
| 81 | ? 'red.500' |
| 82 | : undefined |
| 83 | : undefined |
| 84 | } |
| 85 | /> |
| 86 | </SimpleGrid> |
| 87 | ) |
| 88 | } |
| 89 | |
| 90 | export default StatsSummaryGrid |
nothing calls this directly
no test coverage detected