DayJS Replacement

This commit is contained in:
Patrick Fic
2024-04-18 09:55:18 -07:00
parent 79a0881f5a
commit 7d7fe9819f
13 changed files with 131 additions and 55 deletions

View File

@@ -1,7 +1,6 @@
import { message } from "antd";
import gql from "graphql-tag";
import _ from "lodash";
import moment from "moment";
import client from "../graphql/GraphQLClient";
import {
INSERT_NEW_JOB,
@@ -23,12 +22,12 @@ export function CalculateVehicleAge(job) {
//Per new rules in 2023, we need to determine which set of rules to apply.
const parsedYr = parseInt(job.v_model_yr);
const vehicleYr =
moment().year() + 1 - 2000 >= parsedYr ? 2000 + parsedYr : 1900 + parsedYr;
const closeDate = moment(job.close_date);
const lossDate = moment(job.loss_date);
dayjs().year() + 1 - 2000 >= parsedYr ? 2000 + parsedYr : 1900 + parsedYr;
const closeDate = dayjs(job.close_date);
const lossDate = dayjs(job.loss_date);
let ret;
if (closeDate.isSameOrAfter(moment("2023-04-01"))) {
if (closeDate.isSameOrAfter(dayjs("2023-04-01"))) {
//Post April 2023 rules where the age is calculated based on loss date.
ipcRenderer.send(
ipcTypes.app.toMain.log.debug,
@@ -43,7 +42,7 @@ export function CalculateVehicleAge(job) {
"Using pre 0423 ruleset to calculate vehicle age for job.",
job
);
ret = Math.max(0, moment(job.close_date || new Date()).year() - vehicleYr);
ret = Math.max(0, dayjs(job.close_date || new Date()).year() - vehicleYr);
}
return ret;
@@ -231,7 +230,7 @@ const DetermineVehicleGroup = async (job) => {
variables: {
make: job.v_makedesc.toUpperCase(),
type: job.v_type,
date: moment().format("YYYY-MM-DD"),
date: dayjs().format("YYYY-MM-DD"),
},
});