mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-18 08:02:03 +03:00
a5c71be731
* ✨ new backend get /user endpoint * ✨ new user page for statistics * 📦 add @mui/material & its dependencies 📦 add prettyBytes package * 🌱 new UserStatistics component for user page * 🏷️ use RequestStat type for requests_stats * ✨ new brainConsumption component * ✨ new Date component * 📦 add date-fns, victory * ✨ requests per day chart * ✨ full UserStatistics component * ✨ put UserStatistics in Card in user's page
48 lines
993 B
TypeScript
48 lines
993 B
TypeScript
import { GiBrain } from "react-icons/gi";
|
|
import { UserStats } from "../types";
|
|
|
|
export const BrainConsumption = (userStats: UserStats): JSX.Element => {
|
|
const { current_brain_size, max_brain_size } = userStats;
|
|
const brainFilling = current_brain_size / max_brain_size;
|
|
|
|
const backgroundIcon = (
|
|
<GiBrain
|
|
style={{
|
|
position: "absolute",
|
|
width: "100%",
|
|
height: "100%",
|
|
stroke: "black",
|
|
}}
|
|
color="grey"
|
|
size={12}
|
|
/>
|
|
);
|
|
|
|
const fillingIcon = (
|
|
<GiBrain
|
|
style={{
|
|
position: "absolute",
|
|
width: "100%",
|
|
height: "100%",
|
|
|
|
clipPath: `inset(${(1 - brainFilling) * 100}% 0 0 0)`,
|
|
stroke: "black",
|
|
}}
|
|
color="#FF69B4"
|
|
stroke="black"
|
|
/>
|
|
);
|
|
return (
|
|
<div
|
|
style={{
|
|
position: "relative",
|
|
width: "100px", // Set a width
|
|
height: "100px", // Set a height
|
|
}}
|
|
>
|
|
{backgroundIcon}
|
|
{fillingIcon}
|
|
</div>
|
|
);
|
|
};
|