Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 1 addition & 5 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import { Route, withRouter } from 'react-router-dom';
import PrivateRoute from './components/PrivateRoute';
import './App.scss';
import Main from './views/Main';
import Login from './views/Login';
import { connect } from 'react-redux';
import { decrypt, encrypt } from './components/Cryptr';
import { decrypt } from './components/Cryptr';
import { authenticateFromLocalStorage } from './actions/appActions';
import { loggedIn } from './actions/accountActions';
import Profile from './views/Profile';
import MiniDrawer from './components/MiniDrawer';
import unsplash from './actions/unsplash';
import Matches from './views/Matches';
import Messages from './views/Messages';
import SignOut from './views/SignOut';
import MainStream from './components/MainStream';

class App extends Component {
state = {
Expand Down
46 changes: 31 additions & 15 deletions src/actions/accountActions.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import apiRequest, { requestWithToken } from './axios';
import { requestWithToken } from './axios';
import actionCreator from './actionCreator';
import uuid4 from 'uuid4';

export const UPDATING_ACCOUNT_INFO = 'UPDATING_ACCOUNT_INFO';
export const ACCOUNT_INFORMATION_UPDATED = 'ACCOUNT_INFORMATION_UPDATED';
export const ERROR = 'ERROR';
export const REGISTERED = 'REGISTERED';
export const LOGGED_IN = 'LOGGED_IN';
export const LOGGED_OUT = 'LOGGED_OUT';

let registered = [];

export const updateAccountInfo = (
account,
token,
Expand All @@ -26,16 +22,36 @@ export const updateAccountInfo = (
url = `/jobs/update/${account.id}`;
}

requestWithToken(token)
.put(url, { ...account })
.then(res => {
//debugger;
dispatch(actionCreator(ACCOUNT_INFORMATION_UPDATED, account));
})
.catch(err => {
//debugger;
dispatch(actionCreator(ERROR, err));
});
if (accountType === 'user') {
requestWithToken(token)
.put(url, {
firstName: account.firstName,
lastName: account.lastName,
occupation: account.occupation,
experience: account.experience,
interests: account.interests,
})
.then(res => {
dispatch(actionCreator(ACCOUNT_INFORMATION_UPDATED, account));
})
.catch(err => {
dispatch(actionCreator(ERROR, err));
});
} else if (accountType === 'company') {
requestWithToken(token)
.put(url, {
companyName: account.companyName,
email: account.email,
bio: account.bio,
address: account.address,
})
.then(res => {
dispatch(actionCreator(ACCOUNT_INFORMATION_UPDATED, account));
})
.catch(err => {
dispatch(actionCreator(ERROR, err));
});
}
};

export const logOut = () => {
Expand Down
13 changes: 5 additions & 8 deletions src/actions/appActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { request, requestWithToken } from './axios';
import { request } from './axios';
import actionCreator from './actionCreator';
import { LOGGED_IN } from './accountActions';
import { decrypt, encrypt } from '../components/Cryptr';
import { encrypt } from '../components/Cryptr';

export const CHECKING_AUTHENTICATION = 'CHECKING_AUTHENTICATION';
export const AUTHENTICATED = 'AUTHENTICATED';
Expand All @@ -10,11 +10,9 @@ export const REGISTERED = 'REGISTERED';
export const AUTHENTICATED_FROM_LOCAL_STORAGE =
'AUTHENTICATED_FROM_LOCAL_STORAGE';

let registered = [];

export const checkAuthentication = account => async dispatch => {
dispatch(actionCreator(CHECKING_AUTHENTICATION));
//debugger;

request()
.post('/auth/login', {
email: account.email,
Expand All @@ -32,9 +30,9 @@ export const checkAuthentication = account => async dispatch => {
let key = encrypt('token');
let tokenValue = encrypt(res.data.token);
localStorage.setItem(key, tokenValue);
let account = encrypt(JSON.stringify(data));
let accountToStore = encrypt(JSON.stringify(data));
let accountKey = encrypt('account');
localStorage.setItem(accountKey, account);
localStorage.setItem(accountKey, accountToStore);
}
dispatch(actionCreator(AUTHENTICATED, res.data.token));
dispatch(actionCreator(LOGGED_IN, data));
Expand All @@ -46,7 +44,6 @@ export const checkAuthentication = account => async dispatch => {

export const submitRegistration = account => async dispatch => {
if (account.type === 'company') {
//debugger;
request()
.post('/auth/register', {
email: account.email,
Expand Down
6 changes: 3 additions & 3 deletions src/actions/matchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export const getStream = (token, accountType) => async dispatch => {
requestWithToken(token)
.get(url)
.then(res => {
let accountType = 'job';
let profileType = 'job';
if (accountType === 'company') {
accountType = 'user';
profileType = 'user';
}
res.data = res.data.map(account => {
account.accountType = accountType;
account.accountType = profileType;
return account;
});
dispatch(actionCreator(MATCHES_FETCHED, res.data));
Expand Down
73 changes: 51 additions & 22 deletions src/components/AvatarComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,88 @@ import {
Typography,
} from '@material-ui/core';
import red from '@material-ui/core/colors/red';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import faker from 'faker';
import moment from 'moment';
import SimplePopover from './SimplePopOver';
import { Link } from 'react-router-dom';
import uuid4 from 'uuid4';
import MaterialUiPopOver from './MaterialUiPopOver';

class AvatarComponent extends React.Component {
state = {
popOverElement: null,
popoverOpen: false,
popoverKey: uuid4(),
};

handlePopOverClose = () => {
this.setState({ popOverElement: null });
handlePopOverClose = event => {
if (event.target.value !== this.state.popOverElement) {
console.log('click outer');
if (this.state.popoverOpen === true) {
this.setState(prevState => {
return {
popoverOpen: false,
};
});
}
// this.setState(state => {
// console.log('click inner');
// return {
// popOverElement: null,
// popoverOpen: false,
// };
// });
}
};

handleVertIconClick = event => {
this.setState({
popOverElement: event.currentTarget,
popoverOpen: true,
});
};

getPopOverContent = id => {
return (
<Link replace={true} to={`/profile/${id}`}>
View Profile
</Link>
);
if (this.props.avatar.hasOwnProperty('companyName')) {
return <Link to={`/profile/company/${id}`}>View Profile </Link>;
}
return <Link to={`/profile/user/${id}`}>View Profile</Link>;
};

// componentWillUpdate(nextProps, nextState, nextContext) {
// :
// if (nextState.popoverOpen !== this.state.popoverOpen) {
// return true;
// }
// }

render() {
const { classes } = this.props;

let url = '';
if (this.props.avatar) {
if (this.props.avatar.hasOwnProperty('companyName')) {
url = `/profile/company/${this.props.avatar.id}`;
} else if (this.props.avatar.hasOwnProperty('jobTitle')) {
url = `/profile/jobs/${this.props.avatar.id}`;
} else {
url = `/profile/user/${this.props.avatar.id}`;
}
}

return (
<Card className={classes.card}>
<CardHeader
avatar={
<Avatar
aria-label={this.props.avatar.title}
aria-label={
this.props.avatar && this.props.avatar.title
}
className={classes.bigAvatar}
src={faker.fake('{{image.avatar}}')}
/>
}
action={
<IconButton onClick={this.handleVertIconClick}>
<MoreVertIcon />
<SimplePopover
anchorEl={this.state.popOverElement}
handleClose={this.handlePopOverClose}
getContent={this.getPopOverContent}
id={this.props.avatar.id}
/>
</IconButton>
}
title={this.props.avatar.title}
action={<MaterialUiPopOver url={url} />}
title={this.props.avatar && this.props.avatar.title}
subheader={moment(faker.fake('{{date.past}}')).format(
'dddd, MMMM Do YYYY'
)}
Expand Down
14 changes: 7 additions & 7 deletions src/components/CardDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import SimpleBottomNavigation from './SimpleBottomNavigation';

const CardDetails = ({
classes,
title,
subheader,
image,
imageTitle = null,
title = '',
subheader = '',
image = '',
imageTitle = '',
chips = [],
}) => {
return (
Expand All @@ -36,9 +36,9 @@ const CardDetails = ({

CardDetails.propTypes = {
classes: PropTypes.object.isRequired,
title: PropTypes.string.isRequired,
subheader: PropTypes.string.isRequired,
image: PropTypes.string.isRequired,
title: PropTypes.string,
subheader: PropTypes.string,
image: PropTypes.string,
imageTitle: PropTypes.string,
chips: PropTypes.array,
};
Expand Down
Loading