@@ -6,22 +6,40 @@ import { DonutTitle } from "../../../donutTitle/donutTitle";
66import multipleDonuts from "../../../assets/images/extra-donuts.png" ;
77import GoogleLogin from "../../../assets/images/icons8-google-48.png" ;
88import { FaGithub } from 'react-icons/fa'
9+ import { connect } from 'react-redux' ;
10+ import { getLoginOptions } from '../../../actions/orgAction'
911import "./login.scss" ;
1012
1113class Login extends Component {
1214 constructor ( props ) {
1315 super ( props ) ;
1416 this . state = {
1517 activeForm : "login" ,
18+ loginOptions : { }
1619 } ;
1720 }
21+
22+ // get login options
23+ componentDidMount ( ) {
24+ this . props . getLoginOptions ( )
25+ }
26+
27+ componentDidUpdate ( prevProps , prevState ) {
28+ if ( prevState . loginOptions != this . props . org ?. loginOptions ) {
29+ this . setState ( {
30+ loginOptions : this . props . org ?. loginOptions
31+ } )
32+ }
33+ }
34+
1835 handleSelectorClick = ( formItem ) => {
1936 this . setState ( {
2037 activeForm : formItem ,
2138 } ) ;
2239 } ;
2340
2441 render ( ) {
42+ const { loginOptions } = this . state
2543 return (
2644 < div className = "login-page" >
2745 < div className = "welcome-text" >
@@ -58,7 +76,8 @@ class Login extends Component {
5876 : "Or SignUp with" }
5977 </ p >
6078 < Row >
61- < Col className = "button-column" >
79+ { Boolean ( loginOptions ?. google === true ) ? (
80+ < Col className = "button-column" >
6281 < a
6382 href = "http://localhost:5000/auth/google"
6483 style = { { padding : "1vh" } }
@@ -76,7 +95,9 @@ class Login extends Component {
7695 </ Button >
7796 </ a >
7897 </ Col >
79- < Col className = "button-column" >
98+ ) : null }
99+ { Boolean ( loginOptions ?. github === true ) ? (
100+ < Col className = "button-column" >
80101 < a
81102 href = "http://localhost:5000/auth/google"
82103 style = { { padding : "1vh" } }
@@ -94,6 +115,7 @@ class Login extends Component {
94115 </ Button >
95116 </ a >
96117 </ Col >
118+ ) : null }
97119 </ Row >
98120 < p className = "login-text-selector" >
99121 { this . state . activeForm === "login"
@@ -123,4 +145,9 @@ class Login extends Component {
123145 }
124146}
125147
126- export default Login ;
148+ // map state to props
149+ const mapStateToProps = ( state ) => ( {
150+ org : state . org
151+ } )
152+
153+ export default connect ( mapStateToProps , { getLoginOptions } ) ( Login ) ;
0 commit comments