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