diff --git a/src/redux/modal/constants.ts b/src/redux/modal/constants.ts index eacf9b11..f9562d75 100644 --- a/src/redux/modal/constants.ts +++ b/src/redux/modal/constants.ts @@ -10,12 +10,12 @@ export const MODAL_ACTIONS = { }; export const DIALOGS = { - TEST: 'TEST', + EDITOR: 'EDITOR', LOGIN: 'LOGIN', }; export const DIALOG_CONTENT = { - [DIALOGS.TEST]: ExampleDialog, + [DIALOGS.EDITOR]: ExampleDialog, [DIALOGS.LOGIN]: LoginDialog, }; diff --git a/src/redux/modal/reducer.ts b/src/redux/modal/reducer.ts index f6b830c1..274bba6b 100644 --- a/src/redux/modal/reducer.ts +++ b/src/redux/modal/reducer.ts @@ -10,7 +10,7 @@ export interface IModalState { const INITIAL_STATE: IModalState = { is_shown: true, - dialog: DIALOGS.LOGIN, + dialog: DIALOGS.EDITOR, }; export default createReducer(INITIAL_STATE, MODAL_HANDLERS); diff --git a/src/redux/node/constants.ts b/src/redux/node/constants.ts new file mode 100644 index 00000000..b2f9a8c0 --- /dev/null +++ b/src/redux/node/constants.ts @@ -0,0 +1,20 @@ +import { INode } from "../types"; + +export const EMPTY_NODE: INode = { + id: null, + + user_id: null, + + title: '', + files: [], + + cover: null, + type: null, + + options: { + flow: { + display: 'single', + show_description: false, + } + }, +} \ No newline at end of file diff --git a/src/redux/node/handlers.ts b/src/redux/node/handlers.ts new file mode 100644 index 00000000..4601c35b --- /dev/null +++ b/src/redux/node/handlers.ts @@ -0,0 +1,3 @@ +export const NODE_HANDLERS = { + +}; \ No newline at end of file diff --git a/src/redux/node/reducer.ts b/src/redux/node/reducer.ts index ed59aab9..a48d43f9 100644 --- a/src/redux/node/reducer.ts +++ b/src/redux/node/reducer.ts @@ -1,15 +1,18 @@ import { createReducer } from "~/utils/reducer"; +import { INode } from "../types"; +import { EMPTY_NODE } from "./constants"; +import { NODE_HANDLERS } from "./handlers"; -export type INodeState = { +export type INodeState = Readonly<{ is_loading: boolean; -} - -const HANDLERS = { - -}; + editor: INode; +}>; const INITIAL_STATE: INodeState = { + editor: { + ...EMPTY_NODE, + }, is_loading: false, }; -export default createReducer(INITIAL_STATE, HANDLERS); \ No newline at end of file +export default createReducer(INITIAL_STATE, NODE_HANDLERS); \ No newline at end of file diff --git a/src/redux/node/sagas.ts b/src/redux/node/sagas.ts new file mode 100644 index 00000000..0d5fbe5f --- /dev/null +++ b/src/redux/node/sagas.ts @@ -0,0 +1,3 @@ +export default function* nodeSaga() { + +} \ No newline at end of file diff --git a/src/redux/store.ts b/src/redux/store.ts index 918c1a2a..7768dbe2 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -8,17 +8,23 @@ import { createBrowserHistory } from "history"; import { PersistConfig, Persistor } from "redux-persist/es/types"; import { routerMiddleware } from "connected-react-router"; -import userReducer from "~/redux/auth/reducer"; -import userSaga from "~/redux/auth/sagas"; +import authReducer from "~/redux/auth/reducer"; +import authSaga from "~/redux/auth/sagas"; + +import nodeReducer, { INodeState } from "~/redux/node/reducer"; +import nodeSaga from "~/redux/node/sagas"; + +import uploadReducer, { IUploadState } from "~/redux/uploads/reducer"; +import uploadSaga from "~/redux/node/sagas"; import { IAuthState } from "~/redux/auth/types"; import modalReducer, { IModalState } from "~/redux/modal/reducer"; import { IState } from "~/redux/store"; -const userPersistConfig: PersistConfig = { - key: "user", - whitelist: ["profile"], +const authPersistConfig: PersistConfig = { + key: "auth", + whitelist: ["token"], storage }; @@ -26,6 +32,8 @@ export interface IState { auth: IAuthState; modal: IModalState; router: RouterState; + node: INodeState; + uploads: IUploadState; } export const sagaMiddleware = createSagaMiddleware(); @@ -38,15 +46,19 @@ const composeEnhancers = export const store = createStore( combineReducers({ - auth: persistReducer(userPersistConfig, userReducer), + auth: persistReducer(authPersistConfig, authReducer), modal: modalReducer, - router: connectRouter(history) + router: connectRouter(history), + node: nodeReducer, + uploads: uploadReducer, }), composeEnhancers(applyMiddleware(routerMiddleware(history), sagaMiddleware)) ); export function configureStore(): { store: Store; persistor: Persistor } { - sagaMiddleware.run(userSaga); + sagaMiddleware.run(authSaga); + sagaMiddleware.run(nodeSaga); + sagaMiddleware.run(uploadSaga); const persistor = persistStore(store); diff --git a/src/redux/types.ts b/src/redux/types.ts index f17e8c6a..83e51d99 100644 --- a/src/redux/types.ts +++ b/src/redux/types.ts @@ -67,6 +67,7 @@ export interface INode { id?: UUID; user_id: UUID; + title: string; files: IFile[]; cover: IFile['id']; @@ -82,7 +83,7 @@ export interface INode { options: { flow: { display: 'single' | 'double' | 'quadro'; - has_description: boolean; + show_description: boolean; } }; diff --git a/src/redux/uploads/handlers.ts b/src/redux/uploads/handlers.ts new file mode 100644 index 00000000..76f9e6b0 --- /dev/null +++ b/src/redux/uploads/handlers.ts @@ -0,0 +1,3 @@ +export const UPLOAD_HANDLERS = { + +} \ No newline at end of file diff --git a/src/redux/uploads/reducer.ts b/src/redux/uploads/reducer.ts new file mode 100644 index 00000000..c625a715 --- /dev/null +++ b/src/redux/uploads/reducer.ts @@ -0,0 +1,20 @@ +import { createReducer } from "~/utils/reducer"; +import { IFile } from "~/constants/cells"; +import { UUID } from "../types"; +import { UPLOAD_HANDLERS } from "./handlers"; + +export interface IUploadStatus { + progress: number; is_loading: boolean; error: string; +} + +export interface IUploadState { + files: Record; + statuses: Record; +} + +const INITIAL_STATE = { + files: {}, + statuses: {}, +}; + +export default createReducer(INITIAL_STATE, UPLOAD_HANDLERS); \ No newline at end of file diff --git a/src/redux/uploads/sagas.ts b/src/redux/uploads/sagas.ts new file mode 100644 index 00000000..4806adc2 --- /dev/null +++ b/src/redux/uploads/sagas.ts @@ -0,0 +1,3 @@ +export default function* () { + +} \ No newline at end of file