mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-18 08:02:03 +03:00
253e866a86
# Description Hope ya'll don't mind, I updated the User Profile's UI to be a bit more readable. Kept the design neutral to not impose styles. I also kept the original toggle buttons for Theme and Language in case we still want to use those in other places in the app, where a select menu isn't necessary. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): https://github.com/StanGirard/quivr/assets/64866427/d0320852-ece1-4002-a180-0005df132e71 https://github.com/StanGirard/quivr/assets/64866427/be3c67ec-8d42-44f9-8131-35a70aec20ef --------- Co-authored-by: Zineb El Bachiri <100568984+gozineb@users.noreply.github.com> Co-authored-by: Stan Girard <girard.stanislas@gmail.com>
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
/* eslint-disable */
|
|
"use client";
|
|
import { format, subDays } from "date-fns";
|
|
import {
|
|
VictoryAxis,
|
|
VictoryChart,
|
|
VictoryChartProps,
|
|
VictoryContainer,
|
|
VictoryLine,
|
|
VictoryTheme,
|
|
} from "victory";
|
|
|
|
type RequestStat = {
|
|
date: string;
|
|
daily_requests_count: number;
|
|
user_id: string;
|
|
};
|
|
|
|
interface RequestsPerDayChartProps extends VictoryChartProps {
|
|
requests_stats: RequestStat[];
|
|
}
|
|
|
|
export const RequestsPerDayChart = ({
|
|
requests_stats,
|
|
...props
|
|
}: RequestsPerDayChartProps): JSX.Element => {
|
|
const data = Array.from({ length: 7 }, (_, i) => subDays(new Date(), i))
|
|
.map((date) => {
|
|
const dateString = format(date, "yyyyMMdd");
|
|
const stat = requests_stats.find((s) => s.date === dateString);
|
|
|
|
return {
|
|
date: format(date, "MM/dd/yyyy"),
|
|
daily_requests_count: stat ? stat.daily_requests_count : 0,
|
|
};
|
|
})
|
|
.reverse();
|
|
|
|
return (
|
|
<VictoryChart
|
|
theme={VictoryTheme.material}
|
|
containerComponent={
|
|
<VictoryContainer
|
|
className="bg-white dark:bg-black rounded-md w-full h-full"
|
|
responsive={true}
|
|
/>
|
|
}
|
|
animate={{
|
|
duration: 1000,
|
|
onLoad: { duration: 1000 },
|
|
}}
|
|
{...props}
|
|
>
|
|
<VictoryAxis
|
|
tickFormat={(tick) => {
|
|
return `${tick.split("/")[0]}/${tick.split("/")[1]}`;
|
|
}}
|
|
/>
|
|
<VictoryAxis dependentAxis />
|
|
<VictoryLine data={data} x="date" y="daily_requests_count" />
|
|
</VictoryChart>
|
|
);
|
|
};
|