Fix Admin demo profiles to load after seeding
cgen-dafee2c8e2f0495e98b31410da107d7e
This commit is contained in:
parent
1cf467a4bf
commit
c7ab63bbb7
1 changed files with 7 additions and 8 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import Layout from "@/components/Layout";
|
||||
import LoadingScreen from "@/components/LoadingScreen";
|
||||
import { useAuth } from "@/contexts/AuthContext";
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { ensureDemoSeed } from "@/lib/demo-feed";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import {
|
||||
|
|
@ -26,18 +26,17 @@ export default function Admin() {
|
|||
const { user, loading, roles } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
const isOwner = Array.isArray(roles) && roles.includes("owner");
|
||||
const [demoProfiles, setDemoProfiles] = useState<any[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
ensureDemoSeed();
|
||||
} catch {}
|
||||
}, []);
|
||||
const demoProfiles: any[] = (function () {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem("demo_profiles") || "[]");
|
||||
const list = JSON.parse(localStorage.getItem("demo_profiles") || "[]");
|
||||
setDemoProfiles(Array.isArray(list) ? list : []);
|
||||
} catch {
|
||||
return [];
|
||||
setDemoProfiles([]);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue