"use client";
import { AlertCircleIcon, type LucideIcon } from "lucide-react";
import type { ReactNode } from "react";
import { Button } from "@/components/ui/button";
import { ApiError } from "@/lib/api";
import { useI18n } from "@/lib/i18n";
import { cn } from "@/lib/utils";
export function PageHeader({
title,
subtitle,
actions,
}: {
title: string;
subtitle?: string;
actions?: ReactNode;
}) {
return (
{title}
{subtitle &&
{subtitle}
}
{actions &&
{actions}
}
);
}
export function EmptyState({
icon: Icon,
title,
hint,
className,
children,
}: {
icon: LucideIcon;
title: string;
hint?: string;
className?: string;
children?: ReactNode;
}) {
return (
{title}
{hint &&
{hint}
}
{children}
);
}
export function ErrorState({ error, onRetry }: { error: Error; onRetry?: () => void }) {
const { t } = useI18n();
const msg =
error instanceof ApiError
? error.status === 403
? t("errors.forbidden")
: error.detail
: error.message === "Failed to fetch"
? t("errors.network")
: error.message;
return (
{msg || t("common.error")}
{onRetry && (
)}
);
}
export function StatTile({
label,
value,
hint,
testId,
}: {
label: string;
value: ReactNode;
hint?: ReactNode;
testId?: string;
}) {
return (
{label}
{value}
{hint &&
{hint}
}
);
}