ESlint: application générale des règles
This commit is contained in:
parent
21fe79684d
commit
e5c5d9c8d2
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Http\DataResponse;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class RequestController
|
||||
{
|
||||
|
||||
/**
|
||||
* @Route("/api/v1/request", name="api_v1_list_requests")
|
||||
*/
|
||||
public function listRequests()
|
||||
{
|
||||
return new DataResponse([
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +1,47 @@
|
||||
export const LOGIN_REQUEST = 'LOGIN_REQUEST'
|
||||
export const LOGIN_REQUEST = 'LOGIN_REQUEST';
|
||||
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS';
|
||||
export const LOGIN_FAILURE = 'LOGIN_FAILURE';
|
||||
|
||||
export function login(username, password) {
|
||||
return { type: LOGIN_REQUEST, username, password }
|
||||
return { type: LOGIN_REQUEST, username, password };
|
||||
}
|
||||
|
||||
export function loginFailure(username, error) {
|
||||
return { type: LOGIN_FAILURE, username, error }
|
||||
return { type: LOGIN_FAILURE, username, error };
|
||||
}
|
||||
|
||||
export function loginSuccess(username) {
|
||||
return { type: LOGIN_SUCCESS, username }
|
||||
return { type: LOGIN_SUCCESS, username };
|
||||
}
|
||||
|
||||
export const LOGOUT_REQUEST = 'LOGOUT_REQUEST'
|
||||
export const LOGOUT_REQUEST = 'LOGOUT_REQUEST';
|
||||
export const LOGOUT_SUCCESS = 'LOGOUT_SUCCESS';
|
||||
export const LOGOUT_FAILURE = 'LOGOUT_FAILURE';
|
||||
|
||||
export function logout() {
|
||||
return { type: LOGOUT_REQUEST }
|
||||
return { type: LOGOUT_REQUEST };
|
||||
}
|
||||
|
||||
export function logoutFailure(error) {
|
||||
return { type: LOGOUT_FAILURE, error }
|
||||
return { type: LOGOUT_FAILURE, error };
|
||||
}
|
||||
|
||||
export function logoutSuccess() {
|
||||
return { type: LOGOUT_SUCCESS }
|
||||
return { type: LOGOUT_SUCCESS };
|
||||
}
|
||||
|
||||
export const REFRESH_USER_SESSION_REQUEST = 'REFRESH_USER_SESSION_REQUEST';
|
||||
export const REFRESH_USER_SESSION_SUCCESS = 'REFRESH_USER_SESSION_SUCCESS';
|
||||
export const REFRESH_USER_SESSION_FAILURE = 'REFRESH_USER_SESSION_FAILURE';
|
||||
|
||||
export function refreshUserSession() {
|
||||
return { type: REFRESH_USER_SESSION_REQUEST };
|
||||
}
|
||||
|
||||
export function refreshUserSessionSuccess(user) {
|
||||
return { type: REFRESH_USER_SESSION_SUCCESS, user };
|
||||
}
|
||||
|
||||
export function refreshUserSessionFailure(error) {
|
||||
return { type: REFRESH_USER_SESSION_FAILURE, error };
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
export const ADD_MESSAGE = 'ADD_MESSAGE'
|
||||
export const ADD_MESSAGE = 'ADD_MESSAGE';
|
||||
|
||||
export function addMessage(type, text) {
|
||||
return { type: ADD_MESSAGE, text, messageType: type };
|
||||
}
|
||||
|
||||
export const REMOVE_OLDEST_MESSAGE = 'REMOVE_OLDEST_MESSAGE'
|
||||
export const REMOVE_OLDEST_MESSAGE = 'REMOVE_OLDEST_MESSAGE';
|
||||
|
||||
export function removeOldestMessage() {
|
||||
return { type: REMOVE_OLDEST_MESSAGE }
|
||||
return { type: REMOVE_OLDEST_MESSAGE };
|
||||
}
|
@ -3,13 +3,13 @@ export const PROJECT_USER_LIST_SUCCESS = 'PROJECT_USER_LIST_SUCCESS';
|
||||
export const PROJECT_USER_LIST_FAILURE = 'PROJECT_USER_LIST_FAILURE';
|
||||
|
||||
export function projectUserListRequest() {
|
||||
return { type: PROJECT_USER_LIST}
|
||||
return { type: PROJECT_USER_LIST};
|
||||
}
|
||||
export function projectUserListSuccess(projects) {
|
||||
return { type: PROJECT_USER_LIST_SUCCESS, projects }
|
||||
return { type: PROJECT_USER_LIST_SUCCESS, projects };
|
||||
}
|
||||
export function projectUserListFailure(error) {
|
||||
return { type: PROJECT_USER_LIST_FAILURE, error }
|
||||
return { type: PROJECT_USER_LIST_FAILURE, error };
|
||||
}
|
||||
|
||||
export const PROJECT_LIST = 'PROJECT_LIST';
|
||||
@ -17,11 +17,11 @@ export const PROJECT_LIST_SUCCESS = 'PROJECT_LIST_SUCCESS';
|
||||
export const PROJECT_LIST_FAILURE = 'PROJECT_LIST_FAILURE';
|
||||
|
||||
export function projectList() {
|
||||
return { type: PROJECT_LIST}
|
||||
return { type: PROJECT_LIST};
|
||||
}
|
||||
export function projectListSuccess(projects) {
|
||||
return { type: PROJECT_LIST_SUCCESS, projects }
|
||||
return { type: PROJECT_LIST_SUCCESS, projects };
|
||||
}
|
||||
export function projectListFailure(error) {
|
||||
return { type: PROJECT_LIST_FAILURE, error }
|
||||
return { type: PROJECT_LIST_FAILURE, error };
|
||||
}
|
@ -3,13 +3,13 @@ export const CREATE_USER_SUCCESS = 'CREATE_USER_SUCCESS';
|
||||
export const CREATE_USER_FAILURE = 'CREATE_USER_FAILURE';
|
||||
|
||||
export function createUser(username, password) {
|
||||
return { type: CREATE_USER_REQUEST, username, password}
|
||||
return { type: CREATE_USER_REQUEST, username, password};
|
||||
}
|
||||
|
||||
export function createUserSuccess(user) {
|
||||
return { type: CREATE_USER_SUCCESS, user }
|
||||
return { type: CREATE_USER_SUCCESS, user };
|
||||
}
|
||||
|
||||
export function createUserFailure(error) {
|
||||
return { type: CREATE_USER_FAILURE, error }
|
||||
return { type: CREATE_USER_FAILURE, error };
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
import { Component, Fragment } from 'react'
|
||||
import { hot } from 'react-hot-loader'
|
||||
import { HashRouter } from 'react-router-dom' // ou BrowserRouter
|
||||
import { Route, Switch, Redirect } from 'react-router'
|
||||
import HomePage from './pages/home';
|
||||
import { Component, Fragment } from 'react';
|
||||
import { hot } from 'react-hot-loader';
|
||||
import { HashRouter } from 'react-router-dom'; // ou BrowserRouter
|
||||
import { Route, Switch, Redirect } from 'react-router';
|
||||
import { ConnectedHomePage as HomePage } from './pages/home';
|
||||
import { ConnectedLoginPage as LoginPage } from './pages/login';
|
||||
import DashBoardClient from './pages/DashBoardClient';
|
||||
import DashBoardDev from './pages/DashBoardDev';
|
||||
@ -25,10 +25,9 @@ export class App extends Component {
|
||||
</Switch>
|
||||
</HashRouter>
|
||||
</Fragment>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const ConnectedApp = connect()(App);
|
||||
export const HotApp = hot(module)(ConnectedApp);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import ProjectTile from './ProjectTile'
|
||||
import React from 'react';
|
||||
import ProjectTile from './ProjectTile';
|
||||
|
||||
export default ({ projects, withRequest }) => (
|
||||
<div className="tile is-parent is-vertical">
|
||||
@ -9,4 +9,4 @@ export default ({ projects, withRequest }) => (
|
||||
))
|
||||
}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import RequestList from './RequestList'
|
||||
import React from 'react';
|
||||
import RequestList from './RequestList';
|
||||
|
||||
export default ({ project, withRequest }) => (
|
||||
<article className="tile is-child notification is-primary">
|
||||
@ -8,4 +8,4 @@ export default ({ project, withRequest }) => (
|
||||
withRequest && <RequestList requests={project.requests || []} />
|
||||
}
|
||||
</article>
|
||||
)
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import RequestTile from './RequestTile'
|
||||
import React from 'react';
|
||||
import RequestTile from './RequestTile';
|
||||
|
||||
export default ({ requests }) => (
|
||||
<div className="tile is-parent is-vertical">
|
||||
@ -9,4 +9,4 @@ export default ({ requests }) => (
|
||||
))
|
||||
}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import styles from './RequestTile.css'
|
||||
import { Link } from 'react-router-dom'
|
||||
import React from 'react';
|
||||
import styles from './RequestTile.css';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
export default ({ request }) => (
|
||||
<Link to={`dashboard-client/detail-demande/${request.id}`}>
|
||||
@ -11,4 +11,4 @@ export default ({ request }) => (
|
||||
</div>
|
||||
</article>
|
||||
</Link>
|
||||
)
|
||||
);
|
||||
|
@ -55,20 +55,20 @@ export function UserForm({ form, onSubmit }) {
|
||||
<button type="submit" disabled={!form.valid} className="button">Envoyer</button>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
const validators = {
|
||||
username: (value, formData) => {
|
||||
if (!value) return { hasError: true, message: 'Le nom d\'utilisateur ne peut être vide !' }
|
||||
if (!value) return { hasError: true, message: 'Le nom d\'utilisateur ne peut être vide !' };
|
||||
return { hasError: false, message: '' };
|
||||
},
|
||||
password: (value, formData) => {
|
||||
if (!value) return { hasError: true, message: 'Le mot de passe ne peut pas être vide !' }
|
||||
if (value !== formData.passwordVerification) return { hasError: true, message: 'Vos deux mots de passe sont différents !' }
|
||||
if (!value) return { hasError: true, message: 'Le mot de passe ne peut pas être vide !' };
|
||||
if (value !== formData.passwordVerification) return { hasError: true, message: 'Vos deux mots de passe sont différents !' };
|
||||
return { hasError: false, message: '' };
|
||||
},
|
||||
passwordVerification: (value, formData) => {
|
||||
if (value !== formData.password) return { hasError: true, message: 'Vos deux mots de passe sont différents !' }
|
||||
if (value !== formData.password) return { hasError: true, message: 'Vos deux mots de passe sont différents !' };
|
||||
return { hasError: false, message: '' };
|
||||
}
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ describe('<UserForm />', () => {
|
||||
password: 'test',
|
||||
passwordVerification: 'test'
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('username validation', () => {
|
||||
|
@ -16,15 +16,15 @@ export function WithForm(validators) {
|
||||
setFormErrors(formErrors => {
|
||||
return { ...formErrors, [name]: { hasError: false, message: '' } };
|
||||
});
|
||||
return
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
const value = formData[name];
|
||||
const result = validators[name](value, formData);
|
||||
setFormErrors(formErrors => {
|
||||
return { ...formErrors, [name]: result };
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
Object.keys(formData).forEach(validateField);
|
||||
@ -78,7 +78,7 @@ export function WithForm(validators) {
|
||||
|
||||
return <Component form={form} {...props} />;
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// connect(mapStateToProps)(MyComponent)
|
@ -2,7 +2,7 @@ export function MessageList({ messages }) {
|
||||
if (!Array.isArray(messages)) return null;
|
||||
|
||||
return (
|
||||
<div className="columns" style={{marginTop:"1em"}}>
|
||||
<div className="columns" style={{marginTop:'1em'}}>
|
||||
<div className="column is-4 is-offset-4">
|
||||
<div className="messages">
|
||||
{
|
||||
@ -13,7 +13,7 @@ export function MessageList({ messages }) {
|
||||
{m.text}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
export class UnauthorizedError extends Error {
|
||||
constructor() {
|
||||
super("Unauthorized");
|
||||
super('Unauthorized');
|
||||
Error.captureStackTrace(this, UnauthorizedError);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import ReactDOM from 'react-dom'
|
||||
import { HotApp as App } from './app'
|
||||
import { configureStore } from './store/store'
|
||||
import { Provider } from 'react-redux'
|
||||
import ReactDOM from 'react-dom';
|
||||
import { HotApp as App } from './app';
|
||||
import { configureStore } from './store/store';
|
||||
import { Provider } from 'react-redux';
|
||||
import 'bulma/css/bulma.min.css';
|
||||
|
||||
const store = configureStore()
|
||||
const store = configureStore();
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>,
|
||||
document.getElementById('app')
|
||||
)
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import React, { useEffect } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import Page from './page';
|
||||
import ProjectList from '../components/ProjectList';
|
||||
import { projectUserListRequest } from '../actions/project';
|
||||
@ -7,8 +7,8 @@ import { projectUserListRequest } from '../actions/project';
|
||||
const DashBoardClient = ({ projects = [], ...props }) => {
|
||||
|
||||
useEffect(() => {
|
||||
props.dispatch(projectUserListRequest())
|
||||
}, [])
|
||||
props.dispatch(projectUserListRequest());
|
||||
}, []);
|
||||
projects = [
|
||||
{
|
||||
id: 1,
|
||||
@ -78,7 +78,7 @@ const DashBoardClient = ({ projects = [], ...props }) => {
|
||||
|
||||
]
|
||||
},
|
||||
]
|
||||
];
|
||||
return (
|
||||
<Page title="dashBoard client">
|
||||
<div className="notification">
|
||||
@ -87,11 +87,11 @@ const DashBoardClient = ({ projects = [], ...props }) => {
|
||||
<ProjectList projects={projects} withRequest />
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const mapStateToProps = ({ project }) => ({
|
||||
projects: project.items,
|
||||
})
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(DashBoardClient)
|
||||
export default connect(mapStateToProps)(DashBoardClient);
|
@ -1,5 +1,5 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import React, { useEffect } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import Page from './page';
|
||||
import ProjectList from '../components/ProjectList';
|
||||
import { projectList } from '../actions/project';
|
||||
@ -7,8 +7,8 @@ import { projectList } from '../actions/project';
|
||||
const DashBoardDev = ({ projects = [], ...props }) => {
|
||||
|
||||
useEffect(() => {
|
||||
props.dispatch(projectList())
|
||||
}, [])
|
||||
props.dispatch(projectList());
|
||||
}, []);
|
||||
projects = [
|
||||
{
|
||||
id: 1,
|
||||
@ -78,7 +78,7 @@ const DashBoardDev = ({ projects = [], ...props }) => {
|
||||
|
||||
]
|
||||
},
|
||||
]
|
||||
];
|
||||
return (
|
||||
<Page title="dashBoard dev">
|
||||
<div className="notification">
|
||||
@ -87,11 +87,11 @@ const DashBoardDev = ({ projects = [], ...props }) => {
|
||||
<ProjectList projects={projects} />
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const mapStateToProps = ({ project }) => ({
|
||||
projects: project.items,
|
||||
})
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(DashBoardDev)
|
||||
export default connect(mapStateToProps)(DashBoardDev);
|
@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import React from 'react';
|
||||
import Page from './page';
|
||||
import { ExtendedUserForm as UserForm } from '../components/UserForm';
|
||||
import { connect } from 'react-redux';
|
||||
@ -33,9 +33,9 @@ function transformErrorCode(code) {
|
||||
return {
|
||||
username: {
|
||||
hasError: true,
|
||||
message: "Le nom d'utilisateur ne peut pas être vide. (API)"
|
||||
}
|
||||
message: 'Le nom d\'utilisateur ne peut pas être vide. (API)'
|
||||
}
|
||||
};
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -44,7 +44,7 @@ function transformErrorCode(code) {
|
||||
function mapStateToProps({ users }) {
|
||||
return {
|
||||
createUserFormError: transformErrorCode(users.createUserForm.errorCode),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const ConnectedHomePage = connect(mapStateToProps)(HomePage)
|
||||
export const ConnectedHomePage = connect(mapStateToProps)(HomePage);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { ConnectedPage as Page } from './page';
|
||||
import { login } from '../actions/auth.actions';
|
||||
import { connect } from 'react-redux';
|
||||
@ -13,7 +13,7 @@ export function LoginPage({ dispatch, isLoggedIn, history }) {
|
||||
evt.preventDefault();
|
||||
const { username, password } = formData;
|
||||
dispatch(login(username, password));
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoggedIn) history.push('/home');
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import React, { useEffect } from 'react';
|
||||
import { logout } from '../actions/auth.actions';
|
||||
import { connect } from 'react-redux';
|
||||
import { ConnectedPage as Page } from './page';
|
||||
@ -16,7 +16,7 @@ export function LogoutPage({ dispatch }) {
|
||||
</div>
|
||||
</div>
|
||||
</Page>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export const ConnectedLogoutPage = connect()(LogoutPage);
|
@ -1,4 +1,4 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import React, { useEffect } from 'react';
|
||||
import { MessageList } from '../components/message-list';
|
||||
import { connect } from 'react-redux';
|
||||
import { removeOldestMessage } from '../actions/message.actions';
|
||||
@ -16,7 +16,7 @@ export default function Page({ title, messages, dispatch, children }) {
|
||||
}, 5000);
|
||||
|
||||
return () => clearTimeout(timeoutId);
|
||||
}, [messages])
|
||||
}, [messages]);
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ADD_MESSAGE, REMOVE_OLDEST_MESSAGE } from "../actions/message.actions";
|
||||
import { ADD_MESSAGE, REMOVE_OLDEST_MESSAGE } from '../actions/message.actions';
|
||||
|
||||
const initialState = {
|
||||
sortedByTimestamp: []
|
||||
@ -10,7 +10,7 @@ export function messagesReducer(state = initialState, action) {
|
||||
return handleAddMessage(state, action);
|
||||
case REMOVE_OLDEST_MESSAGE:
|
||||
return handleRemoveOldestMessage(state, action);
|
||||
};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -21,12 +21,12 @@ function handleAddMessage(state, action) {
|
||||
{ ts: Date.now(), text: action.text, type: action.messageType },
|
||||
...state.sortedByTimestamp
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function handleRemoveOldestMessage(state, action) {
|
||||
return {
|
||||
...state,
|
||||
sortedByTimestamp: state.sortedByTimestamp.slice(0, -1)
|
||||
}
|
||||
};
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
import {
|
||||
PROJECT_USER_LIST_SUCCESS,
|
||||
PROJECT_USER_LIST_FAILURE
|
||||
} from '../actions/project'
|
||||
} from '../actions/project';
|
||||
|
||||
const initialState = {
|
||||
items: []
|
||||
}
|
||||
};
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
|
||||
console.log(`Action: ${JSON.stringify(action)}`)
|
||||
console.log(`Action: ${JSON.stringify(action)}`);
|
||||
|
||||
switch (action.type) {
|
||||
|
||||
@ -17,15 +17,15 @@ export default (state = initialState, action) => {
|
||||
return {
|
||||
...state,
|
||||
items: action.projects
|
||||
}
|
||||
};
|
||||
case PROJECT_USER_LIST_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
items: [],
|
||||
error: action.error
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
return state
|
||||
return state;
|
||||
|
||||
}
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
import { LOGIN_SUCCESS, LOGOUT_SUCCESS } from "../actions/auth.actions";
|
||||
import { LOGIN_SUCCESS, LOGOUT_SUCCESS } from '../actions/auth.actions';
|
||||
|
||||
const initialState = {
|
||||
isLoggedIn: false,
|
||||
@ -11,7 +11,7 @@ export function sessionReducer(state = initialState, action) {
|
||||
return handleLoginSuccess(state, action);
|
||||
case LOGOUT_SUCCESS:
|
||||
return handleLogoutSuccess(state, action);
|
||||
};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -22,13 +22,13 @@ function handleLoginSuccess(state, action) {
|
||||
user: {
|
||||
username: action.username,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function handleLogoutSuccess(state, action) {
|
||||
return {
|
||||
...state,
|
||||
isLoggedIn: false,
|
||||
user: null,
|
||||
}
|
||||
};
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { CREATE_USER_FAILURE } from "../actions/user.actions";
|
||||
import { CREATE_USER_FAILURE } from '../actions/user.actions';
|
||||
|
||||
const initialState = {
|
||||
byId: {},
|
||||
@ -9,7 +9,7 @@ export function usersReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case CREATE_USER_FAILURE:
|
||||
return handleCreateUserFailure(state, action);
|
||||
};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
@ -11,20 +11,20 @@ export function* loginSaga(action) {
|
||||
result = yield call(client.login, action.username, action.password);
|
||||
} catch(err) {
|
||||
if (err instanceof UnauthorizedError) {
|
||||
yield put(addMessage('warning', "Identifiants invalides."));
|
||||
yield put(addMessage('warning', 'Identifiants invalides.'));
|
||||
return;
|
||||
}
|
||||
|
||||
yield put(loginFailure(action.username, err));
|
||||
yield put(addMessage('danger', "Une erreur inconnue bloque le fonctionnement normal de l'application. Veuillez réessayer plus tard."));
|
||||
return
|
||||
yield put(addMessage('danger', 'Une erreur inconnue bloque le fonctionnement normal de l\'application. Veuillez réessayer plus tard.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ('error' in result) {
|
||||
yield put(loginFailure(action.username, result.error));
|
||||
const message = result.error.message ? result.error.message : result.error.toString();
|
||||
yield put(addMessage('danger', message));
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
yield put(loginSuccess(action.username));
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { history } from "../../util/history";
|
||||
import { history } from '../../util/history';
|
||||
import { addMessage } from '../../actions/message.actions';
|
||||
import { put } from 'redux-saga/effects';
|
||||
|
||||
export function* logoutRedirectSaga() {
|
||||
yield put(addMessage("success", "Vous êtes déconnecté."));
|
||||
yield put(addMessage('success', 'Vous êtes déconnecté.'));
|
||||
history.push('/login');
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { APIClient } from "../../services/api-client.service";
|
||||
import { logoutFailure, logoutSuccess } from "../../actions/auth.actions";
|
||||
import { addMessage } from "../../actions/message.actions";
|
||||
import { APIClient } from '../../services/api-client.service';
|
||||
import { logoutFailure, logoutSuccess } from '../../actions/auth.actions';
|
||||
import { addMessage } from '../../actions/message.actions';
|
||||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
export function* logoutSaga() {
|
||||
@ -10,7 +10,7 @@ export function* logoutSaga() {
|
||||
result = yield call(client.logout);
|
||||
} catch(err) {
|
||||
yield put(logoutFailure(err));
|
||||
yield put(addMessage('danger', "Une erreur inconnue bloque le fonctionnement normal de l'application. Veuillez réessayer plus tard."));
|
||||
yield put(addMessage('danger', 'Une erreur inconnue bloque le fonctionnement normal de l\'application. Veuillez réessayer plus tard.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ export function* logoutSaga() {
|
||||
yield put(logoutFailure(result.error));
|
||||
const message = result.error.message ? result.error.message : result.error.toString();
|
||||
yield put(addMessage('danger', message));
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
yield put(logoutSuccess());
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { LOGIN_REQUEST, LOGOUT_REQUEST, LOGOUT_SUCCESS } from "../../actions/auth.actions";
|
||||
import { loginSaga } from "./login.saga";
|
||||
import { logoutSaga } from "./logout.saga";
|
||||
import { logoutRedirectSaga } from "./logout-redirect.saga";
|
||||
import { LOGIN_REQUEST, LOGOUT_REQUEST, LOGOUT_SUCCESS } from '../../actions/auth.actions';
|
||||
import { loginSaga } from './login.saga';
|
||||
import { logoutSaga } from './logout.saga';
|
||||
import { logoutRedirectSaga } from './logout-redirect.saga';
|
||||
import { all, takeLatest } from 'redux-saga/effects';
|
||||
|
||||
export function * rootSaga() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { failureActionSaga } from "./failure.saga";
|
||||
import { takeLatest, all } from "redux-saga/effects";
|
||||
import { failureActionSaga } from './failure.saga';
|
||||
import { takeLatest, all } from 'redux-saga/effects';
|
||||
|
||||
export function * rootSaga(action) {
|
||||
yield all([
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { all } from 'redux-saga/effects';
|
||||
import { checkSessionSaga } from './session.saga';
|
||||
import { refreshSessionSaga } from './session.saga';
|
||||
|
||||
export function* rootSaga() {
|
||||
yield all([
|
||||
checkSessionSaga(),
|
||||
refreshSessionSaga(),
|
||||
]);
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
import { APIClient } from '../../services/api-client.service';
|
||||
import { call } from 'redux-saga/effects';
|
||||
import { call, put } from 'redux-saga/effects';
|
||||
import { refreshUserSessionFailure, refreshUserSessionSuccess } from '../../actions/auth.actions';
|
||||
|
||||
export function* checkSessionSaga() {
|
||||
export function* refreshSessionSaga() {
|
||||
const client = new APIClient();
|
||||
let user;
|
||||
try {
|
||||
yield call(client.retrieveSessionUser);
|
||||
user = yield call(client.retrieveSessionUser);
|
||||
} catch(err) {
|
||||
console.error(err);
|
||||
yield put(refreshUserSessionFailure(err));
|
||||
}
|
||||
yield put(refreshUserSessionSuccess(user));
|
||||
}
|
||||
|
@ -2,17 +2,17 @@ import { call, put } from 'redux-saga/effects';
|
||||
import { projectUserListFailure, projectUserListSuccess, projectListFailure, projectListSuccess } from '../actions/project';
|
||||
|
||||
export function* projectUserListSaga() {
|
||||
let result
|
||||
let result;
|
||||
try {
|
||||
result = yield call(projectUserList);
|
||||
} catch(err) {
|
||||
yield put(projectUserListFailure(err));
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if ('error' in result) {
|
||||
yield put(projectUserListFailure(result.error));
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
yield put(projectUserListSuccess(result.data));
|
||||
@ -23,22 +23,22 @@ const projectUserList = () => {
|
||||
method: 'GET',
|
||||
mode: 'cors',
|
||||
credentials: 'include'
|
||||
}).then(res => res.json())
|
||||
}
|
||||
}).then(res => res.json());
|
||||
};
|
||||
|
||||
|
||||
export function* projectListSaga() {
|
||||
let result
|
||||
let result;
|
||||
try {
|
||||
result = yield call(projectList);
|
||||
} catch(err) {
|
||||
yield put(projectListFailure(err));
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if ('error' in result) {
|
||||
yield put(projectListFailure(result.error));
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
yield put(projectListSuccess(result.data));
|
||||
@ -49,5 +49,5 @@ const projectList = () => {
|
||||
method: 'GET',
|
||||
mode: 'cors',
|
||||
credentials: 'include'
|
||||
}).then(res => res.json())
|
||||
}
|
||||
}).then(res => res.json());
|
||||
};
|
@ -10,7 +10,7 @@ export function* createUserSaga({username, password}) {
|
||||
} catch(err) {
|
||||
console.error(err);
|
||||
yield put(createUserFailure(err));
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
yield put(createUserSuccess(user));
|
||||
|
@ -20,7 +20,7 @@ export class APIClient {
|
||||
}
|
||||
|
||||
logout() {
|
||||
return this._callAPI('/logout')
|
||||
return this._callAPI('/logout');
|
||||
}
|
||||
|
||||
retrieveSessionUser() {
|
||||
@ -29,7 +29,7 @@ export class APIClient {
|
||||
}
|
||||
|
||||
listUsers() {
|
||||
return this._callAPI('/users')
|
||||
return this._callAPI('/users');
|
||||
}
|
||||
|
||||
listRequests() {
|
||||
@ -61,7 +61,7 @@ export class APIClient {
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(this._withUnauthorizedErrorMiddleware())
|
||||
.then(res => res.json())
|
||||
.then(res => res.json());
|
||||
}
|
||||
|
||||
_withUnauthorizedErrorMiddleware() {
|
||||
@ -70,7 +70,7 @@ export class APIClient {
|
||||
throw new UnauthorizedError();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_withAPIErrorMiddleware(endpoint) {
|
||||
@ -80,7 +80,7 @@ export class APIClient {
|
||||
throw new APIError(endpoint, code, message, data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { createStore, applyMiddleware, combineReducers, compose } from 'redux'
|
||||
import createSagaMiddleware from 'redux-saga'
|
||||
import rootSaga from '../sagas/root'
|
||||
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
import rootSaga from '../sagas/root';
|
||||
import { sessionReducer } from '../reducers/session.reducers';
|
||||
import { messagesReducer } from '../reducers/messages.reducers';
|
||||
import project from '../reducers/project'
|
||||
import project from '../reducers/project';
|
||||
import { usersReducer } from '../reducers/users.reducers';
|
||||
|
||||
const sagaMiddleware = createSagaMiddleware()
|
||||
const sagaMiddleware = createSagaMiddleware();
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
session: sessionReducer,
|
||||
@ -24,7 +24,7 @@ export function configureStore(initialState = {}) {
|
||||
composeEnhancers(
|
||||
applyMiddleware(sagaMiddleware)
|
||||
)
|
||||
)
|
||||
);
|
||||
sagaMiddleware.run(rootSaga);
|
||||
return store;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user