1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

eslint fix

This commit is contained in:
muerwre 2019-08-09 12:23:07 +07:00
parent dfaac877fb
commit fa4d51360b
81 changed files with 741 additions and 972 deletions

View file

@ -1,10 +1,10 @@
import { AUTH_USER_ACTIONS } from "~/redux/auth/constants";
import {IAuthState, IUser} from "~/redux/auth/types";
import { AUTH_USER_ACTIONS } from '~/redux/auth/constants';
import { IAuthState, IUser } from '~/redux/auth/types';
export const userSendLoginRequest = ({
username, password
}: {
username: string, password: string
username: string; password: string;
}) => ({ type: AUTH_USER_ACTIONS.SEND_LOGIN_REQUEST, username, password });
export const userSetLoginError = (error: IAuthState['login']['error']) => ({

View file

@ -15,9 +15,8 @@ export const apiUserLogin = ({
}: {
username: string;
password: string;
}): Promise<IResultWithStatus<{ token: string; status?: number }>> =>
api
.post(API.USER.LOGIN, { username, password })
.then(resultMiddleware)
.catch(errorMiddleware)
.then(userLoginTransform);
}): Promise<IResultWithStatus<{ token: string; status?: number }>> => api
.post(API.USER.LOGIN, { username, password })
.then(resultMiddleware)
.catch(errorMiddleware)
.then(userLoginTransform);

View file

@ -1,4 +1,4 @@
import {IToken, IUser} from "~/redux/auth/types";
import { IToken, IUser } from '~/redux/auth/types';
export const AUTH_USER_ACTIONS = {
SEND_LOGIN_REQUEST: 'SEND_LOGIN_REQUEST',
@ -39,11 +39,11 @@ export const EMPTY_USER: IUser = {
};
export interface IApiUser {
id: number,
username: string,
email: string,
role: string,
activated: boolean,
createdAt: string,
updatedAt: string,
id: number;
username: string;
email: string;
role: string;
activated: boolean;
createdAt: string;
updatedAt: string;
}

View file

@ -1,6 +1,6 @@
import {AUTH_USER_ACTIONS} from "~/redux/auth/constants";
import * as ActionCreators from "~/redux/auth/actions";
import {IAuthState} from "~/redux/auth/types";
import { AUTH_USER_ACTIONS } from '~/redux/auth/constants';
import * as ActionCreators from '~/redux/auth/actions';
import { IAuthState } from '~/redux/auth/types';
interface ActionHandler<T> {
(state: IAuthState, payload: T extends (...args: any[]) => infer R ? R : any): IAuthState;

View file

@ -1,7 +1,7 @@
import { EMPTY_USER } from "~/redux/auth/constants";
import { createReducer } from "~/utils/reducer";
import { IAuthState } from "~/redux/auth/types";
import { AUTH_USER_HANDLERS } from "~/redux/auth/handlers";
import { EMPTY_USER } from '~/redux/auth/constants';
import { createReducer } from '~/utils/reducer';
import { IAuthState } from '~/redux/auth/types';
import { AUTH_USER_HANDLERS } from '~/redux/auth/handlers';
const HANDLERS = {
...AUTH_USER_HANDLERS,

View file

@ -1,12 +1,14 @@
import { call, put, takeLatest, select } from 'redux-saga/effects';
import {
call, put, takeLatest, select
} from 'redux-saga/effects';
import { SagaIterator } from 'redux-saga';
import { AUTH_USER_ACTIONS } from "~/redux/auth/constants";
import * as ActionCreators from '~/redux/auth/actions';
import { authSetToken, userSetLoginError, authSetUser } from "~/redux/auth/actions";
import { apiUserLogin } from "~/redux/auth/api";
import { modalSetShown, modalShowDialog } from "~/redux/modal/actions";
import { selectToken } from './selectors';
import { push } from 'connected-react-router';
import { AUTH_USER_ACTIONS } from '~/redux/auth/constants';
import * as ActionCreators from '~/redux/auth/actions';
import { authSetToken, userSetLoginError, authSetUser } from '~/redux/auth/actions';
import { apiUserLogin } from '~/redux/auth/api';
import { modalSetShown, modalShowDialog } from '~/redux/modal/actions';
import { selectToken } from './selectors';
import { URLS } from '~/constants/urls';
import { DIALOGS } from '../modal/constants';
import { IResultWithStatus } from '../types';
@ -30,7 +32,7 @@ export function* reqWrapper(requestAction, props = {}): ReturnType<typeof reques
function* sendLoginRequestSaga({ username, password }: ReturnType<typeof ActionCreators.userSendLoginRequest>): SagaIterator {
if (!username || !password) return;
const { error, data: { token, user } }: IResultWithStatus<{ token: string, user: IUser }> = yield call(apiUserLogin, { username, password });
const { error, data: { token, user } }: IResultWithStatus<{ token: string; user: IUser }> = yield call(apiUserLogin, { username, password });
console.log({ token, error });

View file

@ -1,4 +1,4 @@
import { IState } from "~/redux/store";
import { IState } from '~/redux/store';
export const selectUser = (state: IState): IState['auth']['user'] => state.auth.user;
export const selectToken = (state: IState): IState['auth']['token'] => state.auth.token;

View file

@ -1,5 +1,5 @@
import { IResultWithStatus } from "~/redux/types";
import { HTTP_RESPONSES } from "~/utils/api";
import { IResultWithStatus } from '~/redux/types';
import { HTTP_RESPONSES } from '~/utils/api';
export const userLoginTransform = ({ status, data, error }: IResultWithStatus<any>): IResultWithStatus<any> => {
switch (true) {
@ -12,4 +12,4 @@ export const userLoginTransform = ({ status, data, error }: IResultWithStatus<an
default:
return { status, data, error: error || 'Неизвестная ошибка' };
}
};
};