fix: serialize Appwrite rows before sending to client components
Next 16's server-to-client serializer rejects values whose prototype is
not plain Object. node-appwrite returns row objects carrying internal
helpers (toString etc.), so every <ClientComponent prop={row}> crashed with
'Only plain objects, and a few built-ins, can be passed to Client
Components from Server Components.'
Added a tiny toPlain helper that JSON-roundtrips any value and applied it
at the boundary of every query that returns rows consumed by 'use client'
files:
- connection-queries (enrich)
- job-queries (inbound, outbound, approved labs)
- job-file-queries (listJobFiles)
- job-history-queries (listJobHistory)
- prosthetic-queries (listProsthetics, listActiveProsthetics)
- finance-queries (listFinanceEntries)
- notification-helpers (listNotifications)
- dashboard-queries (getDashboardData)
- jobs/[jobId] page (direct getRow for the job prop on JobActionsPanel)
Internal Maps inside queries stay live — only the data crossing the
server/client boundary is normalised.
This commit is contained in:
@@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { listJobFiles } from "@/lib/appwrite/job-file-queries";
|
||||
import { listJobHistory } from "@/lib/appwrite/job-history-queries";
|
||||
import { toPlain } from "@/lib/appwrite/serialize";
|
||||
import {
|
||||
JOB_STATUS_LABELS,
|
||||
JOB_STEP_LABELS,
|
||||
@@ -57,7 +58,7 @@ export default async function JobDetailPage({
|
||||
let job: Job;
|
||||
try {
|
||||
const row = await tablesDB.getRow(DATABASE_ID, TABLES.jobs, jobId);
|
||||
job = row as unknown as Job;
|
||||
job = toPlain(row as unknown as Job);
|
||||
} catch {
|
||||
notFound();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user