Skip to content

Commit

Permalink
Merge pull request #47 from andela/bg-fix-deployment-168216313
Browse files Browse the repository at this point in the history
#168216313 To fix bugs on staging branch
  • Loading branch information
dharmykoya committed Sep 3, 2019
2 parents e61d3ed + be3267b commit 787854c
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/components/AuthorCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ const AuthorCard = props => {
</div>

<hr />
<p className="container-fluid author-bio small-text">{bio}</p>
<p className="container-fluid author-bio small-text">
{bio === 'null' || !bio ? '' : bio}
</p>
{isAuthenticated ? (
<div
onClick={handleFollow}
Expand Down
5 changes: 3 additions & 2 deletions src/components/BookmarkTabList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
import IconComponent from '../IconComponent/index.jsx';
import TablistContainer from '../TablistContainer/index.jsx';
import './ArticleTabList.scss';
import PublishModal from '../../components/Modal/index.jsx';

/**
* Sample Usage
Expand Down Expand Up @@ -73,6 +72,7 @@ const articleCardList = props => {
<div className="col-md-4 article-tab-list-action">
<input
type="submit"
/* istanbul ignore next */
onClick={() => props.handleShow(props.slug)}
value={props.actionButton}
/>
Expand All @@ -97,7 +97,8 @@ articleCardList.propTypes = {
actionButton: PropTypes.string,
unpublishArticle: PropTypes.func,
toggleModal: PropTypes.func,
handleShow: PropTypes.func
handleShow: PropTypes.func,
imageObj: PropTypes.object
};

export default articleCardList;
7 changes: 7 additions & 0 deletions src/components/EditProfile/editProfile.action.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from 'axios';
import * as actionTypes from '../../actionTypes/index';
import { toast } from 'react-toastify';

export const editProfileStart = () => {
return {
Expand Down Expand Up @@ -41,6 +42,12 @@ export const updateProfile = (userData, token) => {

localStorage.setItem('user', JSON.stringify(setUserData));
dispatch(editProfileSuccess(data));
})
.catch(error => {
/* istanbul ignore next */
toast.error(error.response.data.data.message);
/* istanbul ignore next */
dispatch(editProfileFail(error.response.data.data.message));
});
};
};
3 changes: 2 additions & 1 deletion src/components/EditProfile/editProfile.reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const editProfileStart = state => {
const editProfileSuccess = (state, action) => {
return updateObject(state, {
userData: action.userData,
loading: false
loading: false,
error: null
});
};
const editProfileFail = (state, action) => {
Expand Down
47 changes: 47 additions & 0 deletions src/components/EditProfile/editProfile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,53 @@ describe('Edit Profile', () => {

done();
});

it('dispatches updateProfile action to fail', done => {
const userData = {
firstName: 'damilola'
};
const token = 'some-token';
const expectedActions = [
{ type: 'EDIT_PROFILE_START' },
{
type: 'EDIT_PROFILE_SUCCESS',
userData: {
firstName: 'Funmilayo',
lastName: 'Adekoya',
bio: 'dhdkala',
userName: 'djjkslka',
twitterHandle: null,
facebookHandle: null,
image:
'https://res.cloudinary.com/fxola/image/upload/v1566997038/avatar/mypic.jpeg.jpg'
}
},
{ type: 'EDIT_PROFILE_FAIL', error: 'lastName cannot be empty' },
{ type: 'EDIT_PROFILE_START' },
{ type: 'EDIT_PROFILE_SUCCESS', userData: undefined },
{ type: 'EDIT_PROFILE_START' }
];

const result = {
data: {
data: {
message: 'something went wrong'
}
}
};
moxios.stubRequest(
'http://persephone-backend-staging.herokuapp.com/api/v1/users',
{
status: 400,
response: result.data
}
);

store.dispatch(updateProfile(userData, token));
expect(store.getActions()).toEqual(expectedActions);

done();
});
});

describe('Edit Profile reducers', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/ProfileNavbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ export class ProfileNavbar extends Component {

await this.props.updateUserProfile(formData, this.props.auth.user.token);
/* istanbul ignore next */
if (this.props.updatedProfileData.userData !== undefined) {
if (this.props.updatedProfileData.error === null) {
console.log('releh');
/* istanbul ignore next */
this.setState({
showEditModal: false,
Expand Down Expand Up @@ -160,7 +161,7 @@ export class ProfileNavbar extends Component {
<p>
{name}
<br />
<small>{this.props.userName}</small>
<small>@{this.props.userName}</small>
</p>
</div>

Expand Down
1 change: 1 addition & 0 deletions src/components/ReportArticle/style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.report-textarea {
width: 100%;
margin: 1rem auto;
color: initial;
}

.report-btn {
Expand Down
3 changes: 2 additions & 1 deletion src/views/BookmarkPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export class BookmarkedArticle extends Component {
</PublishModal>

<div className="col-md-12 publication-container">
{this.props.bookmarks === null ? (
{this.props.bookmarks === null ||
this.props.bookmarks.length === 0 ? (
<h5 className="no-draft-text pt-5 text-center">
You have not bookmarked any articles
</h5>
Expand Down
6 changes: 3 additions & 3 deletions src/views/FollowersPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class DraftArticle extends Component {
user: { token, id }
}
} = this.props;
console.log(id);
this.props.getUserFollowersRequest(id, token);
}

Expand All @@ -29,7 +28,6 @@ export class DraftArticle extends Component {
if (this.props.user && followers) {
FollowersList = Array.isArray(followers) ? (
followers.map(user => {
console.log();
const { id, email, firstName, lastName, image } = user.follower;

return (
Expand All @@ -43,7 +41,9 @@ export class DraftArticle extends Component {
);
})
) : (
<h5 className="text-center">You currently don't have any follower</h5>
<h5 className="text-center pt-5">
You currently don't have any follower
</h5>
);
}
const userDetails = this.props.auth.user;
Expand Down
19 changes: 13 additions & 6 deletions src/views/PasswordResetPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ export class PasswordResetPage extends Component {
handleSubmit = async e => {
e.preventDefault();
this.setState({ isLoading: true });
await this.props.passwordResetRequest(this.props.location.search, {
password: this.state.password
});
await this.props.passwordResetRequest(
this.props.location.search,
this.props.history,
{
password: this.state.password
}
);
this.setState({ isLoading: false });
};

Expand Down Expand Up @@ -105,13 +109,16 @@ export class PasswordResetPage extends Component {
PasswordResetPage.propTypes = {
theme: PropTypes.object,
passwordResetRequest: PropTypes.func,
location: PropTypes.object
location: PropTypes.object,
history: PropTypes.object
};

export const mapDispatchToProps = dispatch => {
return {
passwordResetRequest: async (location, newPassword) => {
return dispatch(await passwordResetRequest(location, newPassword));
passwordResetRequest: async (location, history, newPassword) => {
return dispatch(
await passwordResetRequest(location, history, newPassword)
);
}
};
};
Expand Down
3 changes: 2 additions & 1 deletion src/views/PasswordResetPage/passwordReset.action.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from '../../utils/axiosConfig';
import { toast } from 'react-toastify';

export const passwordResetRequest = (location, newPassword) => {
export const passwordResetRequest = (location, history, newPassword) => {
return async () => {
try {
const response = await axios.patch(
Expand All @@ -10,6 +10,7 @@ export const passwordResetRequest = (location, newPassword) => {
);
if (response.status === 200) {
toast.success(response.data.data.message);
history.push('/login');
}
} catch (error) {
/* istanbul ignore next */
Expand Down
4 changes: 2 additions & 2 deletions src/views/SignupPage/signup.action.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export const authSignup = (userDetails, history) => {
.then(response => {
const { token } = response.data.data;
const { data } = response.data;
localStorage.setItem('token', token);
localStorage.setItem('user', JSON.stringify(data));

toast.success('Registration Successful');

setTimeout(() => {
history.push('/article');
// dispatch set auth
dispatch(setCurrentUser(data));
history.push('/publication');
}, 3000);

dispatch(userSignupSuccess(token, data));
Expand Down

0 comments on commit 787854c

Please sign in to comment.