TorbatYar/frontend/modules/experience/features/publicPreview.tsx
Mortezakoohjani 0eec9f729b feat(experience): deploy Experience frontend FE-11.0-11.5 portal
Commit completed Torbat Pages admin frontend module, BFF proxy, routes, and validation artifacts for official platform deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 21:01:50 +03:30

60 lines
2.3 KiB
TypeScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import { useParams } from "next/navigation";
import { useQuery } from "@tanstack/react-query";
import Link from "next/link";
import { useTenantId } from "@/hooks/useTenantId";
import { experienceApi } from "@/modules/experience/services/experience-api";
import { ExperiencePageLoader, ExperiencePageError } from "@/modules/experience/pages/shared";
import { PageHeader, Card, CardContent, Badge, Button } from "@/components/ds";
export const PublicPreviewPage = function ExperiencePublicPreview() {
const params = useParams();
const type = String(params.type);
const id = String(params.id);
const { tenantId } = useTenantId();
const resourceQ = useQuery({
queryKey: ["experience", tenantId, "preview", type, id],
queryFn: async () => {
if (type === "page") return experienceApi.pages.get(tenantId!, id);
if (type === "site") return experienceApi.sites.get(tenantId!, id);
if (type === "form") return experienceApi.forms.get(tenantId!, id);
throw new Error("نوع نامعتبر");
},
enabled: !!tenantId && !!id,
});
if (!tenantId || resourceQ.isLoading) return <ExperiencePageLoader />;
if (resourceQ.error) return <ExperiencePageError error={resourceQ.error} onRetry={() => resourceQ.refetch()} />;
const r = resourceQ.data!;
const title = String(r.title ?? r.name ?? r.code ?? id);
return (
<div className="min-h-screen bg-[var(--canvas)]">
<header className="border-b border-[var(--border)] bg-[var(--surface)] px-4 py-3">
<div className="mx-auto flex max-w-4xl items-center justify-between">
<Badge tone="info">پیشنمایش عمومی</Badge>
<Badge>publish_id موقت: {id}</Badge>
</div>
</header>
<main className="mx-auto max-w-4xl p-6">
<PageHeader title={title} description={`نوع: ${type}`} />
<Card>
<CardContent className="space-y-4 p-6">
<pre className="overflow-x-auto rounded-lg bg-[var(--surface-muted)] p-4 text-xs">
{JSON.stringify(r, null, 2)}
</pre>
<Link href={`/experience/${type}s`}>
<Button variant="outline">بازگشت به پنل</Button>
</Link>
</CardContent>
</Card>
</main>
</div>
);
};
export default PublicPreviewPage;