Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating #119

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b1c5bf6
add backend user model unit test
nikrb Feb 10, 2018
1617151
update fetch-mock and lock file
nikrb Feb 10, 2018
09da6f9
add user actions unit test
nikrb Feb 10, 2018
f4d2968
fix: profile prop-types
nikrb Feb 11, 2018
53b0c14
fix: user types import
nikrb Feb 11, 2018
3079b43
add user reducer unit tests
nikrb Feb 11, 2018
ae47685
refactor login actions
nikrb Feb 11, 2018
7b63c39
add login actions unit tests
nikrb Feb 11, 2018
1381244
fix: remove duplicate search redux actions
nikrb Feb 11, 2018
0e6839d
fix: rename user reducer unit test file
nikrb Feb 11, 2018
05c4cbc
rename userReducer import to user to match other reducers in combineR…
nikrb Feb 11, 2018
eea26a0
fix: card missing image url
nikrb Feb 13, 2018
052209d
fix: refactor image url creator
nikrb Feb 13, 2018
e338bba
fix: reject with missing url instead of console error log
nikrb Feb 13, 2018
b9187b1
Merge pull request #98 from chingu-voyage3/fix/house-image-delete
nikrb Feb 14, 2018
08a68c3
Merge pull request #95 from chingu-voyage3/add-user-unit-test
nikrb Feb 14, 2018
e1d1504
Started refactoring
Mortuie Mar 12, 2018
5809875
Deleting unecessary files
Mortuie Mar 12, 2018
6cef2c0
Refactoring the USER REDUX stuff
Mortuie Mar 26, 2018
e641b01
Refactoring the User Tests
Mortuie Mar 26, 2018
848daa8
Removing an unecessary line
Mortuie Mar 26, 2018
5cdcb73
Added an index.js file
Mortuie Mar 26, 2018
05b4de6
Fixed a bug on the auto complete scrolling
Mortuie Mar 26, 2018
2cdf779
Added minor changes
Mortuie Mar 26, 2018
b3da5c2
Pushing refactor of the actions, but have now broken tests
Mortuie Mar 31, 2018
a60a42c
Removed the cross fetch nonsense
Mortuie Apr 1, 2018
b126b7e
Moved all the tests back after reading an article
Mortuie Apr 1, 2018
3519f95
Fixing the code I broke...
Mortuie Apr 1, 2018
2382039
Fixed the styling of the register box
Mortuie Apr 1, 2018
bd6c08b
Removed the stuff for pre and post pull/pushing or well just commente…
Mortuie Apr 1, 2018
efe209c
fix: credentials is required on fetch for login
nikrb Apr 10, 2018
3c22f92
Merge pull request #112 from chingu-voyage3/leon/refactor
Mortuie Apr 12, 2018
bdd71fa
Merge pull request #118 from chingu-voyage3/master
Mortuie Oct 6, 2018
738e657
fix: display default avatar pic
nikrb Oct 7, 2018
052e5d6
Merge pull request #120 from chingu-voyage3/fix/default-avatar-pic
Mortuie Oct 7, 2018
c0d9cfc
Fixing the register error handling
Mortuie Oct 7, 2018
31b8ee3
Merge pull request #121 from chingu-voyage3/fix/userActions
Mortuie Oct 7, 2018
e0e52de
WIP.
vivekimsit Oct 9, 2018
2d6a8c1
Add error handling.
vivekimsit Oct 10, 2018
65a57d1
Catch validation errors.
vivekimsit Oct 10, 2018
d0dae2f
WIP.
vivekimsit Oct 14, 2018
f1a65f0
WIP.
vivekimsit Oct 17, 2018
96fdb20
Fix auth route and login flow.
vivekimsit Oct 20, 2018
ed03b37
Fix logout logic.
vivekimsit Oct 20, 2018
c022d7a
More fixes.
vivekimsit Oct 20, 2018
e3c622b
Fix login.
vivekimsit Oct 21, 2018
7538de7
Revert to Mongo for now.
vivekimsit Oct 22, 2018
48d9619
Initial commit for the prettier config
Mortuie Oct 22, 2018
9e31c89
Prettier running on all files
Mortuie Oct 22, 2018
05086ba
Adding the last files...
Mortuie Oct 22, 2018
6ee3b0a
Fixing last linting issues and removing the unecessary shell script
Mortuie Oct 22, 2018
e793369
Merge pull request #123 from chingu-voyage3/feature/prettier
Mortuie Oct 22, 2018
0d9c0ea
Initial commit
Mortuie Oct 23, 2018
034b8f8
Added hook
Mortuie Oct 23, 2018
579ffc7
Ran Prettier
Mortuie Oct 23, 2018
707e37e
Revert "Feature/prettier"
Mortuie Oct 23, 2018
bdee79a
Merge pull request #126 from chingu-voyage3/revert-123-feature/prettier
vivekimsit Oct 23, 2018
716eaea
Merge pull request #125 from chingu-voyage3/fixes/prettier
vivekimsit Oct 23, 2018
3740588
Address comments.
vivekimsit Oct 23, 2018
606d475
Lint.
vivekimsit Oct 23, 2018
9727cc2
Merge pull request #122 from chingu-voyage3/fixes/error-handling
vivekimsit Oct 25, 2018
c322860
Edited .gitignore
Mortuie Dec 20, 2018
350b852
Adding the using of the new Url parser
Mortuie Dec 20, 2018
741d32a
Merge pull request #127 from chingu-voyage3/fix/removeDeprecationWarning
Mortuie Dec 20, 2018
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
1,216 changes: 1,004 additions & 212 deletions frontend/package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"dependencies": {
"aphrodite": "^1.2.5",
"axios": "^0.17.1",
"cross-fetch": "^1.1.1",
"prop-types": "^15.6.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
Expand All @@ -27,7 +26,7 @@
"eject": "react-scripts eject"
},
"devDependencies": {
"fetch-mock": "^6.0.0-beta.9",
"fetch-mock": "^6.0.0",
"redux-mock-store": "^1.4.0"
}
}
1 change: 0 additions & 1 deletion frontend/src/API/service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from 'cross-fetch';

