1
1
/* eslint-disable react/no-unused-prop-types */
2
2
/* eslint-disable no-unused-vars */
3
+ /* eslint-disable no-restricted-globals */
4
+ /* eslint-disable react/destructuring-assignment */
3
5
/**
4
6
* SlashTC index container
5
7
*/
6
- import React from 'react' ;
8
+ import React , { useEffect } from 'react' ;
7
9
import PT from 'prop-types' ;
8
10
import { connect } from 'react-redux' ;
9
11
import { useMediaQuery } from 'react-responsive' ;
12
+ import { isTokenExpired } from '@topcoder-platform/tc-auth-lib' ;
13
+ import { config } from 'topcoder-react-utils' ;
10
14
import Viewport from 'components/Contentful/Viewport' ;
11
15
import TopcoderTime from 'components/Dashboard/TCTime' ;
12
16
import ThriveArticlesFeedContainer from 'containers/Dashboard/ThriveArticlesFeed' ;
@@ -28,6 +32,14 @@ function SlashTCContainer(props) {
28
32
const theme = THEMES . dark ; // for v1 only dark theme
29
33
const isTabletOrMobile = useMediaQuery ( { maxWidth : 768 } ) ;
30
34
const title = 'Home | Topcoder' ;
35
+
36
+ useEffect ( ( ) => {
37
+ if ( props . tokenV3 && ! isTokenExpired ( props . tokenV3 ) ) return ;
38
+ let url = `retUrl=${ encodeURIComponent ( location . href ) } ` ;
39
+ url = `${ config . URL . AUTH } /member?${ url } &utm_source=community-app-home-page` ;
40
+ location . href = url ;
41
+ } , [ props . tokenV3 ] ) ;
42
+
31
43
return (
32
44
< div className = { theme . container } >
33
45
< MetaTags
@@ -110,16 +122,19 @@ function SlashTCContainer(props) {
110
122
111
123
SlashTCContainer . defaultProps = {
112
124
profile : null ,
125
+ tokenV3 : null ,
113
126
} ;
114
127
115
128
SlashTCContainer . propTypes = {
116
129
profile : PT . shape ( ) ,
130
+ tokenV3 : PT . string ,
117
131
} ;
118
132
119
133
function mapStateToProps ( state ) {
120
134
const profile = state . auth && state . auth . profile ? { ...state . auth . profile } : { } ;
121
135
return {
122
136
profile,
137
+ tokenV3 : state . auth . tokenV3 ,
123
138
} ;
124
139
}
125
140
0 commit comments