-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intégrer redux, react-redux, redux-saga pour l'authentification. (1/2) (
#27) (#28) * modify prettierrc, ... * refactor files' tree, ... * append user reducer, saga, ... * append gradle configs, ... * refactor configurations, ... * append scenes, rework modules, ... * append routes, ... * setup datas, ... * append render methods to modal, ... * remove extras props from render, ... * append sign-up, sign-in datas, ... * append extra props, move modal as dependencies, ... * remove configs from build, ... * fix button bind multiscenes * Scenes is rendered only when needed * changed default rightTo value * fixed path -> pathname * append users reducers, actions creators, ... * remove useless respond argument, ... * fixed error * Update popup-window.js * remove demo modifs, useless responds, ... * remove useless comments, ...
- Loading branch information
Quentin Woivre
committed
Nov 23, 2018
1 parent
87954f7
commit e9431bd
Showing
28 changed files
with
249 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { combineReducers } from "redux"; | ||
import { currentUserReducer as currentUser } from "../../datas/current-user"; | ||
import { usersReducer as users } from "../../datas/users"; | ||
|
||
const rootReducer = combineReducers({ /* ... */ }); | ||
const rootReducer = combineReducers({ currentUser, users }); | ||
|
||
export default rootReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import { all } from "redux-saga/effects"; | ||
import { signInSaga } from "../../datas/sign-in"; | ||
import { signUpSaga } from "../../datas/sign-up"; | ||
import { usersSaga } from "../../datas/users"; | ||
|
||
function* rootSaga() { yield all([ /* ... */ ]); } | ||
function* rootSaga() { yield all([signInSaga, signUpSaga, usersSaga]); } | ||
|
||
export default rootSaga; |
File renamed without changes.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import _ from "lodash"; | ||
import signInActionsTypes from "../sign-in/sign-in-actions-types"; | ||
|
||
const initialState = { id: "", token: "", refreshToken: "" }; | ||
|
||
const currentUserReducer = (state = initialState, action) => { | ||
switch (action.type) { | ||
case signInActionsTypes.SIGN_IN_SUCCESS: | ||
return _.assign({}, state, action.payload); | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default currentUserReducer; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import currentUserReducer from "./current-user-reducer"; | ||
|
||
// eslint-disable-next-line | ||
export { currentUserReducer }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import signInActionsTypes from "./sign-in-actions-types"; | ||
import signInActions from "./sign-in-actions"; | ||
import signInApi from "./sign-in-api"; | ||
import signInSaga from "./sign-in-saga"; | ||
|
||
export { signInActionsTypes, signInActions, signInApi, signInSaga }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const signInActionsTypes = { | ||
SIGN_IN_REQUEST: "SIGN_IN_REQUEST", | ||
SIGN_IN_SUCCESS: "SIGN_IN_SUCCESS", | ||
SIGN_IN_FAILURE: "SIGN_IN_FAILURE", | ||
SIGN_OUT_REQUEST: "SIGN_OUT_REQUEST", | ||
SIGN_OUT_SUCCESS: "SIGN_OUT_SUCCESS", | ||
SIGN_OUT_FAILURE: "SIGN_OUT_FAILURE" | ||
}; | ||
|
||
export default signInActionsTypes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import signInActionsTypes from "./sign-in-actions-types"; | ||
|
||
const signInActions = { | ||
signInRequest: payload => ({ | ||
type: signInActionsTypes.SIGN_IN_REQUEST, | ||
payload | ||
}), | ||
signInSuccess: payload => ({ | ||
type: signInActionsTypes.SIGN_IN_SUCCESS, | ||
payload | ||
}), | ||
signInFailure: error => ({ | ||
type: signInActionsTypes.SIGN_IN_FAILURE, | ||
payload: error, | ||
error: true | ||
}), | ||
signOutRequest: payload => ({ | ||
type: signInActionsTypes.SIGN_OUT_REQUEST, | ||
payload | ||
}), | ||
signOutSuccess: () => ({ | ||
type: signInActionsTypes.SIGN_OUT_SUCCESS, | ||
payload: undefined | ||
}), | ||
signOutFailure: error => ({ | ||
type: signInActionsTypes.SIGN_OUT_FAILURE, | ||
payload: error, | ||
error: true | ||
}) | ||
}; | ||
|
||
export default signInActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const signInApi = { signIn: () => ({}), signOut: () => ({}) }; | ||
|
||
export default signInApi; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { all, takeLatest, call, put } from "redux-saga/effects"; | ||
import usersActions from "../users/users-actions"; | ||
import signInActionsTypes from "./sign-in-actions-types"; | ||
import signInActions from "./sign-in-actions"; | ||
import signInApi from "./sign-in-api"; | ||
|
||
function* signInRequestSaga({ payload }) { | ||
try { | ||
const { id, ...others } = yield call(signInApi.signIn, payload); | ||
yield put(usersActions.getUserRequest({ id })); | ||
yield put(signInActions.signInSuccess({ id, ...others })); | ||
} catch (error) { | ||
yield put(signInActions.signInFailure(error)); | ||
} | ||
} | ||
|
||
function* signOutRequestSaga({ payload }) { | ||
try { | ||
yield call(signInApi.signOut, payload); | ||
yield put(signInActions.signOutSuccess()); | ||
} catch (error) { | ||
yield put(signInActions.signOutFailure(error)); | ||
} | ||
} | ||
|
||
const signInSaga = all([ | ||
takeLatest(signInActionsTypes.SIGN_IN_REQUEST, signInRequestSaga), | ||
takeLatest(signInActionsTypes.SIGN_OUT_REQUEST, signOutRequestSaga) | ||
]); | ||
|
||
export default signInSaga; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import signUpActionsTypes from "./sign-up-actions-types"; | ||
import signUpActions from "./sign-up-actions"; | ||
import signUpApi from "./sign-up-api"; | ||
import signUpSaga from "./sign-up-saga"; | ||
|
||
export { signUpActionsTypes, signUpActions, signUpApi, signUpSaga }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const signUpActionsTypes = { | ||
SIGN_UP_REQUEST: "SIGN_UP_REQUEST", | ||
SIGN_UP_SUCCESS: "SIGN_UP_SUCCESS", | ||
SIGN_UP_FAILURE: "SIGN_UP_FAILURE" | ||
}; | ||
|
||
export default signUpActionsTypes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import signUpActionsTypes from "./sign-up-actions-types"; | ||
|
||
const signUpActions = { | ||
signUpRequest: payload => ({ | ||
type: signUpActionsTypes.SIGN_UP_REQUEST, | ||
payload | ||
}), | ||
signUpSuccess: () => ({ | ||
type: signUpActionsTypes.SIGN_UP_SUCCESS, | ||
payload: undefined | ||
}), | ||
signUpFailure: error => ({ | ||
type: signUpActionsTypes.SIGN_UP_FAILURE, | ||
payload: error, | ||
error: true | ||
}) | ||
}; | ||
|
||
export default signUpActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const signUpApi = { signUp: () => ({}) }; | ||
|
||
export default signUpApi; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { all, takeLatest, call, put } from "redux-saga/effects"; | ||
import signInActions from "../sign-in/sign-in-actions"; | ||
import signUpActionsTypes from "./sign-up-actions-types"; | ||
import signUpActions from "./sign-up-actions"; | ||
import signUpApi from "./sign-up-api"; | ||
|
||
function* signUpRequestSaga({ payload }) { | ||
try { | ||
yield call(signUpApi.signUp, payload); | ||
yield put(signInActions.signInRequest(payload)); | ||
yield put(signUpActions.signUpSuccess()); | ||
} catch (error) { | ||
yield put(signUpActions.signUpFailure(error)); | ||
} | ||
} | ||
|
||
const signUpSaga = all([ | ||
takeLatest(signUpActionsTypes.SIGN_UP_REQUEST, signUpRequestSaga) | ||
]); | ||
|
||
export default signUpSaga; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import usersActionsTypes from "./users-actions-types"; | ||
import usersActions from "./users-actions"; | ||
import usersApi from "./users-api"; | ||
import usersReducer from "./users-reducer"; | ||
import usersSaga from "./users-saga"; | ||
|
||
export { usersActionsTypes, usersActions, usersApi, usersReducer, usersSaga }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const usersActionsTypes = { | ||
GET_USER_REQUEST: "GET_USER_REQUEST", | ||
GET_USER_SUCCESS: "GET_USER_SUCCESS", | ||
GET_USER_FAILURE: "GET_USER_FAILURE" | ||
}; | ||
|
||
export default usersActionsTypes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import usersActionsTypes from "./users-actions-types"; | ||
|
||
const usersActions = { | ||
getUserRequest: payload => ({ | ||
type: usersActionsTypes.GET_USER_REQUEST, | ||
payload | ||
}), | ||
getUserSuccess: payload => ({ | ||
type: usersActionsTypes.GET_USER_SUCCESS, | ||
payload | ||
}), | ||
getUserFailure: error => ({ | ||
type: usersActionsTypes.GET_USER_FAILURE, | ||
payload: error, | ||
error: true | ||
}) | ||
}; | ||
|
||
export default usersActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const usersApi = { getUser: () => ({}) }; | ||
|
||
export default usersApi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import _ from "lodash"; | ||
import usersActionsTypes from "./users-actions-types"; | ||
|
||
const initialState = { byId: {}, allIds: [] }; | ||
|
||
const usersReducer = (state = initialState, action) => { | ||
switch (action.type) { | ||
case usersActionsTypes.GET_USER_SUCCESS: | ||
return _.assign({}, state, { | ||
byId: _.assign({}, state.byId, { [action.payload.id]: action.payload }), | ||
allIds: _.concat([], state.allIds, [action.payload.id]) | ||
}); | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default usersReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { all, takeLatest, call, put } from "redux-saga/effects"; | ||
import usersActionsTypes from "./users-actions-types"; | ||
import usersActions from "./users-actions"; | ||
import usersApi from "./users-api"; | ||
|
||
function* getUsersRequestSaga({ payload }) { | ||
try { | ||
const respond = yield call(usersApi.getUser, payload); | ||
yield put(usersActions.getUserSuccess(respond)); | ||
} catch (error) { | ||
yield put(usersActions.getUserFailure(error)); | ||
} | ||
} | ||
|
||
const usersSaga = all([ | ||
takeLatest(usersActionsTypes.GET_USER_REQUEST, getUsersRequestSaga) | ||
]); | ||
|
||
export default usersSaga; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters