Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c19f06e
Created scaffolding for front end
Sep 6, 2017
3691229
Removed stock README.md file
Sep 6, 2017
261645b
Added .env file to sluggram backend
Sep 6, 2017
1d82802
Added package.json dependancies and added custom npm scripts
Sep 6, 2017
da6127d
Wrote bare minimum to run npm run watch and render a webpage
Sep 6, 2017
8a06b93
Created the action creaters without the API calls yet :D
Sep 6, 2017
718565c
Added actions for API calls
Sep 6, 2017
5201b51
Added reducer for auth
Sep 6, 2017
edc1d53
Wrote thunk and reporter middleware. Created store modudle
Sep 7, 2017
5216530
Created combined reducer
Sep 7, 2017
f1dc3ce
Added dashboard component
Sep 7, 2017
e3517c3
Added habdlers in Auth Form
Sep 7, 2017
a44cb06
Got button to appear :D
Sep 7, 2017
3ffa459
Added an email form
Sep 7, 2017
f6e4ee6
Rejoicegit add .! It works???
Sep 7, 2017
eac2b71
Added style scaffolding :D
Sep 7, 2017
e19fc6c
Deleted old lab and started from scratch. Added an ass ton of scaffol…
Sep 7, 2017
e24f30e
Added auth action and reducer, Created combined reducer, created stor…
Sep 8, 2017
9b70804
The gingerbread man is in a gingerbread house.
Sep 8, 2017
f7ca90e
Finished setting up the scaffolding :D
Sep 8, 2017
3bbb4ec
Finished auth portion
Sep 8, 2017
9994e62
There's a special place in hell for those who don't indent correctly
Sep 8, 2017
1736295
Added profile action
Sep 8, 2017
248619f
Made custom dynamic validation module
Sep 8, 2017
c4a4c34
Winner winner chicken dinner
Sep 11, 2017
e9003d7
Added profile route and some middleware
Sep 11, 2017
f8a63fd
Added profile form component
Sep 11, 2017
ff0803d
Plugged in settings componenet
Sep 11, 2017
6e3c901
The ginger bread man lives in a gingerbread house. Is he made from th…
Sep 11, 2017
16f8562
Added new component directories
Sep 12, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions README.md

This file was deleted.

4 changes: 4 additions & 0 deletions front/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["es2015", "react"],
"plugins": ["transform-object-rest-spread"]
}
4 changes: 4 additions & 0 deletions front/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
API_URL='http://localhost:3000'
AWS_BUCKET='cf-giggle-app'
AWS_SECRET_ACCESS_KEY='teODM4s7oh9X0tZXQjSomsu7X1HLtz5o6mlTjId5'
AWS_ACCESS_KEY_ID='AKIAIYVWTGIO4BMPFKCA'
21 changes: 21 additions & 0 deletions front/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": [ "error", "single" ],
"semi": ["error", "always"],
"linebreak-style": [ "error", "unix" ]
},
"env": {
"es6": true,
"node": true,
"mocha": true,
"jasmine": true
},
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true,
"impliedStrict": true
},
"extends": "eslint:recommended"
}
2 changes: 2 additions & 0 deletions front/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/.env
39 changes: 39 additions & 0 deletions front/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "frontend",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"build": "webpack",
"watch": "webpack-dev-server --inline --hot"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"clean-webpack-plugin": "^0.1.16",
"css-loader": "^0.28.7",
"dotenv": "^4.0.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"html-webpack-plugin": "^2.30.1",
"node-sass": "^4.5.3",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"redux": "^3.7.2",
"sass-loader": "^6.0.6",
"superagent": "^3.6.0",
"uglifyjs-webpack-plugin": "^0.4.6",
"url-loader": "^0.5.9",
"webpack": "^3.5.6",
"webpack-dev-server": "^2.7.1"
}
}
40 changes: 40 additions & 0 deletions front/src/action/auth-action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import superagent from 'superagent';

export const tokenSet = token => ({
type: 'TOKEN_SET',
payload: token
});

export const tokenDelete = () => ({
type: 'TOKEN_DELETE',
});

export const signupRequest = user => dispatch => {
return superagent.post(`${__API_URL__}/signup`)
.withCredentials()
.send(user)
.then(res => {
dispatch(tokenSet(res.text))
try {
localStorage.auth = res.text;
} catch(err) {
console.error(err);
}
return res;
})
}

