Added tech routing paths and basic structure of landing page + sign in + reducers BOD-95
This commit is contained in:
@@ -7,11 +7,12 @@ import messagingReducer from "./messaging/messaging.reducer";
|
||||
import emailReducer from "./email/email.reducer";
|
||||
import modalsReducer from "./modals/modals.reducer";
|
||||
import applicationReducer from "./application/application.reducer";
|
||||
import techReducer from "./tech/tech.reducer";
|
||||
const persistConfig = {
|
||||
key: "root",
|
||||
storage,
|
||||
whitelist: ["messaging"],
|
||||
blacklist: ["user", "email", "modals"],
|
||||
blacklist: ["user", "email", "modals", "tech"],
|
||||
};
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
@@ -20,6 +21,7 @@ const rootReducer = combineReducers({
|
||||
email: emailReducer,
|
||||
modals: modalsReducer,
|
||||
application: applicationReducer,
|
||||
tech: techReducer,
|
||||
});
|
||||
|
||||
export default persistReducer(persistConfig, rootReducer);
|
||||
|
||||
@@ -5,6 +5,8 @@ import { messagingSagas } from "./messaging/messaging.sagas";
|
||||
import { emailSagas } from "./email/email.sagas";
|
||||
import { modalsSagas } from "./modals/modals.sagas";
|
||||
import { applicationSagas } from "./application/application.sagas";
|
||||
import { techSagas } from "./tech/tech.sagas";
|
||||
|
||||
export default function* rootSaga() {
|
||||
yield all([
|
||||
call(userSagas),
|
||||
@@ -12,5 +14,6 @@ export default function* rootSaga() {
|
||||
call(emailSagas),
|
||||
call(modalsSagas),
|
||||
call(applicationSagas),
|
||||
call(techSagas),
|
||||
]);
|
||||
}
|
||||
|
||||
16
client/src/redux/tech/tech.actions.js
Normal file
16
client/src/redux/tech/tech.actions.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import TechActionTypes from "./tech.types";
|
||||
|
||||
export const loginStart = ({ technician, password }) => ({
|
||||
type: TechActionTypes.LOGIN_START,
|
||||
payload: { technician, password },
|
||||
});
|
||||
|
||||
export const loginSuccess = (tech) => ({
|
||||
type: TechActionTypes.LOGIN_SUCCESS,
|
||||
payload: tech,
|
||||
});
|
||||
|
||||
export const loginFailure = (error) => ({
|
||||
type: TechActionTypes.LOGIN_SUCCESS,
|
||||
payload: error,
|
||||
});
|
||||
25
client/src/redux/tech/tech.reducer.js
Normal file
25
client/src/redux/tech/tech.reducer.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import TechActionTypes from "./tech.types";
|
||||
const INITIAL_STATE = {
|
||||
technician: null,
|
||||
loginError: null,
|
||||
};
|
||||
|
||||
const applicationReducer = (state = INITIAL_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case TechActionTypes.LOGIN_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
technician: action.payload,
|
||||
};
|
||||
case TechActionTypes.LOGIN_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
loginError: action.payload,
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default applicationReducer;
|
||||
19
client/src/redux/tech/tech.sagas.js
Normal file
19
client/src/redux/tech/tech.sagas.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { all, takeLatest, call, put } from "redux-saga/effects";
|
||||
import TechActionTypes from "./tech.types";
|
||||
import { client } from "../../App/App.container";
|
||||
import { loginSuccess, loginFailure } from "./tech.actions";
|
||||
|
||||
export function* onSignInStart() {
|
||||
yield takeLatest(TechActionTypes.LOGIN_START, signInStart);
|
||||
}
|
||||
export function* signInStart({ payload: { technician, password } }) {
|
||||
try {
|
||||
yield put(loginSuccess({ username: "TECHNICIAN" }));
|
||||
} catch (error) {
|
||||
yield put(loginFailure(error));
|
||||
}
|
||||
}
|
||||
|
||||
export function* techSagas() {
|
||||
yield all([call(onSignInStart)]);
|
||||
}
|
||||
12
client/src/redux/tech/tech.selectors.js
Normal file
12
client/src/redux/tech/tech.selectors.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createSelector } from "reselect";
|
||||
|
||||
const selectTechReducer = (state) => state.tech;
|
||||
|
||||
export const selectTechnician = createSelector(
|
||||
[selectTechReducer],
|
||||
(application) => application.technician
|
||||
);
|
||||
export const selectLoginError = createSelector(
|
||||
[selectTechReducer],
|
||||
(application) => application.loginError
|
||||
);
|
||||
6
client/src/redux/tech/tech.types.js
Normal file
6
client/src/redux/tech/tech.types.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const TechActionTypes = {
|
||||
LOGIN_START: "LOGIN_START",
|
||||
LOGIN_SUCCESS: "LOGIN_SUCCESS",
|
||||
LOGIN_FAILURE: "LOGIN_FAILURE",
|
||||
};
|
||||
export default TechActionTypes;
|
||||
Reference in New Issue
Block a user