1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

upload mock

This commit is contained in:
muerwre 2019-08-06 18:41:37 +07:00
parent ba26b374ba
commit 5659914f3f
4 changed files with 19 additions and 9 deletions

5
package-lock.json generated
View file

@ -16862,6 +16862,11 @@
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz",
"integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA=="
},
"uuid4": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/uuid4/-/uuid4-1.1.4.tgz",
"integrity": "sha512-Gr1q2k40LpF8CokcnQFjPDsdslzJbTCTBG5xQIEflUov431gFkY5KduiGIeKYAamkQnNn4IfdHJbLnl9Bib8TQ=="
},
"v8-compile-cache": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.2.tgz",

View file

@ -96,6 +96,7 @@
"tslint-config-airbnb": "^5.11.1",
"tslint-react": "^4.0.0",
"tslint-react-hooks": "^2.2.1",
"tt-react-custom-scrollbars": "latest"
"tt-react-custom-scrollbars": "latest",
"uuid4": "^1.1.4"
}
}

View file

@ -47,9 +47,10 @@ export interface IResultWithStatus<T> {
export type UUID = string;
export interface IFile {
id: UUID;
user_id: UUID;
node_id: UUID;
id?: UUID;
temp_id?: UUID;
user_id?: UUID;
node_id?: UUID;
name: string;
path: string;

View file

@ -1,12 +1,15 @@
import { IResultWithStatus, IFile } from "../types";
import { IResultWithStatus, IFile, UUID } from "../types";
import { HTTP_RESPONSES } from "~/utils/api";
import { EMPTY_FILE } from "./constants";
import uuid from 'uuid4';
export const uploadMock = (file: File): Promise<IResultWithStatus<IFile>> => (
Promise.resolve(() => ({
export const uploadMock = ({ temp_id, file }: { temp_id: UUID, file: File }): Promise<IResultWithStatus<IFile>> => (
Promise.resolve({
status: HTTP_RESPONSES.CREATED,
data: {
...EMPTY_FILE,
id: uuid(),
temp_id,
},
error: null,
}))
);
}));