diff --git a/frontend/src/pages/Stats.tsx b/frontend/src/pages/Stats.tsx index ef4d445..5ed9a29 100644 --- a/frontend/src/pages/Stats.tsx +++ b/frontend/src/pages/Stats.tsx @@ -1,5 +1,55 @@ -const StatPage = () => { - return
Stats Page
; -}; +import { useEffect, useState } from "react"; +import axios from "axios"; +import { + LineChart, + Line, + XAxis, + YAxis, + Tooltip, + CartesianGrid, + ResponsiveContainer +} from "recharts"; -export default StatPage; \ No newline at end of file +function PostsPerDay() { + const [data, setData] = useState([]); + const [error, setError] = useState(null); + const [loading, setLoading] = useState(true); + + useEffect(() => { + axios + .get("http://localhost:5000/stats/posts_per_day") + .then(res => { + setData(res.data); + setLoading(false); + }) + .catch(err => { + setError(err.response?.data?.error || "Failed to load data"); + setLoading(false); + }); + }, []); + + if (loading) return

Loading posts per day…

; + if (error) return

{error}

; + + return ( +
+

Posts per Day

+ + + + + + + + + + +
+ ); +} + +export default PostsPerDay;