Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(profile): refactor achievement to typescript #1025

Merged
merged 6 commits into from
Feb 19, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Max Prettyjohns
* 2023 Meziyum
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -33,7 +34,6 @@ const maxAchievementProgress = {
7: 1,
8: 10,
9: 100,
// eslint-disable-next-line sort-keys
10: 10,
11: 7,
12: 30,
Expand All @@ -57,8 +57,37 @@ const maxAchievementProgress = {
30: 100
};

function Achievement(props) {
const {achievement, counter, unlocked} = props;
interface Props {
meziyum marked this conversation as resolved.
Show resolved Hide resolved
achievement: {
id: number;
name: string;
description: string;
badgeUrl: string;
},
MonkeyDo marked this conversation as resolved.
Show resolved Hide resolved
counter: number;
unlocked: boolean;
};

/**
* Achievement Component
*
* A React component that displays an achievement card with its details, including name,
* description, badge image, and progress if the achievement is locked.
*
* @component
*
* @param {Object} props - The props for the Achievement component.
* @param {Object} props.achievement - The achievement object containing details.
* @param {number} props.achievement.id - The unique ID of the achievement.
* @param {string} props.achievement.name - The name of the achievement.
* @param {string} props.achievement.description - The description of the achievement.
* @param {string} props.achievement.badgeUrl - The URL of the achievement badge image.
* @param {number} props.counter - The current progress or counter for the achievement.
* @param {boolean} props.unlocked - A boolean indicating whether the achievement is unlocked.
*
* @returns {JSX.Element} The rendered Achievement card component.
*/
function Achievement({achievement, counter, unlocked}: Props): React.JSX.Element {
const {id, name, description, badgeUrl} = achievement;
const imgElement = unlocked ? (
<DragAndDropImage
Expand Down
Loading