generated from Codaisseur/react-redux-jwt-bootstrap-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
101 lines (95 loc) · 2.14 KB
/
index.js
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import React from "react";
import { ProgressBar, Container, Col, Row, Card } from "react-bootstrap";
const expProgress = [
{
rank: "Code Monkey",
total: 30,
},
{
rank: "Coder",
total: 90,
},
{
rank: "Code Wizard",
total: 180,
},
{
rank: "Code Master",
total: 360,
},
];
export default function Progressbar(props) {
const user = props.userData;
console.log("got user data", user);
const rankIcon = () => {
if (user.ranking === "Code Monkey") {
return (
<span role="img" aria-label="monkeyFace">
🐵
</span>
);
} else if (user.ranking === "Coder") {
return (
<span role="img" aria-label="coder">
👨💻
</span>
);
} else if (user.ranking === "Code Wizard") {
return (
<span role="img" aria-label="codeWizard">
🧙
</span>
);
} else {
return (
<span role="img" aria-label="Code Master">
🧞♂️
</span>
);
}
};
function progress() {
const progressNeeded = expProgress.find((exp) => {
console.log("user ranking", user.ranking);
console.log("exp rank", exp.rank);
return exp.rank === user.ranking;
});
console.log("progress", progressNeeded);
return (
<ProgressBar
variant="warning"
now={progressNeeded && (user.totalExp * 100) / progressNeeded.total}
label={progressNeeded && `${user.totalExp}/${progressNeeded.total}`}
/>
);
}
return (
<Container fluid>
<Row>
<Col>
<Card
style={{
width: "12rem",
backgroundColor: "transparent",
}}
>
<Card.Body>
<Card.Title>
<h3
style={{
color: "yellow",
fontSize: 20,
}}
>
{rankIcon()}
{user.ranking}
</h3>
</Card.Title>
{progress()}
</Card.Body>
</Card>
</Col>
</Row>
</Container>
);
}