-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,156 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", "@babel/preset-react" | ||
"presets": ["@babel/preset-env", "@babel/preset-react"], | ||
"plugins": [ | ||
"@babel/plugin-proposal-class-properties", | ||
"@babel/transform-runtime" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
/node_modules/* | ||
dist/* | ||
*.test.js | ||
*.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
coverage/ | ||
package-lock.json | ||
dist/ | ||
src/tests/__snapshots__/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,3 @@ eslint: | |
enabled: true | ||
config_file: .eslintrc | ||
ignore_file: .eslintignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
{ | ||
"addons": [ | ||
|
||
], | ||
"addons": [], | ||
"buildpacks": [ | ||
{ | ||
"url": "heroku/nodejs" | ||
} | ||
], | ||
"env": { | ||
}, | ||
"env": {}, | ||
"formation": { | ||
"web": { | ||
"quantity": 1 | ||
} | ||
}, | ||
"name": "ah-frontend-prime", | ||
"scripts": { | ||
}, | ||
"scripts": {}, | ||
"stack": "heroku-18" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
const express = require('express'); | ||
const express = require("express"); | ||
|
||
const app = express(); | ||
const path = require('path'); | ||
const path = require("path"); | ||
|
||
app.use(express.static('dist')); | ||
app.get('*', (req, res) => { | ||
res.sendFile(path.resolve(__dirname, 'dist', 'index.html')); | ||
app.use(express.static("dist")); | ||
app.get("*", (req, res) => { | ||
res.sendFile(path.resolve(__dirname, "dist", "index.html")); | ||
}); | ||
|
||
const PORT = process.env.PORT || 5000; | ||
app.listen(PORT, () => console.log(`Authors Haven running on port ${PORT}`)) | ||
app.listen(PORT, () => console.log(`Authors Haven running on port ${PORT}`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import axios from "axios"; | ||
|
||
import { toast } from "react-toastify"; | ||
import { LOGIN_STARTED, LOGIN_FAIL, SUCCESSFUL } from "./types"; | ||
|
||
export const successLogin = data => { | ||
return { | ||
type: SUCCESSFUL, | ||
payload: data.data.user.token | ||
}; | ||
}; | ||
|
||
export const userLoginRequest = (userData, props) => async dispatch => { | ||
toast.dismiss(); | ||
dispatch({ | ||
type: LOGIN_STARTED | ||
}); | ||
try { | ||
const response = await axios.post( | ||
"https://ah-backend-prime-staging.herokuapp.com/api/v1/users/login/", | ||
userData | ||
); | ||
dispatch(successLogin(response)); | ||
sessionStorage.setItem("token", response.data.user.token); | ||
toast.success(`Welcome ${response.data.user.username}. Login Successful`, { | ||
position: toast.POSITION.TOP_RIGHT, | ||
autoClose: 2000, | ||
hideProgressBar: false | ||
}); | ||
} catch (error) { | ||
dispatch({ | ||
type: LOGIN_FAIL | ||
}); | ||
const errors = error.response.data.errors; | ||
|
||
errors.error.forEach(err => { | ||
toast.error(` ${err}`, { | ||
position: toast.POSITION.TOP_RIGHT, | ||
autoClose: false, | ||
hideProgressBar: false | ||
}); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export const FETCH_ARTICLES_SUCCESS = "FETCH_ARTICLES_SUCCESS"; | ||
export const LOGIN_STARTED = "LOGIN_STARTED"; | ||
export const LOGIN_FAIL = "LOGIN_FAIL"; | ||
export const SUCCESSFUL = "SUCCESSFUL"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import React from "react"; | ||
import Grid from "@material-ui/core/Grid"; | ||
import Paper from "@material-ui/core/Paper"; | ||
import { withStyles } from "@material-ui/core/styles"; | ||
import TextField from "@material-ui/core/TextField"; | ||
import Button from "@material-ui/core/Button"; | ||
import "../../styles/register.scss"; | ||
|
||
const styles = themes => ({ | ||
floatingLabelFocusStyle: { | ||
color: "black", | ||
fontFamily: "Quantico", | ||
fontSize: "15px", | ||
fontWeight: "bold" | ||
} | ||
}); | ||
const LoginComponent = props => { | ||
const { | ||
classes, | ||
password, | ||
email, | ||
handleChange, | ||
handleSubmit, | ||
isProcessing | ||
} = props; | ||
|
||
let Loader = require("react-loader"); | ||
|
||
return ( | ||
<div> | ||
<Grid container spacing={24}> | ||
<Grid item lg={2} md={2} /> | ||
<Grid item lg={8} md={8}> | ||
<Paper className="Paper"> | ||
<h3>Welcome back!</h3> | ||
<p> | ||
SignIn to like, dislike, favorite and unfavorite various articles, | ||
<br /> | ||
follow authors and comment on articles. | ||
</p> | ||
<Grid container spacing={24}> | ||
<Grid item lg={6} md={6}> | ||
<div className="button-collective"> | ||
<Button className="face-book"> | ||
<img | ||
src="https://img.icons8.com/color/96/000000/facebook.png" | ||
width="=40px" | ||
height="40px" | ||
alt="facebook" | ||
/> | ||
Login with Facebook | ||
</Button> | ||
<Button className="twitter"> | ||
<img | ||
src="https://img.icons8.com/color/96/000000/twitter-circled.png" | ||
width="=40px" | ||
height="40px" | ||
alt="twitter" | ||
/> | ||
Login with Twitter | ||
</Button> | ||
<Button className="google"> | ||
<img | ||
src="https://img.icons8.com/color/96/000000/google-logo.png" | ||
width="=40px" | ||
height="40px" | ||
alt="google" | ||
/> | ||
Login with Google | ||
</Button> | ||
</div> | ||
</Grid> | ||
<Grid item lg={6} md={6} className="grid-register"> | ||
<form method="post" onSubmit={handleSubmit}> | ||
<TextField | ||
InputLabelProps={{ | ||
className: classes.floatingLabelFocusStyle | ||
}} | ||
id="email" | ||
label="email" | ||
name="email" | ||
type="text" | ||
required | ||
className="textField" | ||
value={email} | ||
onChange={handleChange} | ||
/> | ||
|
||
<TextField | ||
InputLabelProps={{ | ||
className: classes.floatingLabelFocusStyle | ||
}} | ||
id="password" | ||
label="password" | ||
name="password" | ||
required | ||
minLength={6} | ||
maxLength={16} | ||
type="password" | ||
className="textField" | ||
value={password} | ||
onChange={handleChange} | ||
/> | ||
|
||
<Loader loaded={!isProcessing} /> | ||
<Button type="submit" className="button-success"> | ||
Login | ||
</Button> | ||
</form> | ||
</Grid> | ||
</Grid> | ||
<p> | ||
Don't have an account yet?{" "} | ||
<a href="/register" id="link"> | ||
create one now | ||
</a> | ||
</p> | ||
<p> | ||
Forgot your password?{" "} | ||
<a href="/passwordreset" id="link"> | ||
reset now | ||
</a> | ||
</p> | ||
</Paper> | ||
</Grid> | ||
<Grid item lg={2} md={2} /> | ||
</Grid> | ||
</div> | ||
); | ||
}; | ||
export default withStyles(styles)(LoginComponent); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
import React, { Component } from "react"; | ||
import { BrowserRouter, Route } from "react-router-dom"; | ||
|
||
import Login from "./loginComponent"; | ||
import LoginContainer from "../containers/Login/LoginContainer"; | ||
import Home from "./home"; | ||
|
||
class Routes extends Component { | ||
render() { | ||
return ( | ||
<BrowserRouter> | ||
<Route exact path="/" component={Home} /> | ||
<Route path="/login" component={Login} /> | ||
<Route exact path="/home" component={Home} /> | ||
<Route path="/login" component={LoginContainer} /> | ||
</BrowserRouter> | ||
); | ||
} | ||
} | ||
|
||
export default Routes; |
Oops, something went wrong.