export const loginRequest = user => dispatch => {
return superagent.get(`${__API_URL__}/login`)
.withCredentials()
.auth(user.username, user.password)
.then(res => {
dispatch(tokenSet(res.text));
try {
localStorage.auth = res.text;
} catch(err) {
console.error(err);
}
return res;
})
}
23 changes: 23 additions & 0 deletions front/src/action/profile-action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import superagent from 'superagent';

export const profileCreate = profile => ({
type: 'PROFILE_CREATE',
payload: profile
});

export const profileUpdate = profile => ({
type: 'PROFILE_UPDATE',
payload: profile
});

export const profileCreateRequest = profile => (dispatch, getState) => {
let {auth} = getState();
return superagent.post(`${__API_URL__}/profiles`)
.set('Authorization', `Bearer ${auth}`)
.field('bio', profile.bio)
.attach('avatar', profile.avatar)
.then(res => {
dispatch(profileCreate(res.body));
return res;
});
};
35 changes: 35 additions & 0 deletions front/src/component/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import {Provider} from 'react-redux';
import {BrowserRouter, Route, Link} from 'react-router-dom';

import Landing from '../landing';
import SettingsContainer from '../settings-container';
import createAppStore from '../../lib/createAppStore.js';

let store = createAppStore()

class App extends React.Component {
render() {
return(
<span id="app">
<Provider store={store}>
<BrowserRouter>
<section>
<nav>
<ul>
<li><Link to='/welcome/signup'>signup</Link></li>
<li><Link to='/welcome/login'>login</Link></li>
<li><Link to='/settings'>settings</Link></li>
</ul>
</nav>
<Route exact path='/welcome/:auth' component={Landing} />
<Route exact path='/settings' component={SettingsContainer} />
</section>
</BrowserRouter>
</Provider>
</span>
)
}
}

export default App;
97 changes: 97 additions & 0 deletions front/src/component/auth-form/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React from 'react';
import * as util from '../../lib/util.js';

class AuthForm extends React.Component {
constructor(props) {
super(props);
this.state = {
username: '',
password: '',
email: '',
usernameError: null,
passwordError: null,
emailError: null,
error: null
}

this.onChange = this.onChange.bind(this);
this.onSubmit = this.onSubmit.bind(this);
}

onChange(e) {
let {name, value} = e.target;

function errorCheck(errorName) {
return name === errorName && !value ? `${errorName} required`: null;
}

this.setState({
[name]: value,
usernameError: errorCheck('username'),
emailError: errorCheck('email'),
passwordError: errorCheck('password')
})
}

onSubmit(e) {
e.preventDefault();

this.props.onComplete(this.state)
.then(() => {
this.setState({ username: '', email: '', password: ''})
})
.catch(error => {
console.error(error);
this.setState({error});
})
}




render() {

let emailInput = (
<input
name='email'
type='text'
placeholder='Enter a valid email address'
value={this.state.email}
onChange={this.onChange}
/>
)

return(
<form onSubmit={this.onSubmit}>
<input
name='username'
type='text'
placeholder='Enter a username'
value={this.state.username}
onChange={this.onChange}
/>
{util.renderIf(this.state.usernameError,
<span className='tooltip'>
{this.state.usernameError}
</span>
)}
<input
name='password'
type='password'
placeholder='Enter a password'
value={this.state.password}
onChange={this.onChange}
/>
{util.renderIf(this.state.passwordError,
<span className='tooltip'>
{this.state.passwordError}
</span>
)}
{util.renderIf(this.props.auth === 'signup', emailInput)}
<button type='submit'>{this.props.buttonText}</button>
</form>
)
}
}

export default AuthForm;
Empty file.
33 changes: 33 additions & 0 deletions front/src/component/landing/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import {connect} from 'react-redux';

import AuthFrom from '../auth-form';
import * as authReqs from '../../action/auth-action.js'

class Landing extends React.Component {
render() {

let {params} = this.props.match;

let onComplete = params.auth === 'login'?
this.props.login:
this.props.signup;

return(
<AuthFrom
onComplete={onComplete}
auth={params.auth}
buttonText={params.auth}
/>
)
}
};

let mapDispatchToProps = dispatch => {
return {
signup: user => dispatch(authReqs.signupRequest(user)),
login: user => dispatch(authReqs.loginRequest(user))
}
}

export default connect(undefined, mapDispatchToProps)(Landing);
Empty file.
Empty file.
Loading