Skip to content

Commit

Permalink
Merge pull request #19 from farminf/dev
Browse files Browse the repository at this point in the history
Captcha implementation
  • Loading branch information
Farmin authored Jan 11, 2018
2 parents af8394e + 707a4db commit 1e54fb5
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 25 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"react": "^16.2.0",
"react-dates": "^16.0.1",
"react-dom": "^16.2.0",
"react-icons": "^2.2.7",
"react-recaptcha": "^2.3.5",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
Expand Down
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<script src="https://www.google.com/recaptcha/api.js" async defer></script>

<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down
1 change: 1 addition & 0 deletions src/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class LoginUserNamePassword extends React.Component {
<Button onClick={this.onLoginWithEmail} raised className={classes.button}>
Login
</Button>
{this.state.error && <p>{this.state.error}</p>}
</form>
</Paper>
)
Expand Down
8 changes: 8 additions & 0 deletions src/components/LoginGoogle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {withStyles} from 'material-ui/styles';
import Constants from '../utils/constants'
import Paper from 'material-ui/Paper';
import Typography from 'material-ui/Typography';
import FaGoogle from 'react-icons/lib/fa/google-plus-square';


const styles = theme => ({

Expand All @@ -24,6 +26,10 @@ const styles = theme => ({
marginLeft: 20,
marginRight: 20
})
,
googleicon:{
marginRight : 5
}
});

