Change prettier rules

This commit is contained in:
ErickSkrauch
2020-05-24 02:08:24 +03:00
parent 73f0c37a6a
commit f85b9d8d35
382 changed files with 24137 additions and 26046 deletions

View File

@@ -1,7 +1,4 @@
import {
changeLang as changeLangEndpoint,
acceptRules as acceptRulesEndpoint,
} from 'app/services/api/accounts';
import { changeLang as changeLangEndpoint, acceptRules as acceptRulesEndpoint } from 'app/services/api/accounts';
import { setLocale } from 'app/components/i18n/actions';
import { ThunkAction } from 'app/reducers';
@@ -15,11 +12,11 @@ export const UPDATE = 'USER_UPDATE';
* @returns {object} - action definition
*/
export function updateUser(payload: Partial<User>) {
// Temp workaround
return {
type: UPDATE,
payload,
};
// Temp workaround
return {
type: UPDATE,
payload,
};
}
export const SET = 'USER_SET';
@@ -30,64 +27,62 @@ export const SET = 'USER_SET';
* @returns {object} - action definition
*/
export function setUser(payload: Partial<User>) {
return {
type: SET,
payload,
};
return {
type: SET,
payload,
};
}
export const CHANGE_LANG = 'USER_CHANGE_LANG';
export function changeLang(targetLang: string): ThunkAction<Promise<void>> {
return async (dispatch, getState) =>
dispatch(setLocale(targetLang)).then((lang: string) => {
const { id, isGuest, lang: oldLang } = getState().user;
return async (dispatch, getState) =>
dispatch(setLocale(targetLang)).then((lang: string) => {
const { id, isGuest, lang: oldLang } = getState().user;
if (oldLang === lang) {
return;
}
if (oldLang === lang) {
return;
}
if (!isGuest && id) {
changeLangEndpoint(id, lang);
}
if (!isGuest && id) {
changeLangEndpoint(id, lang);
}
dispatch({
type: CHANGE_LANG,
payload: {
lang,
},
});
});
dispatch({
type: CHANGE_LANG,
payload: {
lang,
},
});
});
}
export function setGuest(): ThunkAction<Promise<void>> {
return async (dispatch, getState) => {
dispatch(
setUser({
lang: getState().user.lang,
isGuest: true,
}),
);
};
return async (dispatch, getState) => {
dispatch(
setUser({
lang: getState().user.lang,
isGuest: true,
}),
);
};
}
export function acceptRules(): ThunkAction<Promise<{ success: boolean }>> {
return (dispatch, getState) => {
const { id } = getState().user;
return (dispatch, getState) => {
const { id } = getState().user;
if (!id) {
throw new Error(
'user id is should be set at the moment when this action is called',
);
}
if (!id) {
throw new Error('user id is should be set at the moment when this action is called');
}
return acceptRulesEndpoint(id).then((resp) => {
dispatch(
updateUser({
shouldAcceptRules: false,
}),
);
return acceptRulesEndpoint(id).then((resp) => {
dispatch(
updateUser({
shouldAcceptRules: false,
}),
);
return resp;
});
};
return resp;
});
};
}