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,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