const API_ROOT = '/api/v1';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Routes from '../Routes/Routes';
import { Routes } from '../Routes';
import { Navbar } from '../Navbar';
import { Footer } from '../Footer';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { StyleSheet, css } from 'aphrodite';
import {autoLogin} from '../Redux/actions';
import { autoLogin } from '../User/userActions';

class app extends Component {
class Entrypoint extends Component {
static propTypes = {
autoLogin: PropTypes.func.isRequired
};
Expand Down Expand Up @@ -36,15 +36,15 @@ const styles = StyleSheet.create({
display: 'flex',
height: '100%',
minHeight: '100vh',
//overflow: 'hidden',
overflow: 'hidden',
flexDirection: 'column',
backgroundColor: '#f0f0f0'
}
});

const mapStateToProps = state => {
return {
user: state.user
user: state.userReducer
};
};
const mapDispatchToProps = dispatch => {
Expand All @@ -53,5 +53,5 @@ const mapDispatchToProps = dispatch => {
};
};

const App = withRouter(connect(mapStateToProps, mapDispatchToProps)(app));
export default App;
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Entrypoint));

4 changes: 2 additions & 2 deletions frontend/src/Entrypoint/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Main from './Main';
import Entrypoint from './Entrypoint';

export { Main };
export { Entrypoint };
4 changes: 0 additions & 4 deletions frontend/src/Forgot/index.js

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/src/House/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {ImageDefault} from '../Image';
import Rating from '../Rating';
import {StyleSheet, css} from 'aphrodite';

const Card = (props) => (
const Card = props => (
<div className={css(styles.container)}>
<ImageDefault src={props.house.images[0]} missing_url="//via.placeholder.com/350x150?No Image"/>
<ImageDefault src={props.house.images[0]} missing_url="//via.placeholder.com/350x150?text=No Image"/>
<div className={css(styles.title)}>
{props.house.title}
<Rating currentRating={props.house.rating}
Expand Down
27 changes: 15 additions & 12 deletions frontend/src/Image/ImageDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@ class ImageDefault extends React.Component {
};
componentDidMount = () => {
this.component_mounted = true;
ImageRef( this.props.src, "//via.placeholder.com/200x200?text=Not Found")
this.createImage( this.props.src);
};

componentWillReceiveProps = newProps => {
if( this.component_mounted && newProps.src && newProps.src !== this.props.src){
this.createImage( newProps.src);
}
};
componentWillUnmount = () => {
this.component_mounted = false;
};
createImage = src => {
ImageRef( src, "//via.placeholder.com/200x200?text=Not Found")
.then( image_src => {
// check component is mounted or we get warning can't setState on
// unmounted component
if( this.component_mounted) {
this.setState( {image_src});
this.setState( {image_src, image_error:false});
}
})
.catch( () => {
Expand All @@ -34,15 +46,6 @@ class ImageDefault extends React.Component {
}
});
};

componentWillReceiveProps = newProps => {
if( this.component_mounted && newProps.src && newProps.src !== this.props.src){
this.setState( {image_src: newProps.src, image_error: false});
}
};
componentWillUnmount = () => {
this.component_mounted = false;
};
onImageError = () => {
this.setState( {image_error: true, image_src: this.props.missing_url});
};
Expand All @@ -52,7 +55,7 @@ class ImageDefault extends React.Component {
return (
<div>
{ image_error
? <img className={css(styles.image)} src={missing_url} alt="noimage"/>
? <img className={css(styles.image)} src={encodeURI(missing_url)} alt="missing"/>
: <img className={css(styles.image)}
src={image_src}
alt="noimage"
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/Image/ImageRef.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ export default function ImageRef(src, missing_url) {
return new Promise( (resolve, reject) => {
// check for undefined, url, image mongo id, file
if ( typeof src === 'undefined' || src === null) {
reject(encodeURI( missing_url));
resolve(encodeURI( missing_url));
} else if (typeof src === 'string') {
if( src.indexOf('/') === -1) {
loadImage( src)
.then( url => {
resolve(url);
});
.then( url => { resolve(url); })
.catch( () => reject(encodeURI(missing_url)));
} else {
resolve(src);
}
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/Login/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions frontend/src/Logout/index.js

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/src/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { StyleSheet, css } from 'aphrodite';
import { connect } from 'react-redux';
import {logout} from '../Redux/actions';
import {logout} from '../User/userActions';

class navbar extends Component {
static propTypes = {
Expand Down Expand Up @@ -94,7 +94,7 @@ const styles = StyleSheet.create({

function mapStateToProps(state) {
return {
user: state.user.user,
user: state.userReducer.user,
}
}

Expand Down
14 changes: 8 additions & 6 deletions frontend/src/Profile/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {StyleSheet, css} from 'aphrodite';
import Avatar from './Avatar';
import Detail from './Detail';
import ProfileLoader from './Profile.Loader';
import {getDetail, profileSave} from '../Redux/userActions';
import {getDetail, profileSave} from '../User/userActions';
import {ImageRef} from '../Image';

class Profile extends React.Component {
static propTypes = {
isWorking: PropTypes.bool,
error: PropTypes.string,
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
match: PropTypes.object.isRequired,
location: PropTypes.object.isRequired,
getDetail: PropTypes.func.isRequired,
Expand Down Expand Up @@ -54,7 +54,9 @@ class Profile extends React.Component {
};
setAvatarImageSrc = image => {
ImageRef(image, "//via.placeholder.com/200x200?text=No Profile Pic")
.then( avatar_src => this.setState( {avatar_src}));
.then( avatar_src => this.setState( {avatar_src}))
// eslint-disable-next-line no-console
.catch(e => console.error('ImageRef failed:', e));
}
changeImage = avatar => {
this.setState( {user: {...this.state.user, avatar}});
Expand Down Expand Up @@ -101,9 +103,9 @@ class Profile extends React.Component {

const mapStateToProps = state => {
return {
user: state.user.user,
isWorking: state.user.isWorking,
error: state.user.error
user: state.userReducer.user,
isWorking: state.userReducer.isWorking,
error: state.userReducer.error
};
};
const mapDispatchToProps = dispatch => {
Expand Down
102 changes: 0 additions & 102 deletions frontend/src/Redux/actions.js

This file was deleted.

3 changes: 3 additions & 0 deletions frontend/src/Redux/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import store from './store';

export { store };
39 changes: 2 additions & 37 deletions frontend/src/Redux/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,10 @@ import houseIssues from '../Dashboard/reducers';
import house from '../House/reducers';
import issue from '../Issue/reducers';
import search from '../Search/reducers';
import * as UserTypes from './UserTypes';
import { userReducer } from '../User';

function reducer(state = {user:{}, isWorking:false, error:""}, action) {
switch (action.type) {
case UserTypes.AUTO_LOGIN_SUCCESS:
case UserTypes.REQUEST_LOGIN_SUCCESS:
return {...state,
user: action.user
};
case UserTypes.AUTO_LOGIN_FAILED:
case UserTypes.REQUEST_LOGIN_FAILED:
return {...state,
error: action.error
};
case UserTypes.USER_IS_WORKING:
return {...state,
isWorking: action.isWorking
};
case UserTypes.USER_SUCCESS:
return {...state,
user: action.user
};
case UserTypes.USER_ERRORED:
return {
error: action.userErrored
};
case UserTypes.CLEAR_LOGIN_ERROR:
case UserTypes.LOGOUT:
return {...state,
user: {}
};
default:
return state;
}
}

// user key has to be user
export default combineReducers({
user: reducer,
userReducer,
houseIssues,
house,
issue,
Expand Down
Loading