forked from SmartDropLabs/smartdrop-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatformStats.tsx
More file actions
78 lines (69 loc) · 2.67 KB
/
Copy pathPlatformStats.tsx
File metadata and controls
78 lines (69 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use client';
import React from 'react';
import { SimpleGrid, Stat, StatLabel, StatNumber, Box, Skeleton } from '@chakra-ui/react';
import { usePlatformStats, UIPlatformStats } from '@/hooks/useSorobanQuery';
const formatCredits = (value: string): string => {
const num = parseFloat(value) || 0;
return `${(num / 1_000_000).toFixed(1)}M XLM`;
};
interface PlatformStatsProps {
initialData?: UIPlatformStats;
}
const cardProps = {
p: 5,
borderWidth: '1px',
borderColor: 'app.border',
borderRadius: 'card',
bg: 'app.surface',
boxShadow: 'card',
transition: 'all 0.2s ease',
_hover: { borderColor: 'app.borderHover', transform: 'translateY(-2px)' },
} as const;
export const PlatformStats: React.FC<PlatformStatsProps> = ({ initialData }) => {
const { data, isLoading } = usePlatformStats(initialData);
const stats = data || initialData;
return (
<SimpleGrid columns={{ base: 2, md: 4 }} spacing={5} mb={8} width="100%">
<Box {...cardProps}>
<Stat>
<StatLabel color="app.muted">Total Value Locked</StatLabel>
<Skeleton isLoaded={!isLoading || !!stats} startColor="app.border" endColor="app.surfaceHover">
<StatNumber fontSize="2xl" fontWeight="extrabold" color="app.accent">
{stats ? formatCredits(stats.tvl) : '0.0M XLM'}
</StatNumber>
</Skeleton>
</Stat>
</Box>
<Box {...cardProps}>
<Stat>
<StatLabel color="app.muted">Active Pools</StatLabel>
<Skeleton isLoaded={!isLoading || !!stats} startColor="app.border" endColor="app.surfaceHover">
<StatNumber fontSize="2xl" fontWeight="extrabold" color="app.accent2">
{stats ? stats.activePools : 0}
</StatNumber>
</Skeleton>
</Stat>
</Box>
<Box {...cardProps}>
<Stat>
<StatLabel color="app.muted">Total Farmers</StatLabel>
<Skeleton isLoaded={!isLoading || !!stats} startColor="app.border" endColor="app.surfaceHover">
<StatNumber fontSize="2xl" fontWeight="extrabold" color="app.accent">
{stats ? stats.totalFarmers.toLocaleString() : 0}
</StatNumber>
</Skeleton>
</Stat>
</Box>
<Box {...cardProps}>
<Stat>
<StatLabel color="app.muted">24h Credit Velocity</StatLabel>
<Skeleton isLoaded={!isLoading || !!stats} startColor="app.border" endColor="app.surfaceHover">
<StatNumber fontSize="2xl" fontWeight="extrabold" color="app.accent2">
{stats ? formatCredits(stats.creditVelocity) : '0.0M XLM'}
</StatNumber>
</Skeleton>
</Stat>
</Box>
</SimpleGrid>
);
};