- the great reformat

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-02-06 18:20:58 -05:00
parent 30c530bcc4
commit e83badb454
912 changed files with 108516 additions and 107493 deletions

View File

@@ -1,20 +1,20 @@
import TechActionTypes from "./tech.types";
export const techLoginStart = ({ employeeid, pin }) => ({
type: TechActionTypes.TECH_LOGIN_START,
payload: { employeeid, pin },
export const techLoginStart = ({employeeid, pin}) => ({
type: TechActionTypes.TECH_LOGIN_START,
payload: {employeeid, pin},
});
export const techLoginSuccess = (tech) => ({
type: TechActionTypes.TECH_LOGIN_SUCCESS,
payload: tech,
type: TechActionTypes.TECH_LOGIN_SUCCESS,
payload: tech,
});
export const techLoginFailure = (error) => ({
type: TechActionTypes.TECH_LOGIN_FAILURE,
payload: error,
type: TechActionTypes.TECH_LOGIN_FAILURE,
payload: error,
});
export const techLogout = () => ({
type: TechActionTypes.TECH_LOGOUT,
type: TechActionTypes.TECH_LOGOUT,
});

View File

@@ -1,45 +1,46 @@
import TechActionTypes from "./tech.types";
const INITIAL_STATE = {
technician: null,
// technician: {
// employee_number: "101",
// first_name: "***HARDCODED",
// last_name: "IN REDUCER***",
// },
loginLoading: false,
loginError: null,
technician: null,
// technician: {
// employee_number: "101",
// first_name: "***HARDCODED",
// last_name: "IN REDUCER***",
// },
loginLoading: false,
loginError: null,
};
const applicationReducer = (state = INITIAL_STATE, action) => {
switch (action.type) {
case TechActionTypes.TECH_LOGOUT:
return {
...state,
technician: null,
loginError: null,
};
case TechActionTypes.TECH_LOGIN_START:
return {
...state,
loginLoading: true,
};
case TechActionTypes.TECH_LOGIN_SUCCESS:
return {
...state,
technician: action.payload,
loginLoading: false,
loginError: false,
};
case TechActionTypes.TECH_LOGIN_FAILURE:
return {
...state,
loginError: action.payload,
loginLoading: false,
};
switch (action.type) {
case TechActionTypes.TECH_LOGOUT:
return {
...state,
technician: null,
loginError: null,
};
case TechActionTypes.TECH_LOGIN_START:
return {
...state,
loginLoading: true,
};
case TechActionTypes.TECH_LOGIN_SUCCESS:
return {
...state,
technician: action.payload,
loginLoading: false,
loginError: false,
};
case TechActionTypes.TECH_LOGIN_FAILURE:
return {
...state,
loginError: action.payload,
loginLoading: false,
};
default:
return state;
}
default:
return state;
}
};
export default applicationReducer;

View File

@@ -1,36 +1,37 @@
import axios from "axios";
import { all, call, put, select, takeLatest } from "redux-saga/effects";
import { logImEXEvent } from "../../firebase/firebase.utils";
import { selectBodyshop } from "../user/user.selectors";
import { techLoginFailure, techLoginSuccess } from "./tech.actions";
import {all, call, put, select, takeLatest} from "redux-saga/effects";
import {logImEXEvent} from "../../firebase/firebase.utils";
import {selectBodyshop} from "../user/user.selectors";
import {techLoginFailure, techLoginSuccess} from "./tech.actions";
import TechActionTypes from "./tech.types";
export function* onSignInStart() {
yield takeLatest(TechActionTypes.TECH_LOGIN_START, signInStart);
yield takeLatest(TechActionTypes.TECH_LOGIN_START, signInStart);
}
export function* signInStart({ payload: { employeeid, pin } }) {
try {
logImEXEvent("redux_tech_sign_in");
const bodyshop = yield select(selectBodyshop);
const response = yield call(axios.post, "/tech/login", {
shopid: bodyshop.id,
employeeid: employeeid,
pin: pin,
});
export function* signInStart({payload: {employeeid, pin}}) {
try {
logImEXEvent("redux_tech_sign_in");
const { valid, technician, error } = response.data;
const bodyshop = yield select(selectBodyshop);
const response = yield call(axios.post, "/tech/login", {
shopid: bodyshop.id,
employeeid: employeeid,
pin: pin,
});
if (valid) {
yield put(techLoginSuccess(technician));
} else {
yield put(techLoginFailure(error));
const {valid, technician, error} = response.data;
if (valid) {
yield put(techLoginSuccess(technician));
} else {
yield put(techLoginFailure(error));
}
} catch (error) {
yield put(techLoginFailure(error));
}
} catch (error) {
yield put(techLoginFailure(error));
}
}
export function* techSagas() {
yield all([call(onSignInStart)]);
yield all([call(onSignInStart)]);
}

View File

@@ -1,16 +1,16 @@
import { createSelector } from "reselect";
import {createSelector} from "reselect";
const selectTechReducer = (state) => state.tech;
export const selectTechnician = createSelector(
[selectTechReducer],
(application) => application.technician
[selectTechReducer],
(application) => application.technician
);
export const selectLoginError = createSelector(
[selectTechReducer],
(application) => application.loginError
[selectTechReducer],
(application) => application.loginError
);
export const selectLoginLoading = createSelector(
[selectTechReducer],
(application) => application.loginLoading
[selectTechReducer],
(application) => application.loginLoading
);

View File

@@ -1,7 +1,7 @@
const TechActionTypes = {
TECH_LOGIN_START: "TECH_LOGIN_START",
TECH_LOGIN_SUCCESS: "TECH_LOGIN_SUCCESS",
TECH_LOGIN_FAILURE: "TECH_LOGIN_FAILURE",
TECH_LOGOUT: "TECH_LOGOUT",
TECH_LOGIN_START: "TECH_LOGIN_START",
TECH_LOGIN_SUCCESS: "TECH_LOGIN_SUCCESS",
TECH_LOGIN_FAILURE: "TECH_LOGIN_FAILURE",
TECH_LOGOUT: "TECH_LOGOUT",
};
export default TechActionTypes;