mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
created fake file uploader
This commit is contained in:
parent
d73437d8c6
commit
3eafd990cb
2 changed files with 9 additions and 6 deletions
|
@ -5,7 +5,7 @@ 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 } from '../types';
|
||||
import { UUID, IFileWithUUID, IResultWithStatus, 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 });
|
||||
|
@ -68,7 +68,7 @@ function* uploadFile({ file, temp_id }: IFileWithUUID) {
|
|||
return yield put(uploadDropStatus(temp_id));
|
||||
}
|
||||
|
||||
const { data, error } = result;
|
||||
const { data, error }: IResultWithStatus<IFile> = result;
|
||||
|
||||
if (error) {
|
||||
return yield put(
|
||||
|
@ -76,13 +76,15 @@ function* uploadFile({ file, temp_id }: IFileWithUUID) {
|
|||
);
|
||||
}
|
||||
|
||||
console.log('upload', data);
|
||||
|
||||
yield put(
|
||||
uploadSetStatus(temp_id, {
|
||||
is_uploading: false,
|
||||
error: null,
|
||||
uuid: data.uuid,
|
||||
url: data.url,
|
||||
thumbnail_url: data.url,
|
||||
uuid: data.id,
|
||||
url: data.full_path,
|
||||
thumbnail_url: data.full_path,
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import { eventChannel, END, EventChannel } from 'redux-saga';
|
|||
import { VALIDATORS } from '~/utils/validators';
|
||||
import { IResultWithStatus, IFile } from '~/redux/types';
|
||||
import { HTTP_RESPONSES } from './api';
|
||||
import { EMPTY_FILE } from '~/redux/uploads/constants';
|
||||
|
||||
export const IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/jpg'];
|
||||
|
||||
|
@ -60,7 +61,7 @@ export const fakeUploader = ({
|
|||
setTimeout(() => {
|
||||
onProgress(2, 2);
|
||||
if (mustSucceed) {
|
||||
resolve({ status: HTTP_RESPONSES.CREATED, data: { id: uuid() } });
|
||||
resolve({ status: HTTP_RESPONSES.CREATED, data: { ...EMPTY_FILE, id: uuid() } });
|
||||
} else {
|
||||
reject({ response: { statusText: error } });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue