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:
parent
dfaac877fb
commit
fa4d51360b
81 changed files with 741 additions and 972 deletions
|
@ -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']) => ({
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 });
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 || 'Неизвестная ошибка' };
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import { IState } from "~/redux/store";
|
||||
import { IState } from '~/redux/store';
|
||||
|
||||
export const selectModal = (state: IState) => state.modal;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {IBlock, INode} from "../types";
|
||||
import { IBlock, INode } from '../types';
|
||||
|
||||
export const EMPTY_BLOCK: IBlock = {
|
||||
type: null,
|
||||
|
@ -25,4 +25,4 @@ export const EMPTY_NODE: INode = {
|
|||
show_description: false,
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export const NODE_HANDLERS = {
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { createReducer } from "~/utils/reducer";
|
||||
import { INode } from "../types";
|
||||
import { EMPTY_BLOCK, EMPTY_NODE } from "./constants";
|
||||
import { NODE_HANDLERS } from "./handlers";
|
||||
import { EMPTY_FILE } from "../uploads/constants";
|
||||
import uuid from 'uuid4';
|
||||
import { createReducer } from '~/utils/reducer';
|
||||
import { INode } from '../types';
|
||||
import { EMPTY_BLOCK, EMPTY_NODE } from './constants';
|
||||
import { NODE_HANDLERS } from './handlers';
|
||||
import { EMPTY_FILE } from '../uploads/constants';
|
||||
|
||||
export type INodeState = Readonly<{
|
||||
is_loading: boolean;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export default function* nodeSaga() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IState } from "../store";
|
||||
import { INodeState } from "./reducer";
|
||||
import { IState } from '../store';
|
||||
import { INodeState } from './reducer';
|
||||
|
||||
export const selectNode = (state: IState): INodeState => state.node;
|
||||
export const selectNode = (state: IState): INodeState => state.node;
|
||||
|
|
|
@ -1,28 +1,30 @@
|
|||
import { createStore, applyMiddleware, combineReducers, compose, Store } from "redux";
|
||||
import {
|
||||
createStore, applyMiddleware, combineReducers, compose, Store
|
||||
} from 'redux';
|
||||
|
||||
import { persistStore, persistReducer } from "redux-persist";
|
||||
import storage from "redux-persist/lib/storage";
|
||||
import createSagaMiddleware from "redux-saga";
|
||||
import { connectRouter, RouterState, routerMiddleware } from "connected-react-router";
|
||||
import { createBrowserHistory } from "history";
|
||||
import { PersistConfig, Persistor } from "redux-persist/es/types";
|
||||
import { persistStore, persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
import { connectRouter, RouterState, routerMiddleware } from 'connected-react-router';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import { PersistConfig, Persistor } from 'redux-persist/es/types';
|
||||
|
||||
import authReducer from "~/redux/auth/reducer";
|
||||
import authSaga from "~/redux/auth/sagas";
|
||||
import authReducer from '~/redux/auth/reducer';
|
||||
import authSaga from '~/redux/auth/sagas';
|
||||
|
||||
import nodeReducer, { INodeState } from "~/redux/node/reducer";
|
||||
import nodeSaga from "~/redux/node/sagas";
|
||||
import nodeReducer, { INodeState } from '~/redux/node/reducer';
|
||||
import nodeSaga from '~/redux/node/sagas';
|
||||
|
||||
import uploadReducer, { IUploadState } from "~/redux/uploads/reducer";
|
||||
import uploadSaga from "~/redux/uploads/sagas";
|
||||
import uploadReducer, { IUploadState } from '~/redux/uploads/reducer';
|
||||
import uploadSaga from '~/redux/uploads/sagas';
|
||||
|
||||
import { IAuthState } from "~/redux/auth/types";
|
||||
import { IAuthState } from '~/redux/auth/types';
|
||||
|
||||
import modalReducer, { IModalState } from "~/redux/modal/reducer";
|
||||
import modalReducer, { IModalState } from '~/redux/modal/reducer';
|
||||
|
||||
const authPersistConfig: PersistConfig = {
|
||||
key: "auth",
|
||||
whitelist: ["token", "user"],
|
||||
key: 'auth',
|
||||
whitelist: ['token', 'user'],
|
||||
storage
|
||||
};
|
||||
|
||||
|
@ -37,10 +39,9 @@ export interface IState {
|
|||
export const sagaMiddleware = createSagaMiddleware();
|
||||
export const history = createBrowserHistory();
|
||||
|
||||
const composeEnhancers =
|
||||
typeof window === "object" && (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
? (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
||||
: compose;
|
||||
const composeEnhancers = typeof window === 'object' && (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
? (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
||||
: compose;
|
||||
|
||||
export const store = createStore(
|
||||
combineReducers<IState>({
|
||||
|
|
|
@ -7,8 +7,8 @@ export interface ITag {
|
|||
}
|
||||
|
||||
export type IInputTextProps = DetailedHTMLProps<
|
||||
InputHTMLAttributes<HTMLInputElement>,
|
||||
HTMLInputElement
|
||||
InputHTMLAttributes<HTMLInputElement>,
|
||||
HTMLInputElement
|
||||
> & {
|
||||
wrapperClassName?: string;
|
||||
handler?: (value: string) => void;
|
||||
|
@ -72,7 +72,7 @@ export interface IFileWithUUID {
|
|||
}
|
||||
|
||||
export interface IBlock {
|
||||
type: 'image' | 'text' | 'media' | 'youtube' | 'video',
|
||||
type: 'image' | 'text' | 'media' | 'youtube' | 'video';
|
||||
temp_ids: UUID[];
|
||||
attaches: UUID[];
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ export interface INode {
|
|||
flow: {
|
||||
display: 'single' | 'double' | 'quadro';
|
||||
show_description: boolean;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
createdAt?: string;
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
import { UPLOAD_ACTIONS } from "~/redux/uploads/constants";
|
||||
import { IFileWithUUID, UUID, IFile } from "../types";
|
||||
import { IUploadStatus } from "./reducer";
|
||||
import { UPLOAD_ACTIONS } from '~/redux/uploads/constants';
|
||||
import { IFileWithUUID, UUID, IFile } from '../types';
|
||||
import { IUploadStatus } from './reducer';
|
||||
|
||||
export const uploadUploadFiles = (files: IFileWithUUID[]) => ({
|
||||
files,
|
||||
type: UPLOAD_ACTIONS.UPLOAD_FILES,
|
||||
type: UPLOAD_ACTIONS.UPLOAD_FILES
|
||||
});
|
||||
|
||||
export const uploadAddStatus = (temp_id: UUID, status?: Partial<IUploadStatus>) => ({
|
||||
temp_id,
|
||||
status,
|
||||
type: UPLOAD_ACTIONS.ADD_STATUS,
|
||||
type: UPLOAD_ACTIONS.ADD_STATUS
|
||||
});
|
||||
|
||||
export const uploadAddFile = (file: IFile) => ({
|
||||
file,
|
||||
type: UPLOAD_ACTIONS.ADD_FILE,
|
||||
type: UPLOAD_ACTIONS.ADD_FILE
|
||||
});
|
||||
|
||||
export const uploadSetStatus = (temp_id: UUID, status?: Partial<IUploadStatus>) => ({
|
||||
temp_id,
|
||||
status,
|
||||
type: UPLOAD_ACTIONS.SET_STATUS,
|
||||
type: UPLOAD_ACTIONS.SET_STATUS
|
||||
});
|
||||
|
||||
export const uploadDropStatus = (temp_id: UUID) => ({
|
||||
temp_id,
|
||||
type: UPLOAD_ACTIONS.DROP_STATUS,
|
||||
type: UPLOAD_ACTIONS.DROP_STATUS
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { IFile } from "~/redux/types";
|
||||
import { IUploadState, IUploadStatus } from "./reducer";
|
||||
import { IFile } from '~/redux/types';
|
||||
import { IUploadState, IUploadStatus } from './reducer';
|
||||
|
||||
const prefix = 'UPLOAD.';
|
||||
|
||||
|
@ -38,4 +38,4 @@ export const EMPTY_UPLOAD_STATUS: IUploadStatus = {
|
|||
thumbnail_url: null,
|
||||
type: null,
|
||||
temp_id: null,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,7 +2,9 @@ import assocPath from 'ramda/es/assocPath';
|
|||
import omit from 'ramda/es/omit';
|
||||
|
||||
import { UPLOAD_ACTIONS, EMPTY_UPLOAD_STATUS } from './constants';
|
||||
import { uploadAddStatus, uploadDropStatus, uploadSetStatus, uploadAddFile } from './actions';
|
||||
import {
|
||||
uploadAddStatus, uploadDropStatus, uploadSetStatus, uploadAddFile
|
||||
} from './actions';
|
||||
import { IUploadState } from './reducer';
|
||||
|
||||
const addStatus = (
|
||||
|
@ -17,33 +19,25 @@ const addStatus = (
|
|||
const dropStatus = (
|
||||
state: IUploadState,
|
||||
{ temp_id }: ReturnType<typeof uploadDropStatus>
|
||||
): IUploadState => assocPath(
|
||||
['statuses'],
|
||||
omit([temp_id], state.statuses),
|
||||
state,
|
||||
);
|
||||
): IUploadState => assocPath(['statuses'], omit([temp_id], state.statuses), state);
|
||||
|
||||
const setStatus = (
|
||||
state: IUploadState,
|
||||
{ temp_id, status }: ReturnType<typeof uploadSetStatus>
|
||||
): IUploadState => assocPath(
|
||||
['statuses'],
|
||||
{ ...state.statuses, [temp_id]: { ...(state.statuses[temp_id] || EMPTY_UPLOAD_STATUS), ...status } },
|
||||
{
|
||||
...state.statuses,
|
||||
[temp_id]: { ...(state.statuses[temp_id] || EMPTY_UPLOAD_STATUS), ...status }
|
||||
},
|
||||
state
|
||||
);
|
||||
|
||||
const addFile = (
|
||||
state: IUploadState,
|
||||
{ file }: ReturnType<typeof uploadAddFile>
|
||||
): IUploadState => assocPath(
|
||||
['files'],
|
||||
{ ...state.files, [file.id]: file },
|
||||
state
|
||||
);
|
||||
const addFile = (state: IUploadState, { file }: ReturnType<typeof uploadAddFile>): IUploadState => assocPath(['files'], { ...state.files, [file.id]: file }, state);
|
||||
|
||||
export const UPLOAD_HANDLERS = {
|
||||
[UPLOAD_ACTIONS.ADD_STATUS]: addStatus,
|
||||
[UPLOAD_ACTIONS.DROP_STATUS]: dropStatus,
|
||||
[UPLOAD_ACTIONS.SET_STATUS]: setStatus,
|
||||
[UPLOAD_ACTIONS.ADD_FILE]: addFile,
|
||||
[UPLOAD_ACTIONS.ADD_FILE]: addFile
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { IResultWithStatus, IFile, UUID } from "../types";
|
||||
import { HTTP_RESPONSES } from "~/utils/api";
|
||||
import { EMPTY_FILE } from "./constants";
|
||||
import uuid from 'uuid4';
|
||||
import { IResultWithStatus, IFile, UUID } from '../types';
|
||||
import { HTTP_RESPONSES } from '~/utils/api';
|
||||
import { EMPTY_FILE } from './constants';
|
||||
|
||||
export const uploadMock = ({ temp_id, file }: { temp_id: UUID, file: File }): Promise<IResultWithStatus<IFile>> => (
|
||||
export const uploadMock = ({ temp_id, file }: { temp_id: UUID; file: File }): Promise<IResultWithStatus<IFile>> => (
|
||||
Promise.resolve({
|
||||
status: HTTP_RESPONSES.CREATED,
|
||||
data: {
|
||||
|
@ -12,4 +12,4 @@ export const uploadMock = ({ temp_id, file }: { temp_id: UUID, file: File }): Pr
|
|||
temp_id,
|
||||
},
|
||||
error: null,
|
||||
}));
|
||||
}));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { createReducer } from "~/utils/reducer";
|
||||
import { IFile, UUID } from "~/redux/types";
|
||||
import { UPLOAD_HANDLERS } from "./handlers";
|
||||
import { createReducer } from '~/utils/reducer';
|
||||
import { IFile, UUID } from '~/redux/types';
|
||||
import { UPLOAD_HANDLERS } from './handlers';
|
||||
|
||||
export interface IUploadStatus {
|
||||
is_uploading: boolean;
|
||||
|
@ -24,4 +24,4 @@ const INITIAL_STATE = {
|
|||
statuses: {},
|
||||
};
|
||||
|
||||
export default createReducer(INITIAL_STATE, UPLOAD_HANDLERS);
|
||||
export default createReducer(INITIAL_STATE, UPLOAD_HANDLERS);
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
import { takeEvery, all, spawn, call, put, take, fork, race } from 'redux-saga/effects';
|
||||
import {
|
||||
takeEvery, all, spawn, call, put, take, fork, race
|
||||
} from 'redux-saga/effects';
|
||||
import { UPLOAD_ACTIONS } from '~/redux/uploads/constants';
|
||||
import { uploadUploadFiles, uploadSetStatus, uploadAddStatus, uploadDropStatus, uploadAddFile } from './actions';
|
||||
import {
|
||||
uploadUploadFiles, uploadSetStatus, uploadAddStatus, uploadDropStatus, uploadAddFile
|
||||
} from './actions';
|
||||
import { reqWrapper } from '../auth/sagas';
|
||||
import { createUploader, uploadGetThumb, fakeUploader } from '~/utils/uploader';
|
||||
import { HTTP_RESPONSES } from '~/utils/api';
|
||||
import { VALIDATORS } from '~/utils/validators';
|
||||
import { UUID, IFileWithUUID, IResultWithStatus, IFile } from '../types';
|
||||
import { UUID, IFileWithUUID, IFile } from '../types';
|
||||
|
||||
function* uploadCall({ temp_id, onProgress, file }) {
|
||||
return yield call(reqWrapper, fakeUploader, { file: { url: 'some', error: 'cant do this boss' }, onProgress, mustSucceed: true });
|
||||
|
|
|
@ -2,4 +2,4 @@ import { IState } from '~/redux/store';
|
|||
import { IUploadState } from '~/redux/uploads/reducer';
|
||||
|
||||
export const selectUploads = ({ uploads }: IState): IUploadState => uploads;
|
||||
export const selectUploadStatuses = ({ uploads: { statuses } }: IState): IUploadState['statuses'] => statuses;
|
||||
export const selectUploadStatuses = ({ uploads: { statuses } }: IState): IUploadState['statuses'] => statuses;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue