added theme icon and login button when user is unauthenticated

This commit is contained in:
Carter 2024-11-01 11:10:20 -06:00
parent 5977aa8edf
commit f64e5ad231
3 changed files with 107 additions and 20 deletions

View file

@ -19,6 +19,15 @@ const reducer = (state: GlobalState, action: GlobalStateAction): GlobalState =>
};
};
const globalDefault = {
user: User.create(),
team: Team.create(),
as: "",
showErrors: false,
userTeamPermissions: [],
backgroundTasksComplete: false
}
export default function UserWrapper() {
const [count, setCount] = useState(0)
const [loading, setLoading] = useState(false)
@ -47,17 +56,13 @@ export default function UserWrapper() {
})
}).catch(err => {
console.log(err.toString())
if (err.toString().includes("CORS")) {
setMessage("CORS error")
} else {
setMessage("Loading failed, refresh may help")
}
setGlobal(globalDefault)
})
.finally(() => {
setLoading(false)
hasFetched.current = true;
})
}, [])
}, [setGlobal, setUser])
useEffect(() => {
if (loading) return;