Add account hierarchy framework with migrations, RLS policies, and UI components
This commit is contained in:
@@ -1,11 +1,27 @@
|
||||
'use client';
|
||||
|
||||
import {
|
||||
BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer,
|
||||
PieChart, Pie, Cell, Legend,
|
||||
BarChart,
|
||||
Bar,
|
||||
XAxis,
|
||||
YAxis,
|
||||
CartesianGrid,
|
||||
Tooltip,
|
||||
ResponsiveContainer,
|
||||
PieChart,
|
||||
Pie,
|
||||
Cell,
|
||||
Legend,
|
||||
} from 'recharts';
|
||||
|
||||
const COLORS = ['#0d9488', '#14b8a6', '#2dd4bf', '#5eead4', '#99f6e4', '#ccfbf1'];
|
||||
const COLORS = [
|
||||
'#0d9488',
|
||||
'#14b8a6',
|
||||
'#2dd4bf',
|
||||
'#5eead4',
|
||||
'#99f6e4',
|
||||
'#ccfbf1',
|
||||
];
|
||||
|
||||
interface BarChartData {
|
||||
name: string;
|
||||
@@ -17,10 +33,16 @@ interface PieChartData {
|
||||
value: number;
|
||||
}
|
||||
|
||||
export function StatsBarChart({ data, title }: { data: BarChartData[]; title?: string }) {
|
||||
if (data.length === 0 || data.every(d => d.value === 0)) {
|
||||
export function StatsBarChart({
|
||||
data,
|
||||
title,
|
||||
}: {
|
||||
data: BarChartData[];
|
||||
title?: string;
|
||||
}) {
|
||||
if (data.length === 0 || data.every((d) => d.value === 0)) {
|
||||
return (
|
||||
<div className="flex h-64 items-center justify-center text-sm text-muted-foreground">
|
||||
<div className="text-muted-foreground flex h-64 items-center justify-center text-sm">
|
||||
Noch keine Daten vorhanden
|
||||
</div>
|
||||
);
|
||||
@@ -28,25 +50,39 @@ export function StatsBarChart({ data, title }: { data: BarChartData[]; title?: s
|
||||
|
||||
return (
|
||||
<div className="h-64">
|
||||
{title && <p className="mb-2 text-sm font-medium text-muted-foreground">{title}</p>}
|
||||
{title && (
|
||||
<p className="text-muted-foreground mb-2 text-sm font-medium">
|
||||
{title}
|
||||
</p>
|
||||
)}
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart data={data}>
|
||||
<CartesianGrid strokeDasharray="3 3" className="stroke-muted" />
|
||||
<XAxis dataKey="name" className="text-xs" />
|
||||
<YAxis className="text-xs" />
|
||||
<Tooltip />
|
||||
<Bar dataKey="value" fill="var(--primary, #0d9488)" radius={[4, 4, 0, 0]} />
|
||||
<Bar
|
||||
dataKey="value"
|
||||
fill="var(--primary, #0d9488)"
|
||||
radius={[4, 4, 0, 0]}
|
||||
/>
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function StatsPieChart({ data, title }: { data: PieChartData[]; title?: string }) {
|
||||
const filtered = data.filter(d => d.value > 0);
|
||||
export function StatsPieChart({
|
||||
data,
|
||||
title,
|
||||
}: {
|
||||
data: PieChartData[];
|
||||
title?: string;
|
||||
}) {
|
||||
const filtered = data.filter((d) => d.value > 0);
|
||||
if (filtered.length === 0) {
|
||||
return (
|
||||
<div className="flex h-64 items-center justify-center text-sm text-muted-foreground">
|
||||
<div className="text-muted-foreground flex h-64 items-center justify-center text-sm">
|
||||
Noch keine Daten vorhanden
|
||||
</div>
|
||||
);
|
||||
@@ -54,10 +90,24 @@ export function StatsPieChart({ data, title }: { data: PieChartData[]; title?: s
|
||||
|
||||
return (
|
||||
<div className="h-64">
|
||||
{title && <p className="mb-2 text-sm font-medium text-muted-foreground">{title}</p>}
|
||||
{title && (
|
||||
<p className="text-muted-foreground mb-2 text-sm font-medium">
|
||||
{title}
|
||||
</p>
|
||||
)}
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart>
|
||||
<Pie data={filtered} cx="50%" cy="50%" innerRadius={50} outerRadius={80} dataKey="value" label={({ name, percent }) => `${name} (${((percent ?? 0) * 100).toFixed(0)}%)`}>
|
||||
<Pie
|
||||
data={filtered}
|
||||
cx="50%"
|
||||
cy="50%"
|
||||
innerRadius={50}
|
||||
outerRadius={80}
|
||||
dataKey="value"
|
||||
label={({ name, percent }) =>
|
||||
`${name} (${((percent ?? 0) * 100).toFixed(0)}%)`
|
||||
}
|
||||
>
|
||||
{filtered.map((_, i) => (
|
||||
<Cell key={`cell-${i}`} fill={COLORS[i % COLORS.length]} />
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user