diff --git a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js index 69a5d6ac5..8873df7d7 100644 --- a/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js +++ b/client/src/components/schedule-calendar-wrapper/schedule-calendar-header.component.js @@ -31,8 +31,9 @@ export function ScheduleCalendarHeaderComponent({ const loadData = load[date.toISOString().substr(0, 10)]; const LoadComponent = loadData ? ( -
+
diff --git a/client/src/components/schedule-calendar/schedule-calendar.container.jsx b/client/src/components/schedule-calendar/schedule-calendar.container.jsx index 001894888..eff7a1bc8 100644 --- a/client/src/components/schedule-calendar/schedule-calendar.container.jsx +++ b/client/src/components/schedule-calendar/schedule-calendar.container.jsx @@ -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 ; - if (error) return ; + if (error) return ; let normalizedData = data.appointments.map((e) => { //Required becuase Hasura returns a string instead of a date object. return Object.assign( diff --git a/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx b/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx index 3d59d9b7d..570a60c3a 100644 --- a/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx +++ b/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx @@ -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"), }); diff --git a/client/src/redux/application/application.sagas.js b/client/src/redux/application/application.sagas.js index 6b71ca79c..834f74c8a 100644 --- a/client/src/redux/application/application.sagas.js +++ b/client/src/redux/application/application.sagas.js @@ -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;