Skip to content

Commit

Permalink
feature: competition badge give
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxencee committed Mar 22, 2024
1 parent 8d3ede4 commit 81761fb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
22 changes: 21 additions & 1 deletion client/src/pages/flami/FlamiPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { useNavigate } from "react-router";
import { useTheme } from "../../hooks/useTheme";
import FlamiDisplay from "../../components/flami/FlamiDisplay";
import FlamiStats from "../../components/flami/FlamiStats";
import { GenericResponse } from "../../interfaces/api-response/generic-response";
import toast from "react-hot-toast";

const FlamiPage = () => {
const { token } = useAuth();
Expand Down Expand Up @@ -60,7 +62,25 @@ const FlamiPage = () => {
Entrainements
</Button>
<Button
onClick={() => navigate("/competition")}
onClick={() => {
if(!flami?.my_flami) return;
let level = flami.my_flami.stats.speed < 3 ? 'bronze' : flami.my_flami.stats.speed > 7 ? 'or' : 'argent';
APIHandler<GenericResponse>(
`/misc/g/badge/sport_course_${level}`,
false,
"GET",
undefined,
token
).then(() => {
toast.success(`Tu as récuperé le badge de course en ${level}.`, {
style: {
background: "#3D3D3D",
color: "#FAFAFA",
borderRadius: "12px",
},
});
});
}}
className="bg-alabaster-900 col-span-2 border-tree-poppy-300 shadow-tree-poppy-300 border-3 flex flex-col items-center gap-2 rounded-xl hover:brightness-90 active:shadow-none active:translate-y-1"
>
<img
Expand Down
14 changes: 7 additions & 7 deletions server/data/badges.json
Original file line number Diff line number Diff line change
Expand Up @@ -819,11 +819,11 @@
"name": "Course (Bronze)",
"url": "\/assets\/img\/badges\/Bronze-course.svg",
"url_cover": "\/assets\/img\/badges\/Bronze-course.svg",
"description": "",
"description": "Victoire de compétition de course.",
"type": "sport",
"id": "sport_course_bronze",
"description_region": "",
"region": "Course"
"description_region": "Victoire de compétition de course.",
"region": "Course (Bronze)"
},
"sport_course_argent": {
"name": "Course (Argent)",
Expand All @@ -832,8 +832,8 @@
"description": "Victoire de compétition de course.",
"type": "sport",
"id": "sport_course_argent",
"description_region": "",
"region": "Course"
"description_region": "Victoire de compétition de course.",
"region": "Course (Argent)"
},
"sport_course_or": {
"name": "Course (Or)",
Expand All @@ -842,7 +842,7 @@
"description": "Victoire de compétition de course.",
"type": "sport",
"id": "sport_course_or",
"description_region": "",
"region": "Course"
"description_region": "Victoire de compétition de course.",
"region": "Course (Or)"
}
}

0 comments on commit 81761fb

Please sign in to comment.