File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
packages/telestion-client-core/src/components/pages/lib Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -23,24 +23,27 @@ import { logger } from './logger';
23
23
* ```
24
24
*/
25
25
export function buildRoute (
26
- routing : Routing & { redirectPath : string } ,
26
+ routing : Routing ,
27
27
page : ReactNode ,
28
28
isAuthenticated : boolean
29
29
) : ReactNode {
30
- const key = `comp:${ routing . path } :${ routing . redirectPath } ` ;
30
+ const { path, exact, type } = routing ;
31
+
32
+ const redirectPath = 'redirectPath' in routing ? routing . redirectPath : '' ;
33
+ const key = `comp:${ path } :${ redirectPath } ` ;
31
34
const shouldRender =
32
- ( routing . type === 'auth' && isAuthenticated ) ||
33
- ( routing . type === 'unAuth' && ! isAuthenticated ) ;
35
+ ( type === 'auth' && isAuthenticated ) ||
36
+ ( type === 'unAuth' && ! isAuthenticated ) ;
34
37
35
38
logger . debug (
36
- `Route with${ routing . exact ? ' exact' : '' } path "${ routing . path } " should ${
37
- shouldRender ? 'render' : `redirect to "${ routing . redirectPath } "`
39
+ `Route with${ exact ? ' exact' : '' } path "${ path } " should ${
40
+ shouldRender ? 'render' : `redirect to "${ redirectPath } "`
38
41
} `
39
42
) ;
40
43
41
44
return (
42
- < Route key = { key } path = { routing . path } exact = { routing . exact } >
43
- { shouldRender ? page : < Redirect to = { routing . redirectPath } /> }
45
+ < Route key = { key } path = { path } exact = { exact } >
46
+ { shouldRender ? page : < Redirect to = { redirectPath } /> }
44
47
</ Route >
45
48
) ;
46
49
}
You can’t perform that action at this time.
0 commit comments