diff --git a/app/routes/reviews.tsx b/app/routes/reviews.tsx index b7ad88f..a3b1541 100644 --- a/app/routes/reviews.tsx +++ b/app/routes/reviews.tsx @@ -196,16 +196,17 @@ export async function loader({ request }: LoaderFunctionArgs) { try { const pointIds = points.map((p: any) => p.pointId).filter(Boolean); if (pointIds.length === 0) return; - const resp = await postgrestGet('/api/postgrest/proxy/evaluation_points', { + const resp = await postgrestGet('/api/postgrest/proxy/evaluation_points', { select: 'id,code', filter: { id: `in.(${[...new Set(pointIds)].join(',')})` }, token: jwt, }); - if (resp.data && Array.isArray(resp.data)) { - const codeMap: Record = {}; - resp.data.forEach((ep: any) => { if (ep.code) codeMap[String(ep.id)] = ep.code; }); - points.forEach((p: any) => { p.pointCode = codeMap[String(p.pointId)] || ''; }); - } + // resp.data 可能是 {code:200, data:[...]} 或直接 [...] + const raw = resp.data; + const epList = Array.isArray(raw) ? raw : (raw?.data && Array.isArray(raw.data) ? raw.data : []); + const codeMap: Record = {}; + epList.forEach((ep: any) => { if (ep.code) codeMap[String(ep.id)] = ep.code; }); + points.forEach((p: any) => { p.pointCode = codeMap[String(p.pointId)] || ''; }); } catch (e) { console.error('[Reviews Loader] patchPointCodes error:', e); }