"use client";
import { LoadingState, ErrorState, EmptyState } from "@/components/ds";
import { CommunicationApiError } from "@/modules/communication/services/communication-api";
import { PermissionDeniedState } from "@/src/shared/ui";
export function CommunicationPageLoader({ label = "در حال بارگذاری…" }: { label?: string }) {
return ;
}
export function CommunicationPageError({
error,
onRetry,
}: {
error: unknown;
onRetry?: () => void;
}) {
if (error instanceof CommunicationApiError && error.status === 403) {
return (
);
}
const message = error instanceof Error ? error.message : "خطا در دریافت دادهها";
return ;
}
export function CommunicationEmptyState({
title = "موردی یافت نشد",
description = "هنوز دادهای ثبت نشده است.",
action,
}: {
title?: string;
description?: string;
action?: React.ReactNode;
}) {
return ;
}
export function exportToCsv(title: string, rows: Record[], columns: string[]) {
if (rows.length === 0) return;
const header = columns.join(",");
const body = rows
.map((r) => columns.map((c) => JSON.stringify(r[c] ?? "")).join(","))
.join("\n");
const blob = new Blob(["\uFEFF" + header + "\n" + body], { type: "text/csv;charset=utf-8" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `${title}-export.csv`;
a.click();
URL.revokeObjectURL(url);
}