Skip to content

Conversation

@sasha4ox
Copy link
Contributor

No description provided.

@sasha4ox sasha4ox requested a review from undead404 March 29, 2020 15:06
import fetchAsync from '../utils/fetch';
import createExpiresCookie from '../utils/create-expires-cookie';

const cookie = require('isomorphic-cookie');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


const cookie = require('isomorphic-cookie');

const minutesOfCookieLive = 60;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good approach to naming, but better English would be: minutesCookiesLive

};
}
export function loginSuccess(data) {
cookie.save('token', data.data.token, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use lodash/get for data.data.token so your code doesn't break when your server fails

};
}
export function alertCreator(text) {
const millisecondsToAlertDisapear = 3000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, better move this constant one level out

dispatch(loginStart());
try {
const payload = await fetchAsync(`${apiURL}/login`, 'POST', loginValue);
if (!payload.data) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect you to check HTTP response status code... If you provide any on error

};
}
export function registrationSuccess(data) {
cookie.save('token', data.data.token, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use lodash/get for data.data.token so your code doesn't break when your server fails

};
}

export function registration(regitrationValue) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo (regitration)

};

function Login() {
const formLoginState = useSelector(state => state.form.Login);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if your form is suddenly null? Write useSelector(property('form.Login))` to avoid

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same below

@@ -0,0 +1,7 @@
export default function createExpiresCookie(minutes) {
const millisecondsInSeconds = 1000;
const secondsInMinutes = 60;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these constants out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants