diff --git a/frontend/app/PublicRoutes.tsx b/frontend/app/PublicRoutes.tsx
index 753dc8039..1173fcd80 100644
--- a/frontend/app/PublicRoutes.tsx
+++ b/frontend/app/PublicRoutes.tsx
@@ -21,27 +21,32 @@ function PublicRoutes() {
const { userStore } = useStore();
const authDetails = userStore.authDetails;
const isEnterprise = userStore.isEnterprise;
- const hideSupport = isEnterprise || location.pathname.includes('spots') || location.pathname.includes('view-spot')
+ const hideSupport = isEnterprise || location.pathname.includes('spots') || location.pathname.includes('view-spot');
+ const [loading, setLoading] = React.useState(true);
useEffect(() => {
if (authDetails && !authDetails.tenants) {
- void userStore.fetchTenants();
+ userStore.fetchTenants().then(() => setLoading(false));
+ } else {
+ setLoading(false);
}
}, []);
return (
- }>
-
-
-
-
-
-
-
- {!hideSupport && }
-
+
+ }>
+
+
+
+
+
+
+
+ {!hideSupport && }
+
+
);
}
-export default observer(PublicRoutes)
+export default observer(PublicRoutes);
diff --git a/frontend/app/Router.tsx b/frontend/app/Router.tsx
index 16710096a..000a6d6d5 100644
--- a/frontend/app/Router.tsx
+++ b/frontend/app/Router.tsx
@@ -163,6 +163,7 @@ const Router: React.FC = (props) => {
}, [isSpotCb, isLoggedIn, localSpotJwt, isSignup]);
useEffect(() => {
+ if (!isLoggedIn) return
const fetchData = async () => {
if (siteId && siteId !== lastFetchedSiteIdRef.current) {
const activeSite = sites.find((s) => s.id == siteId);
@@ -174,7 +175,7 @@ const Router: React.FC = (props) => {
};
void fetchData();
- }, [siteId]);
+ }, [siteId, isLoggedIn]);
const lastFetchedSiteIdRef = useRef(null);
diff --git a/frontend/app/components/Signup/Signup.tsx b/frontend/app/components/Signup/Signup.tsx
index 406575830..442a056ad 100644
--- a/frontend/app/components/Signup/Signup.tsx
+++ b/frontend/app/components/Signup/Signup.tsx
@@ -27,7 +27,6 @@ type SignupProps = RouteComponentProps;
const Signup: React.FC = ({ history }) => {
const { userStore } = useStore();
const authDetails = userStore.authDetails;
- const fetchTenants = userStore.fetchTenants;
const [healthModalPassed, setHealthModalPassed] = useState(localStorage.getItem(healthStatusCheck_key) === 'true');
const [healthStatusLoading, setHealthStatusLoading] = useState(true);
const [healthStatus, setHealthStatus] = useState(null);
@@ -40,16 +39,17 @@ const Signup: React.FC = ({ history }) => {
};
useEffect(() => {
- if (!healthModalPassed) void getHealth();
- }, []);
-
- useEffect(() => {
- if (authDetails && authDetails.tenants) {
- history.push(LOGIN_ROUTE);
+ if (!authDetails) return
+ if (authDetails) {
+ if (authDetails.tenants) {
+ history.push(LOGIN_ROUTE);
+ } else {
+ void getHealth();
+ }
}
}, [authDetails]);
- if (!healthModalPassed) {
+ if (authDetails && !healthModalPassed && !authDetails.tenants) {
return (
null}
diff --git a/frontend/app/services/HealthService.ts b/frontend/app/services/HealthService.ts
index 3b1b4f0ae..83eae33bf 100644
--- a/frontend/app/services/HealthService.ts
+++ b/frontend/app/services/HealthService.ts
@@ -2,7 +2,7 @@ import BaseService from './BaseService';
export default class HealthService extends BaseService {
async fetchStatus(isPublic?: boolean): Promise {
- const r = await this.client.get(isPublic ? '/healthz' : '/health');
+ const r = await this.client.get(isPublic ? '/health' : '/healthz');
const j = await r.json();
return j.data || {};
}