Initial commit

This commit is contained in:
Maksim Eltyshev
2019-08-31 04:07:25 +05:00
commit 5ffef61fe7
613 changed files with 91659 additions and 0 deletions

31
client/src/reducers/app.js Executable file
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
client/src/reducers/auth.js Executable file
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
client/src/reducers/db.js Executable file
View File

@@ -0,0 +1,5 @@
import { createReducer } from 'redux-orm';
import orm from '../orm';
export default createReducer(orm);

21
client/src/reducers/index.js Executable file
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
client/src/reducers/login.js Executable file
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
client/src/reducers/project.js Executable file
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
client/src/reducers/router.js Executable file
View File

@@ -0,0 +1,5 @@
import { connectRouter } from 'connected-react-router';
import history from '../history';
export default connectRouter(history);

17
client/src/reducers/socket.js Executable file
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
client/src/reducers/user.js Executable file
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;
}
};