11import { useAuth } from "../auth/AuthContext.jsx" ;
22import { useEffect , useMemo , useState } from "react" ;
33import { JournalDescription } from "./JournalDescription.jsx" ;
4+ import { readJsonResponse } from "../utils/fetchJson.js" ;
45import { resolveStackAssetUrl } from "../utils/mediaUrls.js" ;
56import "./AdminReviewPage.css" ;
67
@@ -156,7 +157,7 @@ function AdminReviewIndex() {
156157 const response = await fetch ( `/api/admin/review/projects?shipSort=${ encodeURIComponent ( shipSort ) } ` , {
157158 credentials : "include" ,
158159 } ) ;
159- const data = await response . json ( ) ;
160+ const data = await readJsonResponse ( response ) ;
160161 if ( ! response . ok ) throw new Error ( data . error || "Failed to load review projects." ) ;
161162 setProjects ( data . projects || [ ] ) ;
162163 setPendingProjects ( data . pendingProjects || [ ] ) ;
@@ -298,7 +299,7 @@ function AdminReviewDetail({ projectId }) {
298299 setMessage ( "" ) ;
299300 try {
300301 const response = await fetch ( `/api/admin/review/projects/${ projectId } ` , { credentials : "include" } ) ;
301- const data = await response . json ( ) ;
302+ const data = await readJsonResponse ( response ) ;
302303 if ( ! response . ok ) throw new Error ( data . error || "Failed to load project." ) ;
303304 setProject ( data . project ) ;
304305 setJournalEntries ( data . journalEntries || [ ] ) ;
@@ -321,7 +322,7 @@ function AdminReviewDetail({ projectId }) {
321322 headers : { "Content-Type" : "application/json" } ,
322323 body : JSON . stringify ( { fraudFlag : nextChecked } ) ,
323324 } ) ;
324- const data = await response . json ( ) ;
325+ const data = await readJsonResponse ( response ) ;
325326 if ( ! response . ok ) throw new Error ( data . error || "Could not save fraud flag." ) ;
326327 setProject ( ( current ) => ( {
327328 ...current ,
@@ -377,7 +378,7 @@ function AdminReviewDetail({ projectId }) {
377378 headers : { "Content-Type" : "application/json" } ,
378379 body : JSON . stringify ( body ) ,
379380 } ) ;
380- const data = await response . json ( ) ;
381+ const data = await readJsonResponse ( response ) ;
381382 if ( ! response . ok ) throw new Error ( data . error || "Failed to submit review." ) ;
382383 setExceedModalOpen ( false ) ;
383384 setExceedAcknowledged ( false ) ;
@@ -425,7 +426,7 @@ function AdminReviewDetail({ projectId }) {
425426 method : "DELETE" ,
426427 credentials : "include" ,
427428 } ) ;
428- const data = await response . json ( ) . catch ( ( ) => ( { } ) ) ;
429+ const data = await readJsonResponse ( response ) ;
429430 if ( ! response . ok ) throw new Error ( data . error || "Failed to delete project." ) ;
430431 window . location . href = "/admin/review" ;
431432 } catch ( err ) {
0 commit comments