Skip to content

Commit 1c2655c

Browse files
committed
fix for rerendering
1 parent 8eb8c08 commit 1c2655c

File tree

1 file changed

+18
-41
lines changed

1 file changed

+18
-41
lines changed

src/App.tsx

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -125,35 +125,16 @@ export default function App() {
125125
}
126126
}
127127

128+
128129
useEffect(() => {
129130
// If not K8S_CLIENT then validateToken otherwise directly redirect
130-
async function validation() {
131-
try {
132-
await validateToken()
133-
defaultRedirection()
134-
} catch (err: any) {
135-
// push to login without breaking search
136-
if (err?.code === 401) {
137-
const loginPath = URLS.LOGIN_SSO
138-
const newSearch = location.pathname.includes(URLS.LOGIN_SSO)
139-
? location.search
140-
: `?continue=${location.pathname}`
141-
push(`${loginPath}${newSearch}`)
142-
} else {
143-
setErrorPage(true)
144-
showError(err)
145-
}
146-
} finally {
147-
setValidating(false)
148-
}
149-
}
150131
if (!window._env_.K8S_CLIENT) {
151132
// Pass validation for direct email approval notification
152-
// if (location.pathname && location.pathname.includes('approve')) {
153-
// redirectToDirectApprovalNotification()
154-
// } else {
133+
if (location.pathname && location.pathname.includes('approve')) {
134+
redirectToDirectApprovalNotification()
135+
} else {
155136
validation()
156-
// }
137+
}
157138
} else {
158139
setValidating(false)
159140
defaultRedirection()
@@ -264,31 +245,27 @@ export default function App() {
264245
) : (
265246
<ErrorBoundary>
266247
<BreadcrumbStore>
267-
<Switch>
268-
{/* {location.pathname && location.pathname.includes('approve') ? (
248+
{location.pathname && location.pathname.includes('approve') ? (
249+
<Switch>
269250
<Route
270251
exact
271-
path={`/${approvalType?.toLocaleLowerCase()}/approve?token=${approvalToken}`}
252+
path={`/${approvalType?.toLocaleLowerCase()}/approve`}
272253
render={() =>
273254
GenericDirectApprovalModal && (
274255
<GenericDirectApprovalModal approvalType={approvalType} />
275256
)
276257
}
277258
/>
278-
) : ( */}
279-
<>
280-
{!window._env_.K8S_CLIENT && <Route path={`/login`} component={Login} />}
281-
<Route path="/" render={() => <NavigationRoutes />} />
282-
<Redirect
283-
to={
284-
window._env_.K8S_CLIENT
285-
? '/'
286-
: `${URLS.LOGIN_SSO}${location.search}`
287-
}
288-
/>
289-
</>
290-
{/* )} */}
291-
</Switch>
259+
</Switch>
260+
) : (
261+
<Switch>
262+
{!window._env_.K8S_CLIENT && <Route path={`/login`} component={Login} />}
263+
<Route path="/" render={() => <NavigationRoutes />} />
264+
<Redirect
265+
to={window._env_.K8S_CLIENT ? '/' : `${URLS.LOGIN_SSO}${location.search}`}
266+
/>
267+
</Switch>
268+
)}
292269
<div id="full-screen-modal"></div>
293270
<div id="visible-modal"></div>
294271
<div id="visible-modal-2"></div>

0 commit comments

Comments
 (0)