mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-16 10:02:30 +03:00
b0514d6149
* add libraries for traslation purposes * Add button and service for language selection * add spanish translation on login page * add spanish translation on upload page * Add spanish translations for explore page * Add translations on user page * Add translations for config page * Add spanish translations on chat page * add translations for brain page * fix GUI and save on local storage * fix (i18n) init and types * fix (i18n): typos * add translation on new brain modal * add translations on metadata * Add translations on home page * fixes types * fix(frontend-tests): use get by id instead of text --------- Co-authored-by: Gustavo Maciel <gustavo_m13@outlook.com>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { useTranslation } from "react-i18next";
|
|
import { GiBrain } from "react-icons/gi";
|
|
|
|
import { UserStats } from "../../../lib/types/User";
|
|
|
|
export const BrainConsumption = (userStats: UserStats): JSX.Element => {
|
|
const { current_brain_size, max_brain_size } = userStats;
|
|
const brainFilling = current_brain_size / max_brain_size;
|
|
const { t } = useTranslation(["translation","user"]);
|
|
|
|
const backgroundIcon = (
|
|
<GiBrain
|
|
style={{
|
|
position: "absolute",
|
|
width: "100%",
|
|
height: "100%",
|
|
}}
|
|
className="fill-green-200 stroke-black stroke-1"
|
|
/>
|
|
);
|
|
|
|
const fillingIcon = (
|
|
<GiBrain
|
|
style={{
|
|
position: "absolute",
|
|
width: "100%",
|
|
height: "100%",
|
|
clipPath: `inset(${(1 - brainFilling) * 100}% 0 0 0)`,
|
|
}}
|
|
className="fill-pink-300 stroke-black stoke-1"
|
|
/>
|
|
);
|
|
|
|
return (
|
|
<div className="flex flex-col items-center justify-center w-fit">
|
|
<div className="w-24 h-24 relative">
|
|
{backgroundIcon}
|
|
{fillingIcon}
|
|
</div>
|
|
<div className="flex flex-col items-center justify-center">
|
|
<span className="font-semibold">
|
|
{/* Percentage of brain space left */}
|
|
{(100 - brainFilling * 100).toFixed(2)}%{" "}
|
|
</span>
|
|
<span className="text-sm opacity-50">{t("empty", {ns: "user"})}</span>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|