32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { LoadingState, ErrorState, EmptyState } from "@/components/ds";
|
|
import { WorkspaceApiError } from "@/modules/workspace/services/workspace-api";
|
|
import { PermissionDeniedState } from "@/src/shared/ui";
|
|
|
|
export function WorkspacePageLoader({ label = "در حال بارگذاری فضای کاری…" }: { label?: string }) {
|
|
return <LoadingState label={label} />;
|
|
}
|
|
|
|
export function WorkspacePageError({ error, onRetry }: { error: unknown; onRetry?: () => void }) {
|
|
if (error instanceof WorkspaceApiError && error.status === 403) {
|
|
return <PermissionDeniedState message={error.message || "مجوز لازم وجود ندارد."} />;
|
|
}
|
|
const offline = typeof navigator !== "undefined" && !navigator.onLine;
|
|
if (offline) return <ErrorState message="اتصال اینترنت قطع است." onRetry={onRetry} />;
|
|
const message = error instanceof Error ? error.message : "خطا در دریافت دادهها";
|
|
return <ErrorState message={message} onRetry={onRetry} />;
|
|
}
|
|
|
|
export function WorkspaceEmptyState({
|
|
title = "موردی یافت نشد",
|
|
description = "هنوز دادهای در این بخش ثبت نشده است.",
|
|
action,
|
|
}: {
|
|
title?: string;
|
|
description?: string;
|
|
action?: React.ReactNode;
|
|
}) {
|
|
return <EmptyState title={title} description={description} action={action} />;
|
|
}
|