added theme icon and login button when user is unauthenticated
This commit is contained in:
parent
5977aa8edf
commit
f64e5ad231
3 changed files with 107 additions and 20 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue