-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgressStats.tsx
57 lines (50 loc) · 1.54 KB
/
ProgressStats.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
import { columnColors, columnsLabels } from "@/constants/board";
import { calculateProgress } from "@/helpers/progress";
import { type IGame } from "@/models/GameModel";
import { type IProgressStats } from "@/models/ProgressModel";
import { Text, Group, Progress, useMantineTheme } from "@mantine/core";
import { useMemo, type FC } from "react";
interface IProgressStatsProps {
progress: IGame["progress"];
}
const { platinum, complete } = columnColors;
const ProgressStats: FC<IProgressStatsProps> = (props) => {
const { progress } = props;
const { colors } = useMantineTheme();
const platinumColor = colors[platinum.color][platinum.shade];
const completeColor = colors[complete.color][complete.shade];
const stats: IProgressStats = useMemo(() => {
return calculateProgress(progress);
}, [progress]);
return (
<>
<Group position="apart" mt="xs">
<Text size={12}>{columnsLabels.platinum} Progress</Text>
<Text size={12} fw={500}>
{stats.baseProgress}%
</Text>
</Group>
<Progress
value={stats.baseProgress}
color={platinumColor}
radius="xs"
size="sm"
mt={5}
/>
<Group position="apart" mt="xs">
<Text size={12}>{columnsLabels.complete} Progress</Text>
<Text size={12} fw={500}>
{stats.totalProgress}%
</Text>
</Group>
<Progress
value={stats.totalProgress}
color={completeColor}
radius="xs"
size="sm"
mt={5}
/>
</>
);
};
export default ProgressStats;