fix(ui): checking for tenants state

This commit is contained in:
Shekar Siri 2024-10-30 13:06:49 +01:00
parent 6479292158
commit 63d1b8ab49
4 changed files with 15 additions and 13 deletions

View file

@ -1,4 +1,4 @@
import React, { lazy, Suspense } from 'react';
import React, { lazy, Suspense, useEffect } from 'react';
import { Loader } from 'UI';
import { Redirect, Route, Switch } from 'react-router-dom';
import Signup from 'Components/Signup/Signup';
@ -19,8 +19,16 @@ const Spot = lazy(() => import('Components/Spots/SpotPlayer/SpotPlayer'));
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')
useEffect(() => {
if (authDetails && !authDetails.tenants) {
void userStore.fetchTenants();
}
}, []);
return (
<Suspense fallback={<Loader loading={true} className='flex-1' />}>
<Switch>
@ -36,4 +44,4 @@ function PublicRoutes() {
}
export default observer(PublicRoutes)
export default observer(PublicRoutes)

View file

@ -42,15 +42,13 @@ const Login = ({
const params = new URLSearchParams(location.search);
useEffect(() => {
if (Object.keys(authDetails).length !== 0) {
if (!authDetails.tenants) {
if (authDetails && !authDetails.tenants) {
history.push(SIGNUP_ROUTE);
}
}
}, [authDetails]);
useEffect(() => {
void fetchTenants();
// void fetchTenants();
const jwt = params.get('jwt');
const spotJwt = params.get('spotJwt');
if (spotJwt) {

View file

@ -41,14 +41,10 @@ const Signup: React.FC<SignupProps> = ({ history }) => {
useEffect(() => {
if (!healthModalPassed) void getHealth();
if (Object.keys(authDetails).length === 0) {
fetchTenants();
}
}, []);
useEffect(() => {
if (Object.keys(authDetails).length === 0) {
if (authDetails && authDetails.tenants) {
history.push(LOGIN_ROUTE);
}
}, [authDetails]);

View file

@ -55,7 +55,7 @@ class UserStore {
constructor() {
makeAutoObservable(this);
makePersistable(
void makePersistable(
this,
{
name: 'UserStore',
@ -624,4 +624,4 @@ class UserStore {
const userStore = new UserStore();
export default userStore;
export default userStore;