DayJS Replacement
This commit is contained in:
@@ -4,7 +4,8 @@ import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectDates } from "../../../redux/reporting/reporting.selectors";
|
||||
import moment from "moment";
|
||||
import dayjs from '../../../util/day.js';
|
||||
|
||||
import { DateFormat } from "../../../util/constants";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
dates: selectDates,
|
||||
@@ -13,9 +14,9 @@ const mapStateToProps = createStructuredSelector({
|
||||
export function ReportingTitleAtom({ dates }) {
|
||||
return (
|
||||
<Typography.Title level={2}>
|
||||
{`RPS Report for Period from ${moment(dates.startDate).format(
|
||||
{`RPS Report for Period from ${dayjs(dates.startDate).format(
|
||||
DateFormat
|
||||
)} to ${moment(dates.endDate).format(DateFormat)}`}
|
||||
)} to ${dayjs(dates.endDate).format(DateFormat)}`}
|
||||
</Typography.Title>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Tooltip } from "antd";
|
||||
import moment from "moment";
|
||||
import dayjs from '../../../util/day.js';
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
export default function TimeAgoFormatter(props) {
|
||||
const [timestampString, setTimestampString] = useState("");
|
||||
const m = moment(props.children);
|
||||
const m = dayjs(props.children);
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => setTimestampString(m.fromNow()), 15000);
|
||||
setTimestampString(m.fromNow());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { WarningOutlined } from "@ant-design/icons";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { DatePicker, message, notification, Spin } from "antd";
|
||||
import moment from "moment";
|
||||
import dayjs from '../../../util/day.js';
|
||||
import React, { useState } from "react";
|
||||
import { UPDATE_JOB } from "../../../graphql/jobs.queries";
|
||||
import ipcTypes from "../../../ipc.types";
|
||||
@@ -10,7 +10,7 @@ import { ChangeOfRuleSet, DateFormat } from "../../../util/constants";
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
export default function CloseDateDisplayMolecule({ job, jobId, close_date }) {
|
||||
const [value, setValue] = useState(moment(close_date));
|
||||
const [value, setValue] = useState(dayjs(close_date));
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updateJob] = useMutation(UPDATE_JOB);
|
||||
|
||||
@@ -21,8 +21,8 @@ export default function CloseDateDisplayMolecule({ job, jobId, close_date }) {
|
||||
setLoading(true);
|
||||
setValue(newDate);
|
||||
const requires_reimport = ChangeOfRuleSet({
|
||||
prevDateMoment: job.close_date ? moment(job.close_date) : moment(),
|
||||
newDateMoment: newDate ? newDate : moment(),
|
||||
prevDateMoment: job.close_date ? dayjs(job.close_date) : dayjs(),
|
||||
newDateMoment: newDate ? newDate : dayjs(),
|
||||
});
|
||||
if (requires_reimport) {
|
||||
notification.open({
|
||||
|
||||
@@ -8,7 +8,7 @@ import JobGroupMolecule from "../job-group/job-group.molecule";
|
||||
import DeleteJobAtom from "../../atoms/delete-job/delete-job.atom";
|
||||
import VehicleGroupAlertAtom from "../../atoms/vehicle-group-alert/vehicle-group-alert.atom";
|
||||
import { DateFormat } from "../../../util/constants";
|
||||
import moment from "moment";
|
||||
import dayjs from '../../../util/day.js';
|
||||
import { PageHeader } from "@ant-design/pro-layout";
|
||||
|
||||
export default function JobsDetailDescriptionMolecule({ loading, job }) {
|
||||
@@ -69,7 +69,7 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) {
|
||||
{job && job.joblines.filter((i) => !i.ignore && i.db_ref !== "900511").length}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="Loss Date">
|
||||
{job.loss_date ? moment(job.loss_date).format(DateFormat) : "No Loss Date"}
|
||||
{job.loss_date ? dayjs(job.loss_date).format(DateFormat) : "No Loss Date"}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</PageHeader>
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { queryReportingData } from "../../../redux/reporting/reporting.actions";
|
||||
import moment from "moment";
|
||||
import dayjs from '../../../util/day.js';
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
});
|
||||
@@ -40,7 +40,7 @@ export function ReportingDatesMolecule({ queryReportingData }) {
|
||||
}
|
||||
|
||||
if (
|
||||
moment(value[1]).diff(moment(value[0]), "years", true) > 1
|
||||
dayjs(value[1]).diff(dayjs(value[0]), "years", true) > 1
|
||||
) {
|
||||
return Promise.reject(
|
||||
"Time period exceeds 1 year. Please select a shorter date range."
|
||||
@@ -55,38 +55,38 @@ export function ReportingDatesMolecule({ queryReportingData }) {
|
||||
<DatePicker.RangePicker
|
||||
format="MM/DD/YYYY"
|
||||
ranges={{
|
||||
Today: [moment(), moment()],
|
||||
"Last 14 days": [moment().subtract(14, "days"), moment()],
|
||||
"Last 7 days": [moment().subtract(7, "days"), moment()],
|
||||
"Next 7 days": [moment(), moment().add(7, "days")],
|
||||
"Next 14 days": [moment(), moment().add(14, "days")],
|
||||
Today: [dayjs(), dayjs()],
|
||||
"Last 14 days": [dayjs().subtract(14, "day"), dayjs()],
|
||||
"Last 7 days": [dayjs().subtract(7, "day"), dayjs()],
|
||||
"Next 7 days": [dayjs(), dayjs().add(7, "day")],
|
||||
"Next 14 days": [dayjs(), dayjs().add(14, "day")],
|
||||
"Last Month": [
|
||||
moment().startOf("month").subtract(1, "month"),
|
||||
moment().startOf("month").subtract(1, "month").endOf("month"),
|
||||
dayjs().startOf("month").subtract(1, "month"),
|
||||
dayjs().startOf("month").subtract(1, "month").endOf("month"),
|
||||
],
|
||||
|
||||
"This Month": [
|
||||
moment().startOf("month"),
|
||||
moment().endOf("month"),
|
||||
dayjs().startOf("month"),
|
||||
dayjs().endOf("month"),
|
||||
],
|
||||
"Next Month": [
|
||||
moment().startOf("month").add(1, "month"),
|
||||
moment().startOf("month").add(1, "month").endOf("month"),
|
||||
dayjs().startOf("month").add(1, "month"),
|
||||
dayjs().startOf("month").add(1, "month").endOf("month"),
|
||||
],
|
||||
"Last Quarter": [
|
||||
moment().startOf("quarter").subtract(1, "quarters"),
|
||||
moment().startOf("quarter").subtract(1, "day"),
|
||||
dayjs().startOf("quarter").subtract(1, "quarter"),
|
||||
dayjs().startOf("quarter").subtract(1, "day"),
|
||||
],
|
||||
"This Quarter": [
|
||||
moment().startOf("quarter"),
|
||||
moment()
|
||||
dayjs().startOf("quarter"),
|
||||
dayjs()
|
||||
.startOf("quarter")
|
||||
.add(1, "quarter")
|
||||
.subtract(1, "day"),
|
||||
],
|
||||
"Last 3 Months": [
|
||||
moment().startOf("month").subtract(3, "month"),
|
||||
moment().startOf("month").subtract(1, "month").endOf("month"),
|
||||
dayjs().startOf("month").subtract(3, "month"),
|
||||
dayjs().startOf("month").subtract(1, "month").endOf("month"),
|
||||
],
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CloudUploadOutlined } from "@ant-design/icons";
|
||||
import { Alert, Input, Space, Table } from "antd";
|
||||
import moment from "moment";
|
||||
import dayjs from '../../../util/day.js';
|
||||
import React, { useState } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { connect } from "react-redux";
|
||||
@@ -60,10 +60,10 @@ export function ReportingJobsListMolecule({
|
||||
title: "R4P",
|
||||
dataIndex: "close_date",
|
||||
key: "close_date",
|
||||
render: (text, record) => moment(record.close_date).format("MM/DD/yyyy"),
|
||||
render: (text, record) => dayjs(record.close_date).format("MM/DD/yyyy"),
|
||||
defaultSortOrder: "ascend",
|
||||
sorter: (a, b) =>
|
||||
moment(a.close_date).unix() - moment(b.close_date).unix(),
|
||||
dayjs(a.close_date).unix() - dayjs(b.close_date).unix(),
|
||||
},
|
||||
{
|
||||
title: "Ins Co.",
|
||||
|
||||
Reference in New Issue
Block a user