Skip to content

Commit 1a083cb

Browse files
committed
Add CriteriaDisplay.jsx
Shows the user what difficulty and language they have selected
1 parent 06e5bec commit 1a083cb

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react';
2+
import { Card, Badge } from 'react-bootstrap';
3+
4+
const getBadgeVariant = (difficulty) => {
5+
switch (difficulty) {
6+
case 'easy':
7+
return 'success';
8+
case 'medium':
9+
return 'warning';
10+
case 'hard':
11+
return 'danger';
12+
default:
13+
return 'secondary'; // in case no difficulty chosen
14+
}
15+
}
16+
17+
const capitalizeFirstLetter = (difficulty) => {
18+
19+
if (difficulty == "cplusplus") {
20+
return difficulty.charAt(0).toUpperCase() + "++"
21+
}
22+
23+
return difficulty.charAt(0).toUpperCase() + difficulty.slice(1);
24+
}
25+
26+
const CriteriaDisplay = ({ difficulty, language }) => {
27+
return (
28+
<Card className="mt-3" style={{ width: '20rem' }}>
29+
<Card.Body>
30+
<Card.Title>Selected Criteria</Card.Title>
31+
<Card.Text>
32+
<span>
33+
Difficulty: <Badge bg={getBadgeVariant(difficulty ? difficulty : "Null" )}>{capitalizeFirstLetter(difficulty ? difficulty : "Null")}</Badge>{' '}
34+
Language: <strong>{capitalizeFirstLetter(language ? language : "???")}</strong>
35+
</span>
36+
</Card.Text>
37+
</Card.Body>
38+
</Card>
39+
)
40+
};
41+
42+
export default CriteriaDisplay;

0 commit comments

Comments
 (0)