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,7 +1,8 @@
|
||||
import Icon from "@ant-design/icons";
|
||||
import { Popover } from "antd";
|
||||
import _ from "lodash";
|
||||
import moment from "moment";
|
||||
import dayjs from "../../utils/day";
|
||||
|
||||
import React, { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { MdFileDownload, MdFileUpload } from "react-icons/md";
|
||||
@@ -43,7 +44,7 @@ export function ScheduleCalendarHeaderComponent({
|
||||
(e) =>
|
||||
!e.vacation &&
|
||||
e.isintake &&
|
||||
moment(date).isSame(moment(e.start), "day")
|
||||
dayjs(date).isSame(dayjs(e.start), "day")
|
||||
),
|
||||
"job.alt_transport"
|
||||
);
|
||||
@@ -54,7 +55,7 @@ export function ScheduleCalendarHeaderComponent({
|
||||
return (
|
||||
events &&
|
||||
events.filter(
|
||||
(e) => moment(date).isSame(moment(e.start), "day") && e.block
|
||||
(e) => dayjs(date).isSame(dayjs(e.start), "day") && e.block
|
||||
)
|
||||
);
|
||||
}, [events, date]);
|
||||
@@ -170,7 +171,7 @@ export function ScheduleCalendarHeaderComponent({
|
||||
|
||||
const isShopOpen = (date) => {
|
||||
let day;
|
||||
switch (moment(date).day()) {
|
||||
switch (dayjs(date).day()) {
|
||||
case 0:
|
||||
day = "sunday";
|
||||
break;
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
import moment from "moment";
|
||||
import dayjs from "../../utils/day";
|
||||
|
||||
export function getRange(dateParam, viewParam) {
|
||||
let start, end;
|
||||
let date = dateParam || new Date();
|
||||
let view = viewParam || "week";
|
||||
// if view is day: from moment(date).startOf('day') to moment(date).endOf('day');
|
||||
// if view is day: from dayjs(date).startOf('day') to dayjs(date).endOf('day');
|
||||
if (view === "day") {
|
||||
start = moment(date).startOf("day");
|
||||
end = moment(date).endOf("day");
|
||||
start = dayjs(date).startOf("day");
|
||||
end = dayjs(date).endOf("day");
|
||||
}
|
||||
// if view is week: from moment(date).startOf('isoWeek') to moment(date).endOf('isoWeek');
|
||||
// if view is week: from dayjs(date).startOf('isoWeek') to dayjs(date).endOf('isoWeek');
|
||||
else if (view === "week") {
|
||||
start = moment(date).startOf("week");
|
||||
end = moment(date).endOf("week");
|
||||
start = dayjs(date).startOf("week");
|
||||
end = dayjs(date).endOf("week");
|
||||
}
|
||||
//if view is month: from moment(date).startOf('month').subtract(7, 'days') to moment(date).endOf('month').add(7, 'days'); i do additional 7 days math because you can see adjacent weeks on month view (that is the way how i generate my recurrent events for the Big Calendar, but if you need only start-end of month - just remove that math);
|
||||
//if view is month: from dayjs(date).startOf('month').subtract(7, 'days') to dayjs(date).endOf('month').add(7, 'days'); i do additional 7 days math because you can see adjacent weeks on month view (that is the way how i generate my recurrent events for the Big Calendar, but if you need only start-end of month - just remove that math);
|
||||
else if (view === "month") {
|
||||
start = moment(date).startOf("month").subtract(7, "days");
|
||||
end = moment(date).endOf("month").add(7, "days");
|
||||
start = dayjs(date).startOf("month").subtract(7, "days");
|
||||
end = dayjs(date).endOf("month").add(7, "days");
|
||||
}
|
||||
// if view is agenda: from moment(date).startOf('day') to moment(date).endOf('day').add(1, 'month');
|
||||
// if view is agenda: from dayjs(date).startOf('day') to dayjs(date).endOf('day').add(1, 'month');
|
||||
else if (view === "agenda") {
|
||||
start = moment(date).startOf("day");
|
||||
end = moment(date).endOf("day").add(1, "month");
|
||||
start = dayjs(date).startOf("day");
|
||||
end = dayjs(date).endOf("day").add(1, "month");
|
||||
}
|
||||
|
||||
return { start, end };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import moment from "moment";
|
||||
import dayjs from "../../utils/day";
|
||||
import queryString from "query-string";
|
||||
import React from "react";
|
||||
import { Calendar, momentLocalizer } from "react-big-calendar";
|
||||
import { Calendar, dayjsLocalizer } from "react-big-calendar";
|
||||
import { connect } from "react-redux";
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -19,7 +19,7 @@ const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
problemJobs: selectProblemJobs,
|
||||
});
|
||||
const localizer = momentLocalizer(moment);
|
||||
const localizer = dayjsLocalizer(dayjs);
|
||||
export function ScheduleCalendarWrapperComponent({
|
||||
bodyshop,
|
||||
problemJobs,
|
||||
@@ -49,7 +49,7 @@ export function ScheduleCalendarWrapperComponent({
|
||||
};
|
||||
};
|
||||
|
||||
const selectedDate = new Date(date || moment(search.date) || Date.now());
|
||||
const selectedDate = new Date(date || dayjs(search.date) || Date.now());
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user