adding reducer and saga for employee
This commit is contained in:
@@ -5,20 +5,30 @@ import { Button, TextInput } from "react-native-paper";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import { signInEmployeeStart } from "../../redux/employee/employee.actions";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import {
|
||||||
|
selectCurrentEmployee, selectSigningIn
|
||||||
|
} from "../../redux/employee/employee.selectors";
|
||||||
//TODO JF add props
|
//TODO JF add props
|
||||||
const mapStateToProps = (state) => ({});
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
currentEmployee: selectCurrentEmployee,
|
||||||
|
signingIn: selectSigningIn,
|
||||||
|
});
|
||||||
|
|
||||||
//TODO JF add prop functions to call dispatch with actions
|
//TODO JF add prop functions to call dispatch with actions
|
||||||
const mapDispatchToProps = {};
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
signInEmployeeStart: (employeeId, pin) =>
|
||||||
|
dispatch(signInEmployeeStart({ employeeId, pin })),
|
||||||
|
});
|
||||||
|
|
||||||
export function TechSignIn({ employeeSignInStart, employeeSigningIn }) {
|
export function TechSignIn({ signInEmployeeStart, employeeSigningIn }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
//TODO add call to dispatch action
|
//TODO add call to dispatch action
|
||||||
const formSubmit = (values) => {
|
const formSubmit = (values) => {
|
||||||
const { employeeId, pin } = values;
|
const { employeeId, pin } = values;
|
||||||
// techSignInStart(employeeId, pin);
|
signInEmployeeStart(employeeId, pin);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -27,3 +27,9 @@ export function loginEmployeeSuccess(technician) {
|
|||||||
payload: technician
|
payload: technician
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export function loginEmployeeFal(error) {
|
||||||
|
return {
|
||||||
|
type: EmployeeActionTypes.AUTHORIZING_EMPLOYEE_FALURE,
|
||||||
|
error: error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { persistReducer } from "redux-persist";
|
|||||||
import appReducer from "./app/app.reducer";
|
import appReducer from "./app/app.reducer";
|
||||||
import photosReducer from "./photos/photos.reducer";
|
import photosReducer from "./photos/photos.reducer";
|
||||||
import userReducer from "./user/user.reducer";
|
import userReducer from "./user/user.reducer";
|
||||||
|
import employeeReducer from './employee/employee.reducer';
|
||||||
|
|
||||||
const persistConfig = {
|
const persistConfig = {
|
||||||
key: "root",
|
key: "root",
|
||||||
@@ -12,10 +13,12 @@ const persistConfig = {
|
|||||||
blacklist: ["user"],
|
blacklist: ["user"],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//ADDED JF employee: employeeReducer
|
||||||
const rootReducer = combineReducers({
|
const rootReducer = combineReducers({
|
||||||
user: userReducer,
|
user: userReducer,
|
||||||
app: appReducer,
|
app: appReducer,
|
||||||
photos: photosReducer,
|
photos: photosReducer,
|
||||||
|
employee: employeeReducer,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default persistReducer(persistConfig, rootReducer);
|
export default persistReducer(persistConfig, rootReducer);
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { all, call } from "redux-saga/effects";
|
|||||||
import { appSagas } from "./app/app.sagas";
|
import { appSagas } from "./app/app.sagas";
|
||||||
import { photosSagas } from "./photos/photos.sagas";
|
import { photosSagas } from "./photos/photos.sagas";
|
||||||
import { userSagas } from "./user/user.sagas";
|
import { userSagas } from "./user/user.sagas";
|
||||||
|
import { employeeSagas } from "./employee/employee.sagas";
|
||||||
|
|
||||||
export default function* rootSaga() {
|
export default function* rootSaga() {
|
||||||
yield all([call(userSagas), call(appSagas), call(photosSagas)]);
|
yield all([call(userSagas), call(appSagas), call(photosSagas), call(employeeSagas)]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user