From 128746fa1534ca31e23d5b7665b11b3eea56495f Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Fri, 30 Aug 2024 11:32:19 +0200 Subject: [PATCH] fix: Redirect to SPOTS_LIST_PATH when spotOnly is true in PrivateRoutes --- frontend/app/PrivateRoutes.tsx | 305 +++++++++++++++++---------------- 1 file changed, 158 insertions(+), 147 deletions(-) diff --git a/frontend/app/PrivateRoutes.tsx b/frontend/app/PrivateRoutes.tsx index 1f48c2bc9..59fa3c482 100644 --- a/frontend/app/PrivateRoutes.tsx +++ b/frontend/app/PrivateRoutes.tsx @@ -1,16 +1,17 @@ -import React, { lazy, Suspense } from 'react'; -import { Switch, Route, Redirect } from 'react-router-dom'; -import { connect } from 'react-redux'; -import { Loader } from 'UI'; import withSiteIdUpdater from 'HOCs/withSiteIdUpdater'; +import { Map } from 'immutable'; +import React, { Suspense, lazy } from 'react'; +import { connect } from 'react-redux'; +import { Redirect, Route, Switch } from 'react-router-dom'; + +import AdditionalRoutes from 'App/AdditionalRoutes'; +import { GLOBAL_HAS_NO_RECORDINGS } from 'App/constants/storageKeys'; +import { OB_DEFAULT_TAB } from 'App/routes'; +import { Loader } from 'UI'; import APIClient from './api_client'; -import { getScope } from "./duck/user"; +import { getScope } from './duck/user'; import * as routes from './routes'; -import { OB_DEFAULT_TAB } from 'App/routes'; -import { GLOBAL_HAS_NO_RECORDINGS } from 'App/constants/storageKeys'; -import { Map } from 'immutable'; -import AdditionalRoutes from 'App/AdditionalRoutes'; const components: any = { SessionPure: lazy(() => import('Components/Session/Session')), @@ -21,12 +22,20 @@ const components: any = { SessionsOverviewPure: lazy(() => import('Components/Overview')), DashboardPure: lazy(() => import('Components/Dashboard/NewDashboard')), FunnelDetailsPure: lazy(() => import('Components/Funnels/FunnelDetails')), - FunnelIssueDetails: lazy(() => import('Components/Funnels/FunnelIssueDetails')), + FunnelIssueDetails: lazy( + () => import('Components/Funnels/FunnelIssueDetails') + ), FunnelPagePure: lazy(() => import('Components/Funnels/FunnelPage')), MultiviewPure: lazy(() => import('Components/Session_/Multiview/Multiview')), - UsabilityTestingPure: lazy(() => import('Components/UsabilityTesting/UsabilityTesting')), - UsabilityTestEditPure: lazy(() => import('Components/UsabilityTesting/TestEdit')), - UsabilityTestOverviewPure: lazy(() => import('Components/UsabilityTesting/TestOverview')), + UsabilityTestingPure: lazy( + () => import('Components/UsabilityTesting/UsabilityTesting') + ), + UsabilityTestEditPure: lazy( + () => import('Components/UsabilityTesting/TestEdit') + ), + UsabilityTestOverviewPure: lazy( + () => import('Components/UsabilityTesting/TestOverview') + ), SpotsListPure: lazy(() => import('Components/Spots/SpotsList')), SpotPure: lazy(() => import('Components/Spots/SpotPlayer')), ScopeSetup: lazy(() => import('Components/ScopeForm')), @@ -46,10 +55,12 @@ const enhancedComponents: any = { Multiview: withSiteIdUpdater(components.MultiviewPure), UsabilityTesting: withSiteIdUpdater(components.UsabilityTestingPure), UsabilityTestEdit: withSiteIdUpdater(components.UsabilityTestEditPure), - UsabilityTestOverview: withSiteIdUpdater(components.UsabilityTestOverviewPure), + UsabilityTestOverview: withSiteIdUpdater( + components.UsabilityTestOverviewPure + ), SpotsList: withSiteIdUpdater(components.SpotsListPure), Spot: components.SpotPure, - ScopeSetup: components.ScopeSetup + ScopeSetup: components.ScopeSetup, }; const withSiteId = routes.withSiteId; @@ -137,139 +148,139 @@ function PrivateRoutes(props: Props) { path={SCOPE_SETUP} component={enhancedComponents.ScopeSetup} /> - {props.spotOnly ? null : <> - { - const client = new APIClient(); - switch (location.pathname) { - case "/integrations/slack": - client.post("integrations/slack/add", { - code: location.search.split("=")[1], - state: props.tenantId - }); - break; - case "/integrations/msteams": - client.post("integrations/msteams/add", { - code: location.search.split("=")[1], - state: props.tenantId - }); - break; - } - return ; - }} - /> - {redirectToOnboarding && } - - {/* DASHBOARD and Metrics */} - - - - - - - - - - - - - - - - - {/*{Object.entries(routes.redirects).map(([fr, to]) => (*/} - {/* */} - {/*))}*/} - {/**/} - } {props.spotOnly ? : null} + { + const client = new APIClient(); + switch (location.pathname) { + case '/integrations/slack': + client.post('integrations/slack/add', { + code: location.search.split('=')[1], + state: props.tenantId, + }); + break; + case '/integrations/msteams': + client.post('integrations/msteams/add', { + code: location.search.split('=')[1], + state: props.tenantId, + }); + break; + } + return ; + }} + /> + {redirectToOnboarding && ( + + )} + + {/* DASHBOARD and Metrics */} + + + + + + + + + + + + + + + + + {Object.entries(routes.redirects).map(([fr, to]) => ( + + ))} + );