diff --git a/apps/web/app/modules/Statistics/Statistics.page.tsx b/apps/web/app/modules/Statistics/Statistics.page.tsx index 825175e4..1290a472 100644 --- a/apps/web/app/modules/Statistics/Statistics.page.tsx +++ b/apps/web/app/modules/Statistics/Statistics.page.tsx @@ -11,26 +11,147 @@ import { RatesChart } from "./components/RatesChart"; export default function StatisticsPage() { const { data: user } = useCurrentUser(); - const chartData = [ - { month: "January", completed: 2, started: 8 }, - { month: "February", completed: 3, started: 5 }, - { month: "March", completed: 2, started: 2 }, - { month: "April", completed: 7, started: 9 }, - { month: "May", completed: 2, started: 3 }, - { month: "June", completed: 2, started: 4 }, - { month: "July", completed: 4, started: 5 }, - { month: "August", completed: 3, started: 6 }, - { month: "September", completed: 6, started: 7 }, - { month: "October", completed: 1, started: 8 }, - { month: "November", completed: 7, started: 9 }, - { month: "December", completed: 8, started: 10 }, - ]; - - const chartData2 = chartData.map((item) => ({ - ...item, - completed: item.completed * 22, - started: item.started * 22, - })); + const data = { + data: { + quizzes: { + totalAttempts: 1, + totalCorrectAnswers: 1, + totalWrongAnswers: 6, + totalQuestions: 7, + averageScore: 14, + uniqueQuizzesTaken: 1, + }, + courses: { + December: { + started: 10, + completed: 8, + completionRate: 80, + }, + January: { + started: 5, + completed: 1, + completionRate: 20, + }, + February: { + started: 2, + completed: 1, + completionRate: 50, + }, + March: { + started: 1, + completed: 1, + completionRate: 100, + }, + April: { + started: 0, + completed: 0, + completionRate: 0, + }, + May: { + started: 12, + completed: 8, + completionRate: 66, + }, + June: { + started: 0, + completed: 0, + completionRate: 0, + }, + July: { + started: 0, + completed: 0, + completionRate: 0, + }, + August: { + started: 0, + completed: 0, + completionRate: 20, + }, + September: { + started: 0, + completed: 3, + completionRate: 75, + }, + October: { + started: 0, + completed: 0, + completionRate: 0, + }, + November: { + started: 0, + completed: 0, + completionRate: 0, + }, + }, + streak: { + current: 0, + longest: 0, + activityHistory: {}, + }, + lessons: { + December: { + started: 0, + completed: 0, + completionRate: 0, + }, + January: { + started: 0, + completed: 0, + completionRate: 0, + }, + February: { + started: 10, + completed: 4, + completionRate: 40, + }, + March: { + started: 0, + completed: 0, + completionRate: 0, + }, + April: { + started: 0, + completed: 0, + completionRate: 0, + }, + May: { + started: 3, + completed: 1, + completionRate: 33, + }, + June: { + started: 6, + completed: 3, + completionRate: 50, + }, + July: { + started: 40, + completed: 20, + completionRate: 50, + }, + August: { + started: 0, + completed: 0, + completionRate: 0, + }, + September: { + started: 0, + completed: 0, + completionRate: 0, + }, + October: { + started: 0, + completed: 0, + completionRate: 33, + }, + November: { + started: 0, + completed: 4, + completionRate: 75, + }, + }, + }, + }; return (
@@ -67,8 +188,8 @@ export default function StatisticsPage() {
- - + +
diff --git a/apps/web/app/modules/Statistics/components/RatesChart.tsx b/apps/web/app/modules/Statistics/components/RatesChart.tsx index 8c25bdd3..7bda8823 100644 --- a/apps/web/app/modules/Statistics/components/RatesChart.tsx +++ b/apps/web/app/modules/Statistics/components/RatesChart.tsx @@ -16,20 +16,24 @@ const chartConfig = { }, } satisfies ChartConfig; -interface ChartData { - month: string; - completed: number; +interface CourseData { started: number; + completed: number; + completionRate: number; } -export const RatesChart = ({ - resourceName, - chartData, -}: { +interface RatesChartProps { resourceName: string; - chartData: ChartData[]; -}) => { - const dataMax = Math.max(...chartData.map((d) => d.started)); + chartData: Record; +} + +export const RatesChart: React.FC = ({ resourceName, chartData }) => { + const data = Object.entries(chartData).map(([month, values]) => ({ + month, + started: values.started, + completed: values.completed, + })); + const dataMax = Math.max(...data.map((d) => d.started)); const step = Math.ceil(dataMax / 10); const yAxisMax = dataMax + step; const ticks = Array.from({ length: Math.floor(yAxisMax / step) }, (_, i) => (i + 1) * step); @@ -43,7 +47,7 @@ export const RatesChart = ({ config={chartConfig} className="mx-auto aspect-square max-h-[450px] w-full h-full" > - +