mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
add charts and reset stats function
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user