Skip to content

Commit

Permalink
Changed FinishedLearningView
Browse files Browse the repository at this point in the history
- moved two buttons into Stack
- added additional hotkey "d" as an additional way to return to the deck
- added translations
  • Loading branch information
h16nning committed Feb 10, 2024
1 parent ecd7ce0 commit e8a2011
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import classes from "./FinishedLearningView.module.css";
import {
Button,
Center,
Expand All @@ -8,19 +7,20 @@ import {
ThemeIcon,
Title,
} from "@mantine/core";
import { useHotkeys } from "@mantine/hooks";
import {
IconClockHour9,
IconHome,
IconTallymarks,
IconTrophy,
} from "@tabler/icons-react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { StopwatchResult } from "react-timer-hook";
import { useHotkeys } from "@mantine/hooks";
import { useSetting } from "../../../logic/Settings";
import Stat from "../../custom/Stat/Stat";
import { useRepetitionAccuracy } from "../../../logic/learn";
import { useTranslation } from "react-i18next";
import Stat from "../../custom/Stat/Stat";
import classes from "./FinishedLearningView.module.css";

interface FinishedLearningViewProps {
ratingsList: number[];
Expand All @@ -41,16 +41,21 @@ function FinishedLearningView({

useHotkeys([["Space", () => navigate("/home")]]);
useHotkeys([["Enter", () => navigate("/home")]]);
useHotkeys([["d", () => navigate(`/deck/${deckId}`)]]);

return (
<Center>
<Stack gap="xl" align="center" pt="xl">
<ThemeIcon size="6rem" radius="60%" className={classes.trophyIcon}>
<IconTrophy stroke={0.75} size={50} />
</ThemeIcon>
<Title>Congratulations{name && ", " + name}!</Title>
<Title>
{name
? t("learning.finished-congrats-name", { name: name })
: t("learning.finished-congrats")}
</Title>
<Text style={{ textAlign: "center" }}>
{t("learning.finished-congratulations")}
{t("learning.finished-info")}
</Text>
<Group wrap="nowrap">
<Stat
Expand All @@ -60,39 +65,36 @@ function FinishedLearningView({
}
icon={IconClockHour9}
color="orange"
width="7rem"
/>
<Stat
name={t("learning.finished-accuracy-ratio")}
value={accuracy ? accuracy + "%" : "not available"}
icon={IconTrophy}
color="green"
width="7rem"
/>
<Stat
name={t("learning.finished-repetions-count")}
value={ratingsList.length}
icon={IconTallymarks}
color="blue"
width="7rem"
/>
</Group>
<Group>
<Stack gap="sm">
<Button
onClick={() => navigate(`/deck/${deckId}`)}
onClick={() => navigate("/home")}
leftSection={<IconHome />}
size="md"
variant="subtle"
>
{t("learning.finished-button-to-deck")}
{t("learning.finished-button-home")}
</Button>
<Button
onClick={() => navigate("/home")}
leftSection={<IconHome />}
onClick={() => navigate(`/deck/${deckId}`)}
size="md"
variant="subtle"
>
{t("learning.finished-button-home")}
{t("learning.finished-button-to-deck")}
</Button>
</Group>
</Stack>
</Stack>
</Center>
);
Expand Down
12 changes: 11 additions & 1 deletion src/i18n/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"new-cards-label": "Neu",
"learning-cards-label": "Lernen",
"review-cards-label": "Wiederholen",
"new-deck-button": "Neues Deck"
"new-deck-button": "Neuer Stapel"
},
"home": {
"welcome-user": "Willkommen zurück, {{name}}!",
Expand Down Expand Up @@ -44,5 +44,15 @@
"developer": {
"title": "Entwickler"
}
},
"learning": {
"finished-congrats": "Herzlichen Glückwunsch!",
"finished-congrats-name": "Herzlichen Glückwunsch, {{name}}!",
"finished-button-home": "Zum Start",
"finished-button-to-deck": "Zurück zum Stapel",
"finished-repetions-count": "Wiederholt",
"finished-accuracy-ratio": "Genauigkeit",
"finished-duration": "Dauer",
"finished-info": "Du hast alle Karten in diesem Stapel für heute gelernt!"
}
}
4 changes: 3 additions & 1 deletion src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
}
},
"learning": {
"finished-congrats": "Congratulations!",
"finished-congrats-name": "Congratulations, {{name}}!",
"finished-button-home": "Go Home",
"finished-button-to-deck": "Back to the deck",
"finished-repetions-count": "Repetitions",
"finished-accuracy-ratio": "Accuracy",
"finished-duration": "Duration",
"finished-congratulations": "You learned all cards for today of this deck."
"finished-info": "You learned all cards for today in this deck."
}
}

0 comments on commit e8a2011

Please sign in to comment.