Added minor changes for BOD-83 scheduling load.
This commit is contained in:
@@ -31,8 +31,9 @@ export function ScheduleCalendarHeaderComponent({
|
|||||||
const loadData = load[date.toISOString().substr(0, 10)];
|
const loadData = load[date.toISOString().substr(0, 10)];
|
||||||
|
|
||||||
const LoadComponent = loadData ? (
|
const LoadComponent = loadData ? (
|
||||||
<div>
|
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||||
<Progress
|
<Progress
|
||||||
|
style={{ display: "flex", alignItems: "center" }}
|
||||||
percent={((loadData.expectedLoad || 0) / ShopTargetHrs) * 100}
|
percent={((loadData.expectedLoad || 0) / ShopTargetHrs) * 100}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useQuery } from "@apollo/react-hooks";
|
import { useQuery } from "@apollo/react-hooks";
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
import React from "react";
|
import React, { useMemo } from "react";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import { QUERY_ALL_ACTIVE_APPOINTMENTS } from "../../graphql/appointments.queries";
|
import { QUERY_ALL_ACTIVE_APPOINTMENTS } from "../../graphql/appointments.queries";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
@@ -21,7 +21,7 @@ export function ScheduleCalendarContainer({ calculateScheduleLoad }) {
|
|||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
|
|
||||||
const { date, view } = search;
|
const { date, view } = search;
|
||||||
const range = getRange(date, view);
|
const range = useMemo(() => getRange(date, view), [date, view]);
|
||||||
const { loading, error, data, refetch } = useQuery(
|
const { loading, error, data, refetch } = useQuery(
|
||||||
QUERY_ALL_ACTIVE_APPOINTMENTS,
|
QUERY_ALL_ACTIVE_APPOINTMENTS,
|
||||||
{
|
{
|
||||||
@@ -31,7 +31,7 @@ export function ScheduleCalendarContainer({ calculateScheduleLoad }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (loading) return <LoadingSpinner />;
|
if (loading) return <LoadingSpinner />;
|
||||||
if (error) return <AlertComponent message={error.message} type='error' />;
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||||
let normalizedData = data.appointments.map((e) => {
|
let normalizedData = data.appointments.map((e) => {
|
||||||
//Required becuase Hasura returns a string instead of a date object.
|
//Required becuase Hasura returns a string instead of a date object.
|
||||||
return Object.assign(
|
return Object.assign(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { notification, Modal } from "antd";
|
import { notification, Modal } from "antd";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { UPDATE_JOB_STATUS } from "../../graphql/jobs.queries";
|
import { UPDATE_JOBS } from "../../graphql/jobs.queries";
|
||||||
|
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
@@ -36,12 +36,7 @@ export function ScheduleJobModalContainer({
|
|||||||
start: null,
|
start: null,
|
||||||
});
|
});
|
||||||
const [insertAppointment] = useMutation(INSERT_APPOINTMENT);
|
const [insertAppointment] = useMutation(INSERT_APPOINTMENT);
|
||||||
const [updateJobStatus] = useMutation(UPDATE_JOB_STATUS, {
|
const [updateJobStatus] = useMutation(UPDATE_JOBS);
|
||||||
variables: {
|
|
||||||
jobId: jobId,
|
|
||||||
status: bodyshop.md_ro_statuses.default_scheduled,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const [formData, setFormData] = useState({ notifyCustomer: false });
|
const [formData, setFormData] = useState({ notifyCustomer: false });
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -64,7 +59,16 @@ export function ScheduleJobModalContainer({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
updateJobStatus().then((r) => {
|
updateJobStatus({
|
||||||
|
variables: {
|
||||||
|
jobIds: [jobId],
|
||||||
|
fields: {
|
||||||
|
status: bodyshop.md_ro_statuses.default_scheduled,
|
||||||
|
date_scheduled: new Date(),
|
||||||
|
scheduled_in: appData.start,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).then((r) => {
|
||||||
notification["success"]({
|
notification["success"]({
|
||||||
message: t("appointments.successes.created"),
|
message: t("appointments.successes.created"),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -75,24 +75,17 @@ export function* calculateScheduleLoad({ payload: end }) {
|
|||||||
//Propagate the expected load to each day.
|
//Propagate the expected load to each day.
|
||||||
const range = Math.round(moment.duration(end.diff(today)).asDays());
|
const range = Math.round(moment.duration(end.diff(today)).asDays());
|
||||||
for (var day = 0; day < range; day++) {
|
for (var day = 0; day < range; day++) {
|
||||||
console.log(
|
|
||||||
"function*calculateScheduleLoad -> today",
|
|
||||||
today.toISOString()
|
|
||||||
);
|
|
||||||
const current = moment(today)
|
const current = moment(today)
|
||||||
.add(day, "days")
|
.add(day, "days")
|
||||||
.toISOString()
|
.toISOString()
|
||||||
.substr(0, 10);
|
.substr(0, 10);
|
||||||
console.log(
|
|
||||||
"function*calculateScheduleLoad -> today",
|
|
||||||
today.toISOString()
|
|
||||||
);
|
|
||||||
console.log("function*calculateScheduleLoad -> current", current);
|
|
||||||
const prev = moment(today)
|
const prev = moment(today)
|
||||||
.add(day - 1, "days")
|
.add(day - 1, "days")
|
||||||
.toISOString()
|
.toISOString()
|
||||||
.substr(0, 10);
|
.substr(0, 10);
|
||||||
console.log("function*calculateScheduleLoad -> prev", prev);
|
if (!!!load[current]) {
|
||||||
|
load[current] = {};
|
||||||
|
}
|
||||||
if (day === 0) {
|
if (day === 0) {
|
||||||
//Starting on day 1. The load is current.
|
//Starting on day 1. The load is current.
|
||||||
load[current].expectedLoad = load.productionHoursTotal;
|
load[current].expectedLoad = load.productionHoursTotal;
|
||||||
|
|||||||
Reference in New Issue
Block a user