Skip to content

Commit

Permalink
Extract social buttons into component SocialAuthButtonList
Browse files Browse the repository at this point in the history
  • Loading branch information
gocreating committed Oct 31, 2016
1 parent 43a5267 commit 47de115
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 49 deletions.
72 changes: 24 additions & 48 deletions src/common/components/pages/user/LoginPage.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,34 @@
import React from 'react';
import PageHeader from 'react-bootstrap/lib/PageHeader';
import Alert from 'react-bootstrap/lib/Alert';
import Grid from 'react-bootstrap/lib/Grid';
import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col';
import PageLayout from '../../layouts/PageLayout';
import Head from '../../widgets/Head';
import LoginForm from '../../forms/user/LoginForm';
import SocialAuthButtonList from '../../utils/SocialAuthButtonList';

let LoginPage = ({ location }) => {
let { next } = location.query;
let search = next ? '?next=' + next : '';

return (
<PageLayout hasGrid={false}>
<Head
links={[
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-social/5.0.0/bootstrap-social.min.css',
]}
/>
<Grid>
<PageHeader>Login</PageHeader>
<Row>
<Col md={12}>
{next && (
<Alert bsStyle="warning">
<strong>Authentication Required</strong>
{' '}Please login first.
</Alert>
)}
</Col>
</Row>
<Row>
<Col md={9}>
<LoginForm />
</Col>
<Col md={3}>
<a
href={`/auth/facebook${search}`}
className="btn btn-block btn-social btn-facebook"
>
<span className="fa fa-facebook"></span>Login with Facebook
</a>
<a
href={`/auth/linkedin${search}`}
className="btn btn-block btn-social btn-linkedin"
>
<span className="fa fa-linkedin"></span>Login with LinkedIn
</a>
</Col>
</Row>
</Grid>
</PageLayout>
);
};
let LoginPage = ({ location }) => (
<PageLayout>
<PageHeader>Login</PageHeader>
<Row>
<Col md={12}>
{location.query.next && (
<Alert bsStyle="warning">
<strong>Authentication Required</strong>
{' '}Please login first.
</Alert>
)}
</Col>
</Row>
<Row>
<Col md={9}>
<LoginForm />
</Col>
<Col md={3}>
<SocialAuthButtonList />
</Col>
</Row>
</PageLayout>
);

export default LoginPage;
12 changes: 11 additions & 1 deletion src/common/components/pages/user/RegisterPage.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import React from 'react';
import PageHeader from 'react-bootstrap/lib/PageHeader';
import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col';
import PageLayout from '../../layouts/PageLayout';
import RegisterForm from '../../forms/user/RegisterForm';
import SocialAuthButtonList from '../../utils/SocialAuthButtonList';

const RegisterPage = (props) => (
<PageLayout>
<PageHeader>Register</PageHeader>
<RegisterForm />
<Row>
<Col md={9}>
<RegisterForm />
</Col>
<Col md={3}>
<SocialAuthButtonList />
</Col>
</Row>
</PageLayout>
);

Expand Down
34 changes: 34 additions & 0 deletions src/common/components/utils/SocialAuthButtonList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { connect } from 'react-redux';
import Head from '../widgets/Head';

let SocialAuthButtonList = ({ routing }) => {
let { next } = routing.locationBeforeTransitions.query;
let search = next ? '?next=' + next : '';

return (
<div>
<Head
links={[
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-social/5.0.0/bootstrap-social.min.css',
]}
/>
<a
href={`/auth/facebook${search}`}
className="btn btn-block btn-social btn-facebook"
>
<span className="fa fa-facebook"></span>Login with Facebook
</a>
<a
href={`/auth/linkedin${search}`}
className="btn btn-block btn-social btn-linkedin"
>
<span className="fa fa-linkedin"></span>Login with LinkedIn
</a>
</div>
);
};

export default connect(state => ({
routing: state.routing,
}))(SocialAuthButtonList);

0 comments on commit 47de115

Please sign in to comment.