Benaah's picture
Upload folder using huggingface_hub
fb12607 verified
Raw History Blame Contribute Delete
7.43 kB
"use client";
import React, { useEffect, useState } from "react";
import Link from "next/link";
import { AlertTriangle, RotateCcw, LayoutDashboard, ChevronDown, ChevronUp, Copy, Check } from "lucide-react";
export default function DashboardError({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
const [showDetails, setShowDetails] = useState(false);
const [copied, setCopied] = useState(false);
useEffect(() => {
console.error("[DashboardError caught]:", error);
}, [error]);
const copyDiagnostic = () => {
const text = `Digest: ${error.digest || "none"}\nMessage: ${error.message}\nStack: ${error.stack || "none"}`;
navigator.clipboard?.writeText(text);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};
return (
<div
style={{
flex: 1,
minHeight: "calc(100vh - 120px)",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
padding: "var(--space-8, 2rem)",
textAlign: "center",
}}
>
<div
style={{
maxWidth: 500,
width: "100%",
background: "var(--bg-elevated, #17151F)",
border: "1px solid var(--border-color, #272430)",
borderRadius: "var(--radius-md, 4px)",
padding: "var(--space-8, 2rem) var(--space-6, 1.5rem)",
boxShadow: "0 12px 40px rgba(0, 0, 0, 0.4)",
position: "relative",
overflow: "hidden",
}}
>
{/* Top glowing accent bar */}
<div
style={{
position: "absolute",
top: 0,
left: 0,
right: 0,
height: 2,
background: "linear-gradient(90deg, transparent, var(--color-error, #EF4444), transparent)",
}}
/>
{/* Pulse icon */}
<div
style={{
width: 48,
height: 48,
borderRadius: "var(--radius-md, 4px)",
background: "rgba(239, 68, 68, 0.12)",
border: "1px solid rgba(239, 68, 68, 0.3)",
color: "var(--color-error, #EF4444)",
display: "flex",
alignItems: "center",
justifyContent: "center",
margin: "0 auto var(--space-4, 1rem) auto",
}}
>
<AlertTriangle size={24} />
</div>
<h2
style={{
fontFamily: "var(--font-display, inherit)",
fontSize: "var(--text-lg, 1.125rem)",
fontWeight: 700,
color: "var(--text-primary, #F6F4F8)",
marginBottom: "var(--space-2, 0.5rem)",
}}
>
Failed to load dashboard workspace section
</h2>
<p
style={{
fontSize: "var(--text-sm, 0.875rem)",
color: "var(--text-secondary, #A7A3B4)",
lineHeight: 1.5,
marginBottom: "var(--space-6, 1.5rem)",
}}
>
This dashboard section encountered an issue while retrieving data or rendering. Your data is safe.
</p>
{/* Actions */}
<div
style={{
display: "flex",
flexWrap: "wrap",
gap: "var(--space-3, 0.75rem)",
justifyContent: "center",
marginBottom: "var(--space-4, 1rem)",
}}
>
<button
type="button"
onClick={() => reset()}
className="btn btn-primary"
style={{
display: "inline-flex",
alignItems: "center",
gap: "var(--space-2, 0.5rem)",
padding: "var(--space-2, 0.5rem) var(--space-4, 1rem)",
fontSize: "var(--text-sm, 0.875rem)",
fontWeight: 600,
}}
>
<RotateCcw size={14} /> Retry Section
</button>
<Link
href="/dashboard"
className="btn btn-secondary"
style={{
display: "inline-flex",
alignItems: "center",
gap: "var(--space-2, 0.5rem)",
textDecoration: "none",
padding: "var(--space-2, 0.5rem) var(--space-4, 1rem)",
fontSize: "var(--text-sm, 0.875rem)",
fontWeight: 600,
}}
>
<LayoutDashboard size={14} /> Studio Overview
</Link>
</div>
{/* Diagnostic Accordion */}
<div style={{ textAlign: "left", marginTop: "var(--space-4, 1rem)" }}>
<button
type="button"
onClick={() => setShowDetails(!showDetails)}
style={{
background: "transparent",
border: "none",
color: "var(--text-tertiary, #6D697C)",
fontSize: "var(--text-xs, 0.75rem)",
cursor: "pointer",
display: "inline-flex",
alignItems: "center",
gap: 4,
}}
>
{showDetails ? (
<>
Hide error diagnostic <ChevronUp size={12} />
</>
) : (
<>
Show error diagnostic <ChevronDown size={12} />
</>
)}
</button>
{showDetails && (
<div
style={{
marginTop: "var(--space-2, 0.5rem)",
padding: "var(--space-3, 0.75rem)",
background: "rgba(0, 0, 0, 0.45)",
border: "1px solid var(--border-color-subtle, #1C1924)",
borderRadius: "var(--radius-sm, 2px)",
fontFamily: "var(--font-mono, monospace)",
fontSize: "11px",
color: "var(--text-secondary, #A7A3B4)",
}}
>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
borderBottom: "1px solid var(--border-color-subtle, #1C1924)",
paddingBottom: 4,
marginBottom: 6,
}}
>
<span style={{ color: "var(--color-primary, #FF9F0A)" }}>
Digest: {error.digest || "N/A"}
</span>
<button
type="button"
onClick={copyDiagnostic}
style={{
background: "none",
border: "none",
color: copied ? "var(--color-success, #10B981)" : "var(--text-tertiary, #6D697C)",
fontSize: "10px",
cursor: "pointer",
display: "flex",
alignItems: "center",
gap: 3,
}}
>
{copied ? (
<>
<Check size={11} /> Copied
</>
) : (
<>
<Copy size={11} /> Copy
</>
)}
</button>
</div>
<div style={{ maxHeight: 140, overflowY: "auto", whiteSpace: "pre-wrap", wordBreak: "break-all" }}>
{error.name}: {error.message}
</div>
</div>
)}
</div>
</div>
</div>
);
}