diff --git a/package-lock.json b/package-lock.json index 3f0203a3..ead67eba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 614618ad..970a1d29 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/redux/types.ts b/src/redux/types.ts index a8ff7be2..6c38c96c 100644 --- a/src/redux/types.ts +++ b/src/redux/types.ts @@ -47,9 +47,10 @@ export interface IResultWithStatus { 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; diff --git a/src/redux/uploads/mocks.ts b/src/redux/uploads/mocks.ts index 7e856c11..dc3e6bf8 100644 --- a/src/redux/uploads/mocks.ts +++ b/src/redux/uploads/mocks.ts @@ -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> => ( - Promise.resolve(() => ({ +export const uploadMock = ({ temp_id, file }: { temp_id: UUID, file: File }): Promise> => ( + Promise.resolve({ status: HTTP_RESPONSES.CREATED, data: { ...EMPTY_FILE, + id: uuid(), + temp_id, }, error: null, - })) -); \ No newline at end of file + })); \ No newline at end of file