From c1e948b95c52c5e1e12637a26823d80234e01db5 Mon Sep 17 00:00:00 2001 From: Sandeepvarri Date: Sat, 24 Nov 2018 22:28:23 +0530 Subject: [PATCH 1/2] signup UI --- src/App.js | 8 +++ src/views/singup/Signup.js | 130 +++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 src/views/singup/Signup.js diff --git a/src/App.js b/src/App.js index 9c7a1b1..7298acc 100644 --- a/src/App.js +++ b/src/App.js @@ -7,6 +7,7 @@ import Home from "./views/home/Home"; import Navbar from "./components/common/navbar/navbar.component"; import SubNavbar from "./components/common/sub_navbar/sub_navbar.component"; import Sidebar from "./components/common/sidebar/sidebar.component"; +import Signup from "./views/singup/Signup"; // import MainComponent from "./views/main/Main"; const App = styled.div` @@ -59,6 +60,13 @@ class AppComponent extends Component { ); }} /> + { + return ; + }} + /> diff --git a/src/views/singup/Signup.js b/src/views/singup/Signup.js new file mode 100644 index 0000000..13d5c0a --- /dev/null +++ b/src/views/singup/Signup.js @@ -0,0 +1,130 @@ +import React, { Component } from "react"; +import { connect } from "react-redux"; +import { Link } from "react-router-dom"; +import { Row, Col, Button, Icon, Input, Form, Tooltip } from 'antd'; +const FormItem = Form.Item; +class Signup extends Component { + state = { username: "", email: "", password: "" } + setValue = (type, value) => { + this.setState({ [type]: value }, () => { + }); + }; + handleUsername = e => { + e.preventDefault(); + this.setValue("username", e.target.value); + }; + + handlePassword = e => { + e.preventDefault(); + this.setValue("password", e.target.value); + }; + handleEmail = e => { + e.preventDefault(); + this.setValue("email", e.target.value) + } + handleSubmit = e => { + e.preventDefault(); + console.log("submitted"); + + }; + handleGoogle = () => { + console.log("Google btn clicked"); + } + handleGithub = () => { + console.log("Github btn clicked"); + } + handleLinkedin = () => { + console.log("LinkedIn btn clicked"); + } + render() { + return ( +
+ + + +
+ +
+ +
+
+ + + + + + } + size="large" + id="error" + type="text" + placeholder="Enter Username" + onBlur={this.handleUsername} + required + pattern="[A-Za-z]{0,20}" + /> + + + + + + + + } + size="large" + type="email" + placeholder="Enter Email" + required + onBlur={this.handleEmail} + /> + + + + + + } + size="large" + type="password" + placeholder="Enter Password" + required + onBlur={this.handlePassword} + /> + + + + + + + + + + + + + + + + + + + + + + + +
+ + Already a user? Login here +
+ +
+
+
+ + ) + } +} + +export default Signup; \ No newline at end of file From a1f36945150f80cc708597ebb3e9a2fec5f96f45 Mon Sep 17 00:00:00 2001 From: Sandeepvarri Date: Wed, 5 Dec 2018 19:01:39 +0530 Subject: [PATCH 2/2] Signup UI, Google and LInkedIn login --- src/views/singup/GoogleLogin.js | 75 +++++++++++++++++++++++++++++++ src/views/singup/LinkedinLogin.js | 50 +++++++++++++++++++++ src/views/singup/Signup.js | 7 ++- 3 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 src/views/singup/GoogleLogin.js create mode 100644 src/views/singup/LinkedinLogin.js diff --git a/src/views/singup/GoogleLogin.js b/src/views/singup/GoogleLogin.js new file mode 100644 index 0000000..6bec81e --- /dev/null +++ b/src/views/singup/GoogleLogin.js @@ -0,0 +1,75 @@ +import React, { Component } from 'react'; +import { Button, Icon } from 'antd'; +class GoogleLogin extends Component{ + constructor(props) { + super(props) + } + + componentDidMount(){ + (function() { + var e = document.createElement("script"); + e.type = "text/javascript"; + e.async = true; + e.src = "https://apis.google.com/js/client:platform.js?onload=gPOnLoad"; + var t = document.getElementsByTagName("script")[0]; + t.parentNode.insertBefore(e, t) + })(); + } + + googleLogin = () => { + let response = null; + window.gapi.auth.signIn({ + callback: function(authResponse) { + this.googleSignInCallback( authResponse ) + }.bind( this ), + clientid: "", //Google client Id + cookiepolicy: "single_host_origin", + requestvisibleactions: "http://schema.org/AddAction", + scope: "https://www.googleapis.com/auth/plus.login email" + }); + } + + googleSignInCallback = (e) => { + console.log( e ) + if (e["status"]["signed_in"]) { + window.gapi.client.load("plus", "v1", function() { + if (e["access_token"]) { + this.getUserGoogleProfile( e["access_token"] ) + } else if (e["error"]) { + console.log('Import error', 'Error occured while importing data') + } + }.bind(this)); + } else { + console.log('Oops... Error occured while importing data') + } + } + + getUserGoogleProfile = accesstoken => { + var e = window.gapi.client.plus.people.get({ + userId: "me" + }); + e.execute(function(e) { + if (e.error) { + console.log(e.message); + console.log('Import error - Error occured while importing data') + return + + } else if (e.id) { + //Profile data + console.log( e ); + return; + } + }.bind(this)); + } + + render(){ + return( +
+ +
+ ) + } + +} + +export default GoogleLogin; \ No newline at end of file diff --git a/src/views/singup/LinkedinLogin.js b/src/views/singup/LinkedinLogin.js new file mode 100644 index 0000000..9bd8a62 --- /dev/null +++ b/src/views/singup/LinkedinLogin.js @@ -0,0 +1,50 @@ +import React, { Component } from 'react'; +import { Button, Icon } from 'antd'; + +class LinkedinLogin extends Component{ + constructor(props) { + super(props) + } + + componentDidMount(){ + (function() { + var e = document.createElement("script"); + e.type = "text/javascript"; + e.async = true; + e.src = "http://platform.linkedin.com/in.js?async=true"; + var t = document.getElementsByTagName("script")[0]; + t.parentNode.insertBefore(e, t) + })(); + } + + linkedinLogin = () => { + window.IN.init({ + api_key : "" + }); + setTimeout(function(){ + this.getUserDetails() + }.bind(this),1000); + console.log( "Loaded" ) + } + + getUserDetails = () => { + window.IN.User.authorize( function(){ + window.IN.API.Profile("me") + .fields(["id", "firstName", "lastName", "pictureUrl", "publicProfileUrl"]) + .result(function(result) { + console.log(result); + alert("Successfull login from linkedin : "+ result.values[0].firstName + " " + result.values[0].lastName); + }) + .error(function(err) { + console.log('Import error - Error occured while importing data') + }); + }); + } + render(){ + return( + + ) + } +} + +export default LinkedinLogin; \ No newline at end of file diff --git a/src/views/singup/Signup.js b/src/views/singup/Signup.js index 13d5c0a..fbfa3cc 100644 --- a/src/views/singup/Signup.js +++ b/src/views/singup/Signup.js @@ -2,6 +2,8 @@ import React, { Component } from "react"; import { connect } from "react-redux"; import { Link } from "react-router-dom"; import { Row, Col, Button, Icon, Input, Form, Tooltip } from 'antd'; +import GoogleLogin from './GoogleLogin'; +import LinkedinLogin from './LinkedinLogin'; const FormItem = Form.Item; class Signup extends Component { state = { username: "", email: "", password: "" } @@ -102,13 +104,14 @@ class Signup extends Component { - + + - +