This is a breaking change, moment is no longer with us, let us have a dayjs of silence.
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import moment from "moment";
|
||||
import dayjs from "../../utils/day";
|
||||
import { all, call, put, select, takeLatest } from "redux-saga/effects";
|
||||
import { QUERY_SCHEDULE_LOAD_DATA } from "../../graphql/appointments.queries";
|
||||
import { INSERT_AUDIT_TRAIL } from "../../graphql/audit_trail.queries";
|
||||
@@ -18,8 +18,8 @@ export function* onCalculateScheduleLoad() {
|
||||
);
|
||||
}
|
||||
export function* calculateScheduleLoad({ payload: end }) {
|
||||
//REMINDER: Moment.js is not immutable. Today WILL change when adjusted.
|
||||
const today = moment().startOf("day");
|
||||
//REMINDER: dayjs.js is not immutable. Today WILL change when adjusted.
|
||||
const today = dayjs().startOf("day");
|
||||
const state = yield select();
|
||||
const buckets = state.user.bodyshop.ssbuckets;
|
||||
|
||||
@@ -47,7 +47,7 @@ export function* calculateScheduleLoad({ payload: end }) {
|
||||
//Add all of the jobs currently in production to the buckets so that we have a starting point.
|
||||
if (
|
||||
!item.actual_completion &&
|
||||
moment(item.scheduled_completion).isBefore(moment().startOf("day"))
|
||||
dayjs(item.scheduled_completion).isBefore(dayjs().startOf("day"))
|
||||
) {
|
||||
problemJobs.push({
|
||||
...item,
|
||||
@@ -57,7 +57,7 @@ export function* calculateScheduleLoad({ payload: end }) {
|
||||
|
||||
if (
|
||||
item.actual_completion &&
|
||||
moment(item.actual_completion).isBefore(moment().startOf("day"))
|
||||
dayjs(item.actual_completion).isBefore(dayjs().startOf("day"))
|
||||
) {
|
||||
problemJobs.push({
|
||||
...item,
|
||||
@@ -98,7 +98,7 @@ export function* calculateScheduleLoad({ payload: end }) {
|
||||
code: "Job has an actual in date, but no actual completion date and is not marked as in production",
|
||||
});
|
||||
}
|
||||
if (item.actual_in && moment(item.actual_in).isAfter(moment())) {
|
||||
if (item.actual_in && dayjs(item.actual_in).isAfter(dayjs())) {
|
||||
problemJobs.push({
|
||||
...item,
|
||||
code: "Job has an actual in date set in the future",
|
||||
@@ -106,7 +106,7 @@ export function* calculateScheduleLoad({ payload: end }) {
|
||||
}
|
||||
if (
|
||||
item.actual_completion &&
|
||||
moment(item.actual_completion).isAfter(moment())
|
||||
dayjs(item.actual_completion).isAfter(dayjs())
|
||||
) {
|
||||
problemJobs.push({
|
||||
...item,
|
||||
@@ -120,7 +120,7 @@ export function* calculateScheduleLoad({ payload: end }) {
|
||||
});
|
||||
}
|
||||
|
||||
const itemDate = moment(item.actual_in || item.scheduled_in).format(
|
||||
const itemDate = dayjs(item.actual_in || item.scheduled_in).format(
|
||||
"yyyy-MM-DD"
|
||||
);
|
||||
|
||||
@@ -169,7 +169,7 @@ export function* calculateScheduleLoad({ payload: end }) {
|
||||
|
||||
const AddJobForSchedulingCalc = inProdJobs || inArrJobs;
|
||||
|
||||
const itemDate = moment(
|
||||
const itemDate = dayjs(
|
||||
item.actual_completion || item.scheduled_completion
|
||||
).format("yyyy-MM-DD");
|
||||
//Skip it, it's already completed.
|
||||
@@ -207,10 +207,10 @@ export function* calculateScheduleLoad({ payload: end }) {
|
||||
|
||||
//Propagate the expected load to each day.
|
||||
|
||||
const range = Math.round(moment.duration(end.diff(today)).asDays()) + 1;
|
||||
const range = Math.round(dayjs.duration(end.diff(today)).asDays()) + 1;
|
||||
for (var day = 0; day < range; day++) {
|
||||
const current = moment(today).add(day, "days").format("yyyy-MM-DD");
|
||||
const prev = moment(today)
|
||||
const current = dayjs(today).add(day, "days").format("yyyy-MM-DD");
|
||||
const prev = dayjs(today)
|
||||
.add(day - 1, "days")
|
||||
.format("yyyy-MM-DD");
|
||||
if (!!!load[current]) {
|
||||
|
||||
Reference in New Issue
Block a user