e87390adb9
* update eslint and dependencies, fix linting errors that can be fixed with --fix * fix lots of linting errors * update eslintrc, fix some linting errors * fix all server side linting errors, untested * fix errors that fixing linting errors had caused * fix client side eslint errors * fix client side linting errors * fix refs lint errors * fix more linting errors * update eslint and dependencies, fix linting errors that can be fixed with --fix * fix lots of linting errors * update eslintrc, fix some linting errors * fix all server side linting errors, untested * fix errors that fixing linting errors had caused * fix client side eslint errors * fix client side linting errors * fix refs lint errors * fix more linting errors * fix some accessibility linting errors * fix a lot of linting errors * fix a billion more linting errors * hopefully fix all linting errors, still need to test * fix bugs that fixing linting had caused
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import generate from 'project-name-generator';
|
|
import * as ActionTypes from '../../../constants';
|
|
|
|
const initialState = () => {
|
|
const generatedString = generate({ words: 2 }).spaced;
|
|
const generatedName = generatedString.charAt(0).toUpperCase() + generatedString.slice(1);
|
|
return {
|
|
name: generatedName
|
|
};
|
|
};
|
|
|
|
const project = (state, action) => {
|
|
if (state === undefined) {
|
|
state = initialState(); // eslint-disable-line
|
|
}
|
|
switch (action.type) {
|
|
case ActionTypes.SET_PROJECT_NAME:
|
|
return Object.assign({}, { ...state }, { name: action.name });
|
|
case ActionTypes.NEW_PROJECT:
|
|
return {
|
|
id: action.project.id,
|
|
name: action.project.name,
|
|
updatedAt: action.project.updatedAt,
|
|
owner: action.owner
|
|
};
|
|
case ActionTypes.SET_PROJECT:
|
|
return {
|
|
id: action.project.id,
|
|
name: action.project.name,
|
|
updatedAt: action.project.updatedAt,
|
|
owner: action.owner
|
|
};
|
|
case ActionTypes.RESET_PROJECT:
|
|
return initialState();
|
|
case ActionTypes.SHOW_EDIT_PROJECT_NAME:
|
|
return Object.assign({}, state, { isEditingName: true });
|
|
case ActionTypes.HIDE_EDIT_PROJECT_NAME:
|
|
return Object.assign({}, state, { isEditingName: false });
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
export default project;
|