add charts and reset stats function

This commit is contained in:
2025-04-01 14:30:40 +02:00
parent 46d10d6ef4
commit 96a3497aea
7 changed files with 589 additions and 66 deletions
+47
View File
@@ -0,0 +1,47 @@
"use client"
import { LineChart as RechartsLineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
interface LineChartProps {
data: {
date: string;
clicks: number;
}[];
}
export default function LineChart({ data }: LineChartProps) {
return (
<div className="w-full h-[300px] mt-5">
<ResponsiveContainer width="100%" height="100%">
<RechartsLineChart data={data}>
<CartesianGrid strokeDasharray="3 3" stroke="#374151" />
<XAxis
dataKey="date"
stroke="#9CA3AF"
tickFormatter={(value: string) => new Date(value).toLocaleDateString()}
/>
<YAxis
stroke="#9CA3AF"
allowDecimals={false}
/>
<Tooltip
contentStyle={{
backgroundColor: '#1F2937',
border: 'none',
borderRadius: '0.5rem',
color: '#9CA3AF'
}}
labelFormatter={(value: string) => new Date(value).toLocaleDateString()}
/>
<Line
type="monotone"
dataKey="clicks"
stroke="#10B981"
strokeWidth={2}
dot={{ fill: '#10B981', strokeWidth: 2 }}
/>
</RechartsLineChart>
</ResponsiveContainer>
</div>
);
}
+25
View File
@@ -0,0 +1,25 @@
"use client"
import { deletePageStats } from "@/actions/page_actions";
import { useActionState, useEffect } from "react";
import SubmitButton from "../SubmitButton";
import { handleToast } from "@/utils";
import { ArrowPathIcon } from "@heroicons/react/24/solid";
export default function ResetStatsForm({ uuid }: { uuid: string }) {
const initialState = {
message: "",
error: {}
};
const [state, formAction] = useActionState(deletePageStats, initialState);
useEffect(() => { handleToast(state); }, [state]);
return (
<form action={formAction}>
<input type="hidden" name="uuid" value={uuid} />
<SubmitButton><ArrowPathIcon className="button-icon" /></SubmitButton>
</form>
);
}