Wire Admin and GameDevelopment to API-backed Featured Studios
cgen-ceca13f6d7864095a31569d3ef3db530
This commit is contained in:
parent
8bb2b77bc5
commit
7636ec23ab
1 changed files with 16 additions and 14 deletions
|
|
@ -62,13 +62,12 @@ export default function Admin() {
|
|||
} catch {
|
||||
setDemoProfiles([]);
|
||||
}
|
||||
try {
|
||||
const raw = localStorage.getItem("featured_studios");
|
||||
if (raw) {
|
||||
const parsed = JSON.parse(raw);
|
||||
if (Array.isArray(parsed) && parsed.length) setStudios(parsed);
|
||||
}
|
||||
} catch {}
|
||||
fetch("/api/featured-studios")
|
||||
.then((r) => r.ok ? r.json() : [])
|
||||
.then((data) => {
|
||||
if (Array.isArray(data) && data.length) setStudios(data);
|
||||
})
|
||||
.catch(() => void 0);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -283,13 +282,16 @@ export default function Admin() {
|
|||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
try {
|
||||
localStorage.setItem(
|
||||
"featured_studios",
|
||||
JSON.stringify(studios),
|
||||
);
|
||||
} catch {}
|
||||
onClick={async () => {
|
||||
const resp = await fetch("/api/featured-studios", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ studios }),
|
||||
});
|
||||
if (!resp.ok) {
|
||||
alert("Failed to save studios");
|
||||
return;
|
||||
}
|
||||
}}
|
||||
>
|
||||
Save
|
||||
|
|
|
|||
Loading…
Reference in a new issue