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 Layout from "@/components/Layout";
|
||||||
import LoadingScreen from "@/components/LoadingScreen";
|
import LoadingScreen from "@/components/LoadingScreen";
|
||||||
import { useAuth } from "@/contexts/AuthContext";
|
import { useAuth } from "@/contexts/AuthContext";
|
||||||
import { useEffect } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { ensureDemoSeed } from "@/lib/demo-feed";
|
import { ensureDemoSeed } from "@/lib/demo-feed";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
|
|
@ -26,18 +26,17 @@ export default function Admin() {
|
||||||
const { user, loading, roles } = useAuth();
|
const { user, loading, roles } = useAuth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const isOwner = Array.isArray(roles) && roles.includes("owner");
|
const isOwner = Array.isArray(roles) && roles.includes("owner");
|
||||||
|
const [demoProfiles, setDemoProfiles] = useState<any[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
ensureDemoSeed();
|
ensureDemoSeed();
|
||||||
} catch {}
|
const list = JSON.parse(localStorage.getItem("demo_profiles") || "[]");
|
||||||
}, []);
|
setDemoProfiles(Array.isArray(list) ? list : []);
|
||||||
const demoProfiles: any[] = (function () {
|
|
||||||
try {
|
|
||||||
return JSON.parse(localStorage.getItem("demo_profiles") || "[]");
|
|
||||||
} catch {
|
} catch {
|
||||||
return [];
|
setDemoProfiles([]);
|
||||||
}
|
}
|
||||||
})();
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loading) {
|
if (!loading) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue