b71edd880b
- getActiveContext now verifies team still exists (teams.get) before trusting the cookie/prefs tenantId, preventing stale E Ofis cookie from causing an onboarding redirect loop - Resolved tenantId from getUserTeams() is now persisted to cookie so subsequent requests skip the resolution path - Added catch+log on presentations data fetch to surface the actual error in server logs
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
export const dynamic = "force-dynamic";
|
|
|
|
import { Query } from "node-appwrite";
|
|
|
|
import { requireTenant } from "@/lib/appwrite/tenant-guard";
|
|
import { listCustomers } from "@/lib/appwrite/customer-queries";
|
|
import { listProperties } from "@/lib/appwrite/property-queries";
|
|
import { DATABASE_ID, TABLES, type Presentation } from "@/lib/appwrite/schema";
|
|
import { createAdminClient } from "@/lib/appwrite/server";
|
|
import { PresentationsClient } from "@/components/presentations/presentations-client";
|
|
|
|
export default async function PresentationsPage() {
|
|
const ctx = await requireTenant();
|
|
const { tablesDB } = createAdminClient();
|
|
|
|
const [customers, properties, presResult] = await Promise.all([
|
|
listCustomers(ctx.tenantId),
|
|
listProperties(ctx.tenantId),
|
|
tablesDB.listRows({
|
|
databaseId: DATABASE_ID,
|
|
tableId: TABLES.presentations,
|
|
queries: [
|
|
Query.equal("tenantId", ctx.tenantId),
|
|
Query.orderDesc("$createdAt"),
|
|
Query.limit(200),
|
|
],
|
|
}),
|
|
]).catch((e) => {
|
|
console.error("[PresentationsPage] data fetch failed:", e);
|
|
throw e;
|
|
});
|
|
|
|
const presentations = JSON.parse(JSON.stringify(presResult.rows)) as Presentation[];
|
|
|
|
return (
|
|
<div className="flex flex-1 flex-col gap-4 p-4 md:p-6">
|
|
<PresentationsClient
|
|
initialPresentations={presentations}
|
|
customers={customers}
|
|
properties={properties}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|