Initial commit

This commit is contained in:
Maksim Eltyshev
2019-08-31 04:07:25 +05:00
commit 36fe34e8e1
583 changed files with 91539 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import { LOCATION_CHANGE } from 'connected-react-router';
import ActionTypes from '../constants/ActionTypes';
const initialState = {
isInitializing: true,
currentModal: null,
};
export default (state = initialState, { type, payload }) => {
switch (type) {
case LOCATION_CHANGE:
case ActionTypes.MODAL_CLOSE:
return {
...state,
currentModal: null,
};
case ActionTypes.APP_INITIALIZED:
return {
...state,
isInitializing: false,
};
case ActionTypes.MODAL_OPEN:
return {
...state,
currentModal: payload.type,
};
default:
return state;
}
};
+24
View File
@@ -0,0 +1,24 @@
import { getAccessToken } from '../utils/access-token-storage';
import ActionTypes from '../constants/ActionTypes';
const initialState = {
accessToken: getAccessToken(),
userId: null,
};
export default (state = initialState, { type, payload }) => {
switch (type) {
case ActionTypes.AUTHENTICATE_SUCCEEDED:
return {
...state,
accessToken: payload.accessToken,
};
case ActionTypes.CURRENT_USER_FETCH_SUCCEEDED:
return {
...state,
userId: payload.user.id,
};
default:
return state;
}
};
+5
View File
@@ -0,0 +1,5 @@
import { createReducer } from 'redux-orm';
import orm from '../orm';
export default createReducer(orm);
+21
View File
@@ -0,0 +1,21 @@
import { combineReducers } from 'redux';
import router from './router';
import socket from './socket';
import db from './db';
import auth from './auth';
import login from './login';
import app from './app';
import user from './user';
import project from './project';
export default combineReducers({
router,
socket,
db,
auth,
login,
app,
user,
project,
});
+43
View File
@@ -0,0 +1,43 @@
import ActionTypes from '../constants/ActionTypes';
const initialState = {
data: {
email: '',
password: '',
},
isSubmitting: false,
error: null,
};
export default (state = initialState, { type, payload }) => {
switch (type) {
case ActionTypes.AUTHENTICATE:
return {
...state,
data: {
...state.data,
...payload.data,
},
};
case ActionTypes.AUTHENTICATION_ERROR_CLEAR:
return {
...state,
error: null,
};
case ActionTypes.AUTHENTICATE_REQUESTED:
return {
...state,
isSubmitting: true,
};
case ActionTypes.AUTHENTICATE_SUCCEEDED:
return initialState;
case ActionTypes.AUTHENTICATE_FAILED:
return {
...state,
isSubmitting: false,
error: payload.error,
};
default:
return state;
}
};
+35
View File
@@ -0,0 +1,35 @@
import ActionTypes from '../constants/ActionTypes';
const initialState = {
data: {
name: '',
},
isSubmitting: false,
};
export default (state = initialState, { type, payload }) => {
switch (type) {
case ActionTypes.PROJECT_CREATE:
return {
...state,
data: {
...state.data,
...payload.data,
},
};
case ActionTypes.PROJECT_CREATE_REQUESTED:
return {
...state,
isSubmitting: true,
};
case ActionTypes.PROJECT_CREATE_SUCCEEDED:
return initialState;
case ActionTypes.PROJECT_CREATE_FAILED:
return {
...state,
isSubmitting: false,
};
default:
return state;
}
};
+5
View File
@@ -0,0 +1,5 @@
import { connectRouter } from 'connected-react-router';
import history from '../history';
export default connectRouter(history);
+17
View File
@@ -0,0 +1,17 @@
import ActionTypes from '../constants/ActionTypes';
const initialState = {
status: null,
};
export default (state = initialState, { type, payload }) => {
switch (type) {
case ActionTypes.SOCKET_STATUS_CHANGED:
return {
...state,
status: payload.status,
};
default:
return state;
}
};
+43
View File
@@ -0,0 +1,43 @@
import ActionTypes from '../constants/ActionTypes';
const initialState = {
data: {
email: '',
name: '',
},
isSubmitting: false,
error: null,
};
export default (state = initialState, { type, payload }) => {
switch (type) {
case ActionTypes.USER_CREATE:
return {
...state,
data: {
...state.data,
...payload.data,
},
};
case ActionTypes.USER_CREATION_ERROR_CLEAR:
return {
...state,
error: null,
};
case ActionTypes.USER_CREATE_REQUESTED:
return {
...state,
isSubmitting: true,
};
case ActionTypes.USER_CREATE_SUCCEEDED:
return initialState;
case ActionTypes.USER_CREATE_FAILED:
return {
...state,
isSubmitting: false,
error: payload.error,
};
default:
return state;
}
};