Added employee name to the employee field
This commit is contained in:
@@ -3,11 +3,16 @@ import {
|
||||
employeeSignInStart,
|
||||
employeeSignInSuccess,
|
||||
employeeSignInFailure,
|
||||
employeeGetRatesStart,
|
||||
employeeGetRatesSuccess,
|
||||
employeeGetRatesFailure
|
||||
|
||||
} from "./employee.actions";
|
||||
import { all, call, put, select, takeLatest } from "redux-saga/effects";
|
||||
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||
import { selectBodyshop } from "../user/user.selectors";
|
||||
import axios from "axios";
|
||||
import { client } from "../../graphql/client";
|
||||
|
||||
export function* onSignInEmployeeStart() {
|
||||
yield takeLatest(
|
||||
@@ -17,9 +22,9 @@ export function* onSignInEmployeeStart() {
|
||||
}
|
||||
export function* signInWithEmployeeId({ payload: { employeeId, pin } }) {
|
||||
try {
|
||||
logImEXEvent("redux_sign_in_employee_attempt");
|
||||
logImEXEvent("redux_sign_in_employee_attempt");
|
||||
//console.loging
|
||||
console.log("Saga", employeeId, pin, pin);
|
||||
// console.log("Saga", employeeId, pin, pin);
|
||||
const bodyshop = yield select(selectBodyshop);
|
||||
const response = yield call(axios.post, "/tech/login", {
|
||||
shopid: bodyshop.id,
|
||||
@@ -38,6 +43,34 @@ export function* signInWithEmployeeId({ payload: { employeeId, pin } }) {
|
||||
}
|
||||
}
|
||||
|
||||
export function* employeeSagas() {
|
||||
yield all([call(onSignInEmployeeStart)]);
|
||||
export function* onEmployeeGetRatesStart() {
|
||||
yield takeLatest(
|
||||
EmployeeActionTypes.EMPLOYEE_GET_RATES_START,
|
||||
getRatesWithEmployeeId
|
||||
);
|
||||
}
|
||||
export function* getRatesWithEmployeeId({ payload }) {
|
||||
try {
|
||||
const response = yield client.query({ query: QUERY_EMPLOYEE_BY_ID,
|
||||
variables: {
|
||||
id: payload.id,
|
||||
}
|
||||
});
|
||||
logImEXEvent("redux_employee_get_rates_attempt", payload);
|
||||
const { valid, technician, error } = response.data;
|
||||
|
||||
if (valid) {
|
||||
yield put(employeeGetRatesSuccess(technician));
|
||||
} else {
|
||||
yield put(employeeGetRatesFailure(error));
|
||||
}
|
||||
} catch (error) {
|
||||
yield put(employeeGetRatesFailure(error));
|
||||
console.log("Error while getting employee rates.", error);
|
||||
Sentry.Native.captureException(error);
|
||||
}
|
||||
}
|
||||
|
||||
export function* employeeSagas() {
|
||||
yield all([call(onSignInEmployeeStart), call(employeeGetRatesSuccess)]);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,22 @@ import { createSelector } from "reselect";
|
||||
const selectEmployee = (state) => state.employee;
|
||||
|
||||
export const selectCurrentEmployee = createSelector(
|
||||
[selectEmployee],
|
||||
(employee) => employee.currentEmployee
|
||||
);
|
||||
[selectEmployee],
|
||||
(employee) => employee.currentEmployee
|
||||
);
|
||||
export const selectSigningIn = createSelector(
|
||||
[selectEmployee],
|
||||
(employee) => employee.signingIn
|
||||
);
|
||||
export const selectSignInError = createSelector(
|
||||
[selectEmployee],
|
||||
(employee) => employee.error
|
||||
);
|
||||
[selectEmployee],
|
||||
(employee) => employee.signingIn
|
||||
);
|
||||
export const selectSignInError = createSelector(
|
||||
[selectEmployee],
|
||||
(employee) => employee.error
|
||||
);
|
||||
export const selectRates = createSelector(
|
||||
[selectEmployee],
|
||||
(employee) => employee.currentEmployee.rates
|
||||
);
|
||||
export const selectGettingRates = createSelector(
|
||||
[selectEmployee],
|
||||
(employee) => employee.gettingRates
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user