IO-2132 Updated approach to ATS summary.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<babeledit_project version="1.2" be_version="2.7.1">
|
||||
<babeledit_project be_version="2.7.1" version="1.2">
|
||||
<!--
|
||||
|
||||
BabelEdit project file
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { Space } from "antd";
|
||||
import React from "react";
|
||||
import React, { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectScheduleLoad } from "../../redux/application/application.selectors";
|
||||
import queryString from "query-string";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
scheduleLoad: selectScheduleLoad,
|
||||
@@ -14,20 +12,33 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
export function ScheduleAtsSummary({ scheduleLoad }) {
|
||||
export function ScheduleAtsSummary({ scheduleLoad, appointments }) {
|
||||
const { t } = useTranslation();
|
||||
const search = queryString.parse(useLocation().search);
|
||||
|
||||
if (
|
||||
(search.view === undefined || search.view === "week") &&
|
||||
scheduleLoad.atsSummary &&
|
||||
Object.keys(scheduleLoad.atsSummary).length > 0
|
||||
)
|
||||
const atsSummary = useMemo(() => {
|
||||
let atsSummary = {};
|
||||
if (!appointments || appointments.length === 0) {
|
||||
return {};
|
||||
}
|
||||
appointments
|
||||
.filter((a) => a.isintake)
|
||||
.forEach((a) => {
|
||||
if (!a.job.alt_transport) return;
|
||||
if (!atsSummary[a.job.alt_transport]) {
|
||||
atsSummary[a.job.alt_transport] = 1;
|
||||
} else {
|
||||
atsSummary[a.job.alt_transport] = atsSummary[a.job.alt_transport] + 1;
|
||||
}
|
||||
});
|
||||
return atsSummary;
|
||||
}, [appointments]);
|
||||
|
||||
if (Object.keys(atsSummary).length > 0)
|
||||
return (
|
||||
<Space wrap>
|
||||
{t("schedule.labels.atssummary")}
|
||||
{Object.keys(scheduleLoad.atsSummary).map((key) => (
|
||||
<span key={key}>{`${key}: ${scheduleLoad.atsSummary[key]}`}</span>
|
||||
{Object.keys(atsSummary).map((key) => (
|
||||
<span key={key}>{`${key}: ${atsSummary[key]}`}</span>
|
||||
))}
|
||||
</Space>
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Button, Card, Checkbox, Col, PageHeader, Row, Space } from "antd";
|
||||
import { t } from "i18next";
|
||||
import React, { useMemo } from "react";
|
||||
import useLocalStorage from "../../utils/useLocalStorage";
|
||||
import ScheduleAtsSummary from "../schedule-ats-summary/schedule-ats-summary.component";
|
||||
import ScheduleAtsSummary from "../schedule-ats-summary/schedule-ats-summary.component";
|
||||
import ScheduleCalendarWrapperComponent from "../schedule-calendar-wrapper/scheduler-calendar-wrapper.component";
|
||||
import ScheduleModal from "../schedule-job-modal/schedule-job-modal.container";
|
||||
import ScheduleManualEvent from "../schedule-manual-event/schedule-manual-event.component";
|
||||
@@ -11,7 +11,6 @@ import ScheduleProductionList from "../schedule-production-list/schedule-product
|
||||
import ScheduleVerifyIntegrity from "../schedule-verify-integrity/schedule-verify-integrity.component";
|
||||
|
||||
export default function ScheduleCalendarComponent({ data, refetch }) {
|
||||
|
||||
const [filter, setFilter] = useLocalStorage("filter_events", {
|
||||
intake: true,
|
||||
manual: true,
|
||||
@@ -37,7 +36,7 @@ export default function ScheduleCalendarComponent({ data, refetch }) {
|
||||
<PageHeader
|
||||
extra={
|
||||
<Space wrap>
|
||||
<ScheduleAtsSummary/>
|
||||
<ScheduleAtsSummary appointments={filteredData} />
|
||||
<Checkbox
|
||||
checked={filter?.intake}
|
||||
onChange={(e) => {
|
||||
@@ -73,8 +72,6 @@ export default function ScheduleCalendarComponent({ data, refetch }) {
|
||||
<ScheduleProductionList />
|
||||
|
||||
<ScheduleManualEvent />
|
||||
|
||||
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -172,21 +172,6 @@ export function* calculateScheduleLoad({ payload: end }) {
|
||||
}
|
||||
}
|
||||
|
||||
//Calculate weekly ATS summary.
|
||||
const startOfWeek = moment(end).startOf("week");
|
||||
const endOfWeek = moment(end).endOf("week");
|
||||
load.atsSummary = {};
|
||||
arrJobs
|
||||
.filter((j) => moment(j.scheduled_in).isBetween(startOfWeek, endOfWeek))
|
||||
.forEach((j) => {
|
||||
if (!load.atsSummary[j.alt_transport]) {
|
||||
load.atsSummary[j.alt_transport] = 1;
|
||||
} else {
|
||||
load.atsSummary[j.alt_transport] =
|
||||
load.atsSummary[j.alt_transport] + 1;
|
||||
}
|
||||
});
|
||||
|
||||
yield put(setProblemJobs(problemJobs));
|
||||
yield put(scheduleLoadSuccess(load));
|
||||
} catch (error) {
|
||||
|
||||
@@ -2501,7 +2501,7 @@
|
||||
},
|
||||
"schedule": {
|
||||
"labels": {
|
||||
"atssummary": "Weekly ATS Summary",
|
||||
"atssummary": "ATS Summary",
|
||||
"employeevacation": "Employee Vacations",
|
||||
"intake": "Intake Events",
|
||||
"manual": "Manual Events",
|
||||
|
||||
Reference in New Issue
Block a user