11import React , { ReactNode } from 'react' ;
2- import { Query , graphql } from 'react-apollo' ;
2+ import { Query } from 'react-apollo' ;
33import { Redirect } from 'react-router-dom' ;
44import styled from 'styled-components' ;
55import { Link , RouteComponentProps } from 'react-router-dom' ;
@@ -10,7 +10,6 @@ import PageSpinner from '../../spinners/PageSpinner';
1010import AccountVerifier from '../../../HOC/AccountVerifier' ;
1111import logoLight from '../../../assets/images/logo-light.png' ;
1212import { AFFILIATE } from '../../../apollo/queries/affiliate' ;
13- import { SEND_ONBOARDING_CODE } from '../../../apollo/mutations/user' ;
1413
1514const { Title, Paragraph } = Typography ;
1615
@@ -76,64 +75,57 @@ const StyledDiv = styled.div`
7675 padding: 24px 12px;
7776` ;
7877
79- class FreeAndTrial extends React . Component < RouteComponentProps < { affiliateId : string } > > {
80- constructor ( props : RouteComponentProps < { affiliateId : string } > ) {
81- super ( props ) ;
82- }
83-
84- render ( ) {
85- const { match : { params } } = this . props ;
86- const { affiliateId } = params ;
87- let affiliatePlan : string | ReactNode | undefined ;
78+ const FreeAndTrial = ( { match : { params } } : RouteComponentProps < { affiliateId : string } > ) => {
79+ const { affiliateId } = params ;
80+ let affiliatePlan : string | ReactNode | undefined ;
8881
89- return (
90- < Query < IQueryData , IQueryVariables >
91- query = { AFFILIATE }
92- variables = { { affiliateId } }
93- skip = { ! affiliateId }
94- >
95- { ( { loading, data, error } ) => {
96- if ( error ) {
97- return < Redirect to = "/login?error=affiliateId" /> ;
98- }
99- if ( data && ! loading ) {
100- const { affiliate : { plan } } = data ;
101- affiliatePlan = < span style = { { textTransform : 'capitalize' } } > { plan } Trial</ span > ;
102- }
103- const titleText = ( affiliateId && affiliatePlan ) || loading ?
104- affiliatePlan : 'Start with your free REITScreener account' ;
105- return (
106- < PageSpinner loading = { loading } >
107- < FreeAndTrialWrapper >
108- < StyledDiv >
109- < StyledBrandLogo draggable = { false } src = { logoLight } alt = "REITScreener" />
110- < Card >
111- < Row className = "root-row" type = "flex" >
112- < Col xs = { 24 } className = "root-col" >
113- < Title level = { 3 } > { titleText } </ Title >
114- </ Col >
115- < Col xs = { 24 } className = "root-col" >
116- < RegistrationForm
117- affiliateId = { affiliateId }
118- />
119- < Paragraph >
120- By registering you agree with the< br />
121- < Link to = "/terms-and-conditions" > Terms and Conditions</ Link >
122- </ Paragraph >
123- < Paragraph >
124- Already have an account? < Link to = "/login" > Sign in</ Link >
125- </ Paragraph >
126- </ Col >
127- </ Row >
128- </ Card >
129- </ StyledDiv >
130- </ FreeAndTrialWrapper >
131- </ PageSpinner >
132- ) ;
133- } }
134- </ Query >
135- ) ;
136- }
137- }
82+ return (
83+ < Query < IQueryData , IQueryVariables >
84+ query = { AFFILIATE }
85+ variables = { { affiliateId } }
86+ skip = { ! affiliateId }
87+ >
88+ { ( { loading, data, error } ) => {
89+ if ( error ) {
90+ return < Redirect to = "/login?error=affiliateId" /> ;
91+ }
92+ if ( data && ! loading ) {
93+ const { affiliate : { plan } } = data ;
94+ affiliatePlan = < span style = { { textTransform : 'capitalize' } } > { plan } Trial</ span > ;
95+ }
96+ const titleText = ( affiliateId && affiliatePlan ) || loading ?
97+ affiliatePlan : 'Start with your free REITScreener account' ;
98+ return (
99+ < PageSpinner loading = { loading } >
100+ < FreeAndTrialWrapper >
101+ < StyledDiv >
102+ < StyledBrandLogo draggable = { false } src = { logoLight } alt = "REITScreener" />
103+ < Card >
104+ < Row className = "root-row" type = "flex" >
105+ < Col xs = { 24 } className = "root-col" >
106+ < Title level = { 3 } > { titleText } </ Title >
107+ </ Col >
108+ < Col xs = { 24 } className = "root-col" >
109+ < RegistrationForm
110+ affiliateId = { affiliateId }
111+ />
112+ < Paragraph >
113+ By registering you agree with the< br />
114+ < Link to = "/terms-and-conditions" > Terms and Conditions</ Link >
115+ </ Paragraph >
116+ < Paragraph >
117+ Already have an account? < Link to = "/login" > Sign in</ Link >
118+ </ Paragraph >
119+ </ Col >
120+ </ Row >
121+ </ Card >
122+ </ StyledDiv >
123+ </ FreeAndTrialWrapper >
124+ </ PageSpinner >
125+ ) ;
126+ } }
127+ </ Query >
128+ ) ;
129+ } ;
138130
139131export default AccountVerifier ( FreeAndTrial , true ) ;
0 commit comments