From ba26b374ba0898c5790927aa641a3c20fd4aae2e Mon Sep 17 00:00:00 2001 From: muerwre Date: Tue, 6 Aug 2019 18:38:03 +0700 Subject: [PATCH] empty file --- src/constants/cells.ts | 162 ++++++++++++++++----------------- src/redux/types.ts | 6 +- src/redux/uploads/constants.ts | 14 +++ src/redux/uploads/mocks.ts | 12 +++ 4 files changed, 110 insertions(+), 84 deletions(-) create mode 100644 src/redux/uploads/constants.ts create mode 100644 src/redux/uploads/mocks.ts diff --git a/src/constants/cells.ts b/src/constants/cells.ts index 8953fd59..a7e21ed4 100644 --- a/src/constants/cells.ts +++ b/src/constants/cells.ts @@ -1,93 +1,93 @@ -export const BLOCK_TYPES = { - IMAGE: 'IMAGE', - TEXT: 'TEXT', - VIDEO: 'VIDEO', - AUDIO: 'AUDIO', - COVER: 'COVER', -}; +// export const BLOCK_TYPES = { +// IMAGE: 'IMAGE', +// TEXT: 'TEXT', +// VIDEO: 'VIDEO', +// AUDIO: 'AUDIO', +// COVER: 'COVER', +// }; -export const CELL_TYPES = { - IMAGE: 'IMAGE', - POST: 'POST', - MEDIA: 'MEDIA', - DEFAULT: 'DEFAULT', -}; +// export const CELL_TYPES = { +// IMAGE: 'IMAGE', +// POST: 'POST', +// MEDIA: 'MEDIA', +// DEFAULT: 'DEFAULT', +// }; -export interface IFile { - id: number, - cell_id: number, - type: string, - mime: string, - name: string, - path: string, - createdAt: string, - updatedAt: string, - owner: number, -} +// export interface IFile { +// id: number, +// cell_id: number, +// type: string, +// mime: string, +// name: string, +// path: string, +// createdAt: string, +// updatedAt: string, +// owner: number, +// } -export interface IBlock { - block_id: number, -} +// export interface IBlock { +// block_id: number, +// } -export interface ICell { - type: string, - tmp_file_id: number, - tmp_block_id: number, - cell_id: number, - locked_blocks: string[], - initial_blocks: string[], - available_blocks: string[], - blocks: IBlock[], - is_published: boolean, - is_starred: boolean, -} +// export interface ICell { +// type: string, +// tmp_file_id: number, +// tmp_block_id: number, +// cell_id: number, +// locked_blocks: string[], +// initial_blocks: string[], +// available_blocks: string[], +// blocks: IBlock[], +// is_published: boolean, +// is_starred: boolean, +// } -export const DEFAULT_CELL: ICell = { - type: CELL_TYPES.DEFAULT, - tmp_file_id: 0, - tmp_block_id: 0, - cell_id: 0, - locked_blocks: [], - initial_blocks: [], - available_blocks: [], - blocks: [], - is_published: true, - is_starred: false, -}; +// export const DEFAULT_CELL: ICell = { +// type: CELL_TYPES.DEFAULT, +// tmp_file_id: 0, +// tmp_block_id: 0, +// cell_id: 0, +// locked_blocks: [], +// initial_blocks: [], +// available_blocks: [], +// blocks: [], +// is_published: true, +// is_starred: false, +// }; -export const DEFAULT_BLOCK: IBlock = { - block_id: 0, -}; +// export const DEFAULT_BLOCK: IBlock = { +// block_id: 0, +// }; -export const DEFAULT_FILE: IFile = { - id: 0, - cell_id: 0, - type: '', - mime: '', - name: '', - path: '', - createdAt: '', - updatedAt: '', - owner: 0, -}; +// export const DEFAULT_FILE: IFile = { +// id: 0, +// cell_id: 0, +// type: '', +// mime: '', +// name: '', +// path: '', +// createdAt: '', +// updatedAt: '', +// owner: 0, +// }; -interface IBlocks { // todo: continue here - // [x: string]: IBlockImage | IBlockMedia -} +// interface IBlocks { // todo: continue here +// // [x: string]: IBlockImage | IBlockMedia +// } -export const BLOCKS: IBlocks = { - [BLOCK_TYPES.IMAGE]: { - ...DEFAULT_BLOCK, - files: [], // todo: files here - } -}; +// export const BLOCKS: IBlocks = { +// [BLOCK_TYPES.IMAGE]: { +// ...DEFAULT_BLOCK, +// files: [], // todo: files here +// } +// }; -export const CELLS = { - [CELL_TYPES.IMAGE]: { - ...DEFAULT_CELL, - locked_blocks: [BLOCK_TYPES.IMAGE], - available_blocks: [BLOCK_TYPES.IMAGE, BLOCK_TYPES.TEXT], - }, -}; +// export const CELLS = { +// [CELL_TYPES.IMAGE]: { +// ...DEFAULT_CELL, +// locked_blocks: [BLOCK_TYPES.IMAGE], +// available_blocks: [BLOCK_TYPES.IMAGE, BLOCK_TYPES.TEXT], +// }, +// }; diff --git a/src/redux/types.ts b/src/redux/types.ts index 83e51d99..a8ff7be2 100644 --- a/src/redux/types.ts +++ b/src/redux/types.ts @@ -57,10 +57,10 @@ export interface IFile { size: number; type: 'image' | 'text' | 'audio' | 'video'; - mime: MimeType; + mime: string; - createdAt: string; - updatedAt: string; + createdAt?: string; + updatedAt?: string; } export interface INode { diff --git a/src/redux/uploads/constants.ts b/src/redux/uploads/constants.ts new file mode 100644 index 00000000..770c4179 --- /dev/null +++ b/src/redux/uploads/constants.ts @@ -0,0 +1,14 @@ +import { IFile } from "~/redux/types"; + +export const EMPTY_FILE: IFile = { + id: null, + user_id: null, + node_id: null, + + name: 'somefile.jpg', + path: '/covers/', + full_path: '/covers/somefile.jpg', + size: 2400000, + type: 'image', + mime: 'image/jpeg', +}; \ No newline at end of file diff --git a/src/redux/uploads/mocks.ts b/src/redux/uploads/mocks.ts new file mode 100644 index 00000000..7e856c11 --- /dev/null +++ b/src/redux/uploads/mocks.ts @@ -0,0 +1,12 @@ +import { IResultWithStatus, IFile } from "../types"; +import { HTTP_RESPONSES } from "~/utils/api"; + +export const uploadMock = (file: File): Promise> => ( + Promise.resolve(() => ({ + status: HTTP_RESPONSES.CREATED, + data: { + ...EMPTY_FILE, + }, + error: null, + })) +); \ No newline at end of file