"use client";
import { LoadingState, ErrorState, EmptyState } from "@/components/ds";
import { PaymentApiError } from "@/modules/payment/services/payment-api";
import { PermissionDeniedState } from "@/src/shared/ui";
export function PaymentPageLoader({ label = "در حال بارگذاری تربتپی…" }: { label?: string }) {
return ;
}
export function PaymentPageError({ error, onRetry }: { error: unknown; onRetry?: () => void }) {
if (error instanceof PaymentApiError && error.status === 403) {
return (
);
}
const offline = typeof navigator !== "undefined" && !navigator.onLine;
if (offline) {
return ;
}
const message = error instanceof Error ? error.message : "خطا در دریافت دادهها";
return ;
}
export function PaymentEmptyState({
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);
}