WIP for Reporting. Pulled out calculations to utility functions.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { all, call, takeLatest, select, put } from "redux-saga/effects";
|
||||
import GetJobTarget from "../../util/GetJobTarget";
|
||||
import { setSelectedJobTargetPcSuccess } from "./application.actions";
|
||||
import ApplicationActionTypes from "./application.types";
|
||||
|
||||
@@ -12,17 +13,18 @@ export function* CalculateTarget({ payload }) {
|
||||
const { group, v_age } = payload;
|
||||
const targets = yield select((state) => state.user.bodyshop.targets);
|
||||
|
||||
const targetsForGroup = targets.filter((t) => t.group === group);
|
||||
if (!targetsForGroup) return 0;
|
||||
const targetPc = targetsForGroup.filter(
|
||||
(t) => t.ageGte <= v_age && (t.ageLt ? t.ageLt > v_age : true)
|
||||
);
|
||||
if (targetPc.length === 0) yield put(setSelectedJobTargetPcSuccess(100));
|
||||
else if (targetPc.length === 1)
|
||||
yield put(setSelectedJobTargetPcSuccess(targetPc[0].target));
|
||||
else {
|
||||
yield put(setSelectedJobTargetPcSuccess(100));
|
||||
}
|
||||
yield put(setSelectedJobTargetPcSuccess(GetJobTarget(group, v_age, targets)));
|
||||
// const targetsForGroup = targets.filter((t) => t.group === group);
|
||||
// if (!targetsForGroup) return 0;
|
||||
// const targetPc = targetsForGroup.filter(
|
||||
// (t) => t.ageGte <= v_age && (t.ageLt ? t.ageLt > v_age : true)
|
||||
// );
|
||||
// if (targetPc.length === 0) yield put(setSelectedJobTargetPcSuccess(100));
|
||||
// else if (targetPc.length === 1)
|
||||
// yield put(setSelectedJobTargetPcSuccess(targetPc[0].target));
|
||||
// else {
|
||||
// yield put(setSelectedJobTargetPcSuccess(100));
|
||||
// }
|
||||
}
|
||||
|
||||
export function* applicationSagas() {
|
||||
|
||||
Reference in New Issue
Block a user