forked from purpleio/purple-admin-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatistic-sample.tsx
66 lines (62 loc) · 2.06 KB
/
statistic-sample.tsx
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
import { IDashboardResponse } from "@/client/sample/dashboard";
import { ArrowDown, ArrowUp } from "lucide-react";
import React from "react";
import CountUp from "react-countup";
interface IStatisticSampleProps {
data: IDashboardResponse;
}
const renderChangeRate = (value: number) => {
if (value > 0) {
return (
<span className="flex items-center px-2 py-1 text-sm text-white rounded-full bg-emerald">
<ArrowUp className="w-5 h-4" />
{value}%
</span>
);
} else if (value < 0) {
return (
<span className="flex items-center px-2 py-1 text-sm text-white rounded-full bg-alizarin">
<ArrowDown className="w-5 h-4" />
{value}%
</span>
);
}
};
const StatisticSample = ({ data }: IStatisticSampleProps) => {
return (
<>
<div className="grid grid-cols-1 gap-5 md:grid-cols-2 lg:grid-cols-3">
<div className="p-5 border rounded-lg ">
<div>방문자</div>
<div className="mt-3">
<div className="flex items-center mt-3">
<div className="text-2xl font-semibold grow">
<CountUp end={data.visitor.value} separator="," />명
</div>
<div>{renderChangeRate(data.visitor.rate)}</div>
</div>
</div>
</div>
<div className="p-5 border rounded-lg ">
<div>주문</div>
<div className="flex items-center mt-3">
<div className="text-2xl font-semibold grow">
<CountUp end={data.order.value} separator="," />건
</div>
<div>{renderChangeRate(data.order.rate)}</div>
</div>
</div>
<div className="p-5 border rounded-lg ">
<div>매출</div>
<div className="flex items-center mt-3">
<div className="text-2xl font-semibold grow">
<CountUp end={data.income.value} separator="," />원
</div>
<div>{renderChangeRate(data.income.rate)}</div>
</div>
</div>
</div>
</>
);
};
export default React.memo(StatisticSample);