const LoginGoogle = (props) => {
Expand All @@ -41,7 +47,9 @@ const LoginGoogle = (props) => {
Login With Google
</Typography>
<Button onClick={props.onLoginGoogle} raised className={classes.button}>
<FaGoogle size={30} color='red' className={classes.googleicon}/>
{Constants.ASSIGNS_LOGIN}

</Button>

</Paper>
Expand Down
25 changes: 17 additions & 8 deletions src/components/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {withStyles} from 'material-ui/styles';
import Paper from 'material-ui/Paper';
import Typography from 'material-ui/Typography';
import TextField from 'material-ui/TextField';
import Recaptcha from 'react-recaptcha';

const styles = theme => ({

Expand Down Expand Up @@ -51,11 +52,8 @@ class SignUp extends React.Component {

onSignup = (e) => {
e.preventDefault();
if (!this.state.email || !this.state.password || !this.state.confirmpassword ||
!this.state.email.match(/^(([^<>()\\.,;:\s@"]+(\.[^<>()\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)) {
this.setState(() => ({
error : 'All field should be filled'
}));
if (!this.state.email || !this.state.password || !this.state.confirmpassword || !this.state.email.match(/^(([^<>()\\.,;:\s@"]+(\.[^<>()\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)) {
this.setState(() => ({error: 'All field should be filled in the correct way'}));
} else {
this.setState(() => ({error: ''}));
this
Expand All @@ -66,8 +64,14 @@ class SignUp extends React.Component {

onEmailChange = (e) => {
const email = e.target.value;
//if (!email || email.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)) {
this.setState(() => ({email}));
// if (!email ||
// email.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\
//
//
//
// [[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-
// Z ]{2,}))$/)) {
this.setState(() => ({email}));
//}

};
Expand All @@ -87,7 +91,7 @@ class SignUp extends React.Component {
return (

<Paper className={classes.paper} elevation={4}>
{this.state.error && <p>{this.state.error}</p>}

<Typography type="body1" component="p">
Create New Account
</Typography>
Expand Down Expand Up @@ -115,9 +119,14 @@ class SignUp extends React.Component {
alue={this.state.confirmpassword}
onChange={this.onConfirmPasswordChange}/>

<Recaptcha
className={classes.textField}
sitekey="6Lc1_j8UAAAAAH5zKYdv055fpSrIDghc3J6xZF02"
/>
<Button onClick={this.onSignup} raised className={classes.button}>
Register
</Button>
{this.state.error && <p>{this.state.error}</p>}
</form>
</Paper>
)
Expand Down
38 changes: 33 additions & 5 deletions src/components/TransactionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {connect} from 'react-redux';
import TransactionListItem from './TransactionListItem';
import {startDeleteTransaction, startAddTransaction} from '../actions/transactions';
import {withStyles} from 'material-ui/styles';
import Table, {TableBody, TableCell, TableHead, TableRow} from 'material-ui/Table';
import Table, {TableBody, TableCell, TableHead, TableRow, TableFooter, TablePagination} from 'material-ui/Table';
import {updateAccountBalance} from '../actions/accounts';

const styles = theme => ({
Expand All @@ -18,11 +18,16 @@ const styles = theme => ({
});

class TransactionList extends React.Component {

componentDidMount(){

constructor(props){
super(props);
this.state = {
page: 0,
rowsPerPage: 5
}
}

componentDidMount() {}

onDelete = (idObject, id) => {
console.log(id);
this
Expand Down Expand Up @@ -56,6 +61,14 @@ class TransactionList extends React.Component {

};

handleChangePage = (event, page) => {
this.setState({page});
};

handleChangeRowsPerPage = event => {
this.setState({rowsPerPage: event.target.value});
};

render() {
const {classes} = this.props;
return (this.props.transactions.lenght === 0 || this.props.transactions.hasOwnProperty(0) === false
Expand All @@ -76,7 +89,11 @@ class TransactionList extends React.Component {
</TableRow>
</TableHead>
<TableBody>
{this.props.transactions.map((transaction) => {
{this
.props
.transactions
.slice(this.state.page * this.state.rowsPerPage, this.state.page * this.state.rowsPerPage + this.state.rowsPerPage)
.map((transaction) => {
return <TransactionListItem
key={transaction.id}
onDelete={this.onDelete}
Expand All @@ -85,6 +102,17 @@ class TransactionList extends React.Component {
})
}
</TableBody>
<TableFooter>
<TableRow>
<TablePagination
count={this.props.transactions.length}
rowsPerPage={this.state.rowsPerPage}
page={this.state.page}
rowsPerPageOptions={[5 , 10]}
onChangePage={this.handleChangePage}
onChangeRowsPerPage={this.handleChangeRowsPerPage}/>
</TableRow>
</TableFooter>
</Table>
))
}
Expand Down
8 changes: 4 additions & 4 deletions src/containers/Accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const styles = theme => ({
},
root: {
flexGrow: 1,
marginTop: 30,
marginRight: 30,
marginLeft: 30,
marginTop: theme.spacing.unit,
marginRight: theme.spacing.unit,
marginLeft: theme.spacing.unit,
textAlign: 'center'
},
paper: {
Expand Down Expand Up @@ -53,7 +53,7 @@ class AddAccountContainer extends React.Component {
<div>

<div className={classes.root}>
<h1>{Constants.ADD_ACCOUNT_PAGE_TITLE}</h1>
<h2>{Constants.ADD_ACCOUNT_PAGE_TITLE}</h2>
<Grid container spacing={8}>

<Grid item md={4} xs={10} sm={5}>
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CategoriesContainer extends React.Component {
<div>

<div className={classes.root}>
<h1>{Constants.ADD_CATEGORY_PAGE_TITLE}</h1>
<h2>{Constants.ADD_CATEGORY_PAGE_TITLE}</h2>
<Grid container spacing={8} className={classes.rootgrid}>

<Grid item md={4} xs={10} sm={5}>
Expand Down
3 changes: 1 addition & 2 deletions src/containers/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import {withStyles} from 'material-ui/styles';
import Paper from 'material-ui/Paper';
import Grid from 'material-ui/Grid';
import Constants from '../utils/constants';
import AccountList from '../components/AccountList';
import TransactionList from '../components/TransactionList';
import CategoryList from '../components/CategoryList';
Expand Down Expand Up @@ -61,7 +60,7 @@ class Dashboard extends React.Component {
const {classes} = this.props;
return (
<div>
<h1>{Constants.DASHBOARD_PAGE_TITLE}</h1>
{/*<h2>{Constants.DASHBOARD_PAGE_TITLE}</h2>*/}
<div className={classes.root}>
<Grid container spacing={8} className={classes.rootgrid}>

Expand Down
1 change: 1 addition & 0 deletions src/containers/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import LoginGoogle from '../components/LoginGoogle';
import SignUp from '../components/SignUp';
import LoginUserNamePassword from '../components/Login';


const styles = theme => ({

button: {
Expand Down
8 changes: 4 additions & 4 deletions src/containers/Transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const styles = theme => ({
},
root: {
flexGrow: 1,
marginTop: 30,
marginRight: 30,
marginLeft: 30,
marginTop: theme.spacing.unit,
marginRight: theme.spacing.unit,
marginLeft: theme.spacing.unit,
textAlign: 'center',
},
paper: {
Expand Down Expand Up @@ -52,7 +52,7 @@ class AddTransactionContainer extends React.Component {
<div>

<div className={classes.root}>
<h1>{Constants.ADD_TRANSACTION_PAGE_TITLE}</h1>
<h2>{Constants.ADD_TRANSACTION_PAGE_TITLE}</h2>
<Grid container spacing={8}>

<Grid item md={4} xs={10} sm={11}>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Constants = {
ASSIGNS_LOGOUT : "Logout",
TEXT_LOGIN_CARD_HEADER : 'Welcome to Family Finance',
TEXT_LOGIN_CARD_BODY : 'Login to your area',
ADD_ACCOUNT_PAGE_TITLE : 'Account',
ADD_ACCOUNT_PAGE_TITLE : 'Accounts',
ADD_TRANSACTION_PAGE_TITLE : 'Transactions',
ADD_CATEGORY_PAGE_TITLE: 'Categories',

Expand Down

0 comments on commit 1e54fb5

Please sign in to comment.