Spaces:
Running
Running
Download web/src/components/shell/page.tsx from Aynkhn/WorkPilot-AI: direct link, hf CLI and curl.
- Browser
- Download file 2.93 kB
-
https://huggingface.co/spaces/Aynkhn/WorkPilot-AI/resolve/main/web/src/components/shell/page.tsx
- Command line
-
hf download hf://spaces/Aynkhn/WorkPilot-AI/web/src/components/shell/page.tsx
-
curl -L -o page.tsx https://huggingface.co/spaces/Aynkhn/WorkPilot-AI/resolve/main/web/src/components/shell/page.tsx
2.93 kB
| "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 ( | |
| <div className="flex flex-wrap items-end justify-between gap-3"> | |
| <div className="space-y-1"> | |
| <h1 className="text-xl font-semibold tracking-tight">{title}</h1> | |
| {subtitle && <p className="max-w-2xl text-sm text-muted-foreground">{subtitle}</p>} | |
| </div> | |
| {actions && <div className="flex items-center gap-2">{actions}</div>} | |
| </div> | |
| ); | |
| } | |
| export function EmptyState({ | |
| icon: Icon, | |
| title, | |
| hint, | |
| className, | |
| children, | |
| }: { | |
| icon: LucideIcon; | |
| title: string; | |
| hint?: string; | |
| className?: string; | |
| children?: ReactNode; | |
| }) { | |
| return ( | |
| <div | |
| className={cn( | |
| "flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed bg-card/50 px-6 py-14 text-center", | |
| className, | |
| )} | |
| data-testid="empty-state" | |
| > | |
| <div className="mb-1 rounded-full bg-muted p-3 text-muted-foreground"> | |
| <Icon className="size-5" aria-hidden /> | |
| </div> | |
| <p className="font-medium">{title}</p> | |
| {hint && <p className="max-w-sm text-sm text-muted-foreground">{hint}</p>} | |
| {children} | |
| </div> | |
| ); | |
| } | |
| 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 ( | |
| <div | |
| role="alert" | |
| className="flex items-center gap-3 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm" | |
| > | |
| <AlertCircleIcon className="size-4 shrink-0 text-destructive" aria-hidden /> | |
| <span className="flex-1">{msg || t("common.error")}</span> | |
| {onRetry && ( | |
| <Button size="sm" variant="outline" onClick={onRetry}> | |
| {t("common.retry")} | |
| </Button> | |
| )} | |
| </div> | |
| ); | |
| } | |
| export function StatTile({ | |
| label, | |
| value, | |
| hint, | |
| testId, | |
| }: { | |
| label: string; | |
| value: ReactNode; | |
| hint?: ReactNode; | |
| testId?: string; | |
| }) { | |
| return ( | |
| <div className="rounded-lg border bg-card px-4 py-3" data-testid={testId}> | |
| <p className="text-xs text-muted-foreground">{label}</p> | |
| <p className="tabular mt-1 text-2xl font-semibold tracking-tight">{value}</p> | |
| {hint && <p className="mt-0.5 text-xs text-muted-foreground">{hint}</p>} | |
| </div> | |
| ); | |
| } | |