Added error and loading pages to dashboard

This commit is contained in:
keannu125 2023-03-07 18:40:04 +08:00
parent f837903392
commit d518abec77
2 changed files with 30 additions and 2 deletions

View file

@ -11,7 +11,8 @@ export default function LoginChecker() {
const old_session_checked = useSelector(
(state: OldSessionState) => state.old_session_checked.value
);
if (!logged_in && old_session_checked) {
if (!logged_in && !old_session_checked) {
} else if (!logged_in && old_session_checked) {
console.log("Not logged in. Redirecting to login page");
return <Navigate to="/Login" replace />;
}

View file

@ -17,7 +17,34 @@ export default function Dashboard() {
const logs = useQuery("logs", GetLogs, { retry: 0 });
const products = useQuery("products", GetProducts, { retry: 0 });
if (logs.isLoading && products.isLoading) {
return <div>heh</div>;
return (
<div>
<LoginChecker />
<div style={styles.flex_row}>
<HomeIcon size={64} color="white" />
<p style={{ ...styles.text_white, ...styles.text_XL }}>Dashboard</p>
</div>
<div style={{ ...styles.content_column, ...{ alignItems: "center" } }}>
<p style={{ ...styles.text_white, ...styles.text_L }}>
Loading dashboard...
</p>
</div>
</div>
);
}
if (logs.error || products.error) {
<div>
<LoginChecker />
<div style={styles.flex_row}>
<HomeIcon size={64} color="white" />
<p style={{ ...styles.text_white, ...styles.text_XL }}>Dashboard</p>
</div>
<div style={{ ...styles.content_column, ...{ alignItems: "center" } }}>
<p style={{ ...styles.text_red, ...styles.text_L }}>
Error loading dashboard
</p>
</div>
</div>;
}
return (
<div>