From 65157a094f09563a5f1de7c6d27d571de631b78d Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Wed, 13 Dec 2023 19:06:15 -0500 Subject: [PATCH] This is a breaking change, moment is no longer with us, let us have a dayjs of silence. Signed-off-by: Dave Richer --- client/craco.config.js | 5 +- client/package-lock.json | 342 +++++++++++++----- client/package.json | 11 +- client/src/App/App.container.jsx | 5 +- .../bill-detail-edit-component.jsx | 4 +- .../bill-form/bill-form.component.jsx | 10 +- .../billline-add-inventory.component.jsx | 6 +- .../card-payment-modal.component..jsx | 4 +- .../chat-message-list.component.jsx | 4 +- .../contract-cars/contract-cars.container.jsx | 4 +- .../contract-convert-to-ro.component.jsx | 6 +- .../contract-form/contract-form.component.jsx | 10 +- ...ntract-license-decode-button.component.jsx | 14 +- .../contracts-list.component.jsx | 6 +- .../courtesy-car-form.component.jsx | 8 +- .../courtesy-car-return-modal.container.jsx | 4 +- .../courtesy-cars-list.component.jsx | 4 +- .../monthly-employee-efficiency.component.jsx | 10 +- .../monthly-revenue-graph.component.jsx | 6 +- .../projected-monthly-sales.component.jsx | 14 +- .../scheduled-in-today.component.jsx | 12 +- .../scheduled-out-today.component.jsx | 10 +- .../dashboard-grid.component.jsx | 10 +- .../dms-log-events.component.jsx | 4 +- .../dms-post-form/dms-post-form.component.jsx | 4 +- .../email-test/email-test-component.jsx | 10 +- .../feature-wrapper.component.jsx | 4 +- .../form-date-picker.component.jsx | 86 +++-- .../form-date-time-picker.component.jsx | 8 +- .../inventory-bill-ro.component.jsx | 4 +- .../schedule-event.component.jsx | 6 +- .../job-checklist-form.component.jsx | 14 +- .../job-detail-lines/job-lines.component.jsx | 4 +- .../job-line-convert-to-labor.component.jsx | 2 +- .../job-scoreboard-add-button.component.jsx | 4 +- .../jobs-admin-dates.component.jsx | 6 +- .../jobs-admin-mark-reexport.component.jsx | 4 +- .../jobs-admin-unvoid.component.jsx | 4 +- .../jobs-available-table.container.jsx | 4 +- .../jobs-detail-header-actions.addevent.jsx | 4 +- ...bs-detail-header-actions.duplicate.util.js | 4 +- .../parts-order-modal.container.jsx | 8 +- .../payment-expanded-row.component.jsx | 4 +- ...production-board-kanban-card.component.jsx | 8 +- .../production-list-columns.data.js | 4 +- ...production-list-columns.date.component.jsx | 12 +- ...n-list-columns.lastcontacted.component.jsx | 4 +- ...ution-list-columns.touchtime.component.jsx | 6 +- .../report-center-modal.component.jsx | 10 +- .../schedule-block-day.component.jsx | 6 +- .../schedule-calendar-header.component.js | 9 +- .../schedule-calendar-util.js | 26 +- .../scheduler-calendar-wrapper.component.jsx | 8 +- .../schedule-calendar.container.jsx | 6 +- .../schedule-day-view.container.jsx | 16 +- .../schedule-job-modal.component.jsx | 14 +- .../schedule-job-modal.container.jsx | 7 +- .../schedule-manual-event.component.jsx | 4 +- .../schedule-verify-integrity.component.jsx | 4 +- .../scoreboard-chart.component.jsx | 4 +- .../scoreboard-day-stats.component.jsx | 4 +- .../scoreboard-display.component.jsx | 18 +- .../scoreboard-last-days.component.jsx | 5 +- .../scoreboard-targets-table.component.jsx | 8 +- .../scoreboard-targets-table.util.js | 30 +- .../scoreboard-timetickets.component.jsx | 46 +-- ...scoreboard-timetickets.stats.component.jsx | 54 +-- ...rd-timetickets.targets-table.component.jsx | 50 +-- .../scoreboard-timetickets.component.jsx | 32 +- .../shop-employees-add-vacation.component.jsx | 4 +- .../shop-employees-form.component.jsx | 4 +- .../shop-info/shop-info.container.jsx | 14 +- .../shop-info/shop-info.general.component.jsx | 4 +- .../tech-job-clock-in-form.container.jsx | 12 +- .../tech-job-print-tickets.component.jsx | 10 +- .../tech-job-statistics.component.jsx | 10 +- .../time-tickets-dates-selector.component.jsx | 6 +- .../time-ticket-list.component.jsx | 6 +- .../time-ticket-modal.component.jsx | 1 + .../time-ticket-modal.container.jsx | 4 +- .../time-ticket-shift-form.container.jsx | 12 +- ...ime-tickets-attendance-table.component.jsx | 6 +- .../time-tickets-payroll-table.component.jsx | 6 +- ...me-tickets-summary-employees.component.jsx | 6 +- .../vehicle-detail-form.container.jsx | 4 +- .../contract-detail.page.container.jsx | 12 +- .../courtesy-car-detail.page.container.jsx | 16 +- .../jobs-checklist-view.page.jsx | 4 +- .../pages/jobs-close/jobs-close.component.jsx | 28 +- .../jobs-detail.page.component.jsx | 8 +- .../time-tickets/time-tickets.container.jsx | 8 +- .../redux/application/application.sagas.js | 24 +- client/src/redux/user/user.sagas.js | 2 +- client/src/utils/DateFormatter.jsx | 12 +- client/src/utils/DatePickerRanges.js | 32 +- client/src/utils/RenderTemplate.js | 2 +- client/src/utils/day.js | 15 + 97 files changed, 772 insertions(+), 592 deletions(-) create mode 100644 client/src/utils/day.js diff --git a/client/craco.config.js b/client/craco.config.js index 360fbee07..26baf618b 100644 --- a/client/craco.config.js +++ b/client/craco.config.js @@ -4,9 +4,6 @@ const CracoLessPlugin = require("craco-less"); const SentryWebpackPlugin = require("@sentry/webpack-plugin"); const {convertLegacyToken} = require('@ant-design/compatible/lib'); const {theme} = require('antd/lib'); -const {getLoader, loaderByName} = require("@craco/craco"); -const AntdMomentWebpackPlugin = require("@ant-design/moment-webpack-plugin"); -const {writeFile} = require("fs"); const {defaultAlgorithm, defaultSeed} = theme; @@ -38,6 +35,7 @@ module.exports = { lessOptions: { modifyVars: { ...v4Token, + // TODO: This will no longer work in AntD 5.0 ...(process.env.NODE_ENV === "development" ? {"colorPrimary": "#a51d1d"} : { @@ -66,7 +64,6 @@ module.exports = { ], webpack: { configure: (webpackConfig) => { - // config.plugins.push(new AntdMomentWebpackPlugin()); return { ...webpackConfig, // Required for Dev Server diff --git a/client/package-lock.json b/client/package-lock.json index 0adf1faf3..607336ebb 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -15,14 +15,16 @@ "@craco/craco": "^7.1.0", "@fingerprintjs/fingerprintjs": "^4.2.1", "@jsreport/browser-client": "^3.1.0", - "@sentry/react": "^7.86.0", - "@sentry/tracing": "^7.86.0", + "@sentry/react": "^7.87.0", + "@sentry/tracing": "^7.87.0", "@splitsoftware/splitio-react": "^1.10.2", "@tanem/react-nprogress": "^5.0.51", "antd": "^5.12.2", "apollo-link-logger": "^2.0.1", "axios": "^1.3.6", "craco-less": "^3.0.1", + "dayjs": "^1.11.10", + "dayjs-business-days2": "^1.2.2", "dinero.js": "^1.9.1", "dotenv": "^16.3.1", "enquire-js": "^0.2.1", @@ -37,8 +39,6 @@ "libphonenumber-js": "^1.10.51", "logrocket": "^7.0.0", "markerjs2": "^2.31.4", - "moment-business-days": "^1.2.0", - "moment-timezone": "^0.5.43", "normalize-url": "^8.0.0", "phone": "^3.1.41", "preval.macro": "^5.0.0", @@ -61,7 +61,7 @@ "react-number-format": "^5.1.4", "react-redux": "^9.0.4", "react-resizable": "^3.0.5", - "react-router-dom": "^6.20.1", + "react-router-dom": "^6.21.0", "react-scripts": "^5.0.1", "react-sticky": "^6.0.3", "react-sublime-video": "^0.2.5", @@ -93,7 +93,6 @@ "yauzl": "^2.10.0" }, "devDependencies": { - "@ant-design/moment-webpack-plugin": "^0.0.4", "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@sentry/webpack-plugin": "^2.10.2", "@testing-library/cypress": "^10.0.1", @@ -162,11 +161,6 @@ "react-dom": ">=16.0.0" } }, - "node_modules/@ant-design/compatible/node_modules/dayjs": { - "version": "1.11.10", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", - "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" - }, "node_modules/@ant-design/css-animation": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/@ant-design/css-animation/-/css-animation-1.7.3.tgz", @@ -214,12 +208,6 @@ "resolved": "https://registry.npmjs.org/@ant-design/icons-svg/-/icons-svg-4.3.1.tgz", "integrity": "sha512-4QBZg8ccyC6LPIRii7A0bZUk3+lEDCLnhB+FVsflGdcWPPmV+j3fire4AwwoqHV/BibgvBmR9ZIo4s867smv+g==" }, - "node_modules/@ant-design/moment-webpack-plugin": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/@ant-design/moment-webpack-plugin/-/moment-webpack-plugin-0.0.4.tgz", - "integrity": "sha512-qZe5lakKA9DhyEzmv8gJ8xgDSaVYQG5YuHdxSbXIkrT7L0kTgfuVBBLuPJAqmBBgjW/x3QIlM/Hsd5T6/4GHVw==", - "dev": true - }, "node_modules/@ant-design/pro-layout": { "version": "7.17.16", "resolved": "https://registry.npmjs.org/@ant-design/pro-layout/-/pro-layout-7.17.16.tgz", @@ -284,11 +272,6 @@ "react-dom": ">=17.0.0" } }, - "node_modules/@ant-design/pro-utils/node_modules/dayjs": { - "version": "1.11.10", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", - "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" - }, "node_modules/@ant-design/react-slick": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@ant-design/react-slick/-/react-slick-1.0.2.tgz", @@ -4390,9 +4373,9 @@ "integrity": "sha512-1dgmkh+3so0+LlBWRhGA33ua4MYr7tUOj+a9Si28vUi0IUFNbff1T3sgpeDJI/LaC75bBYnQ0A3wXjn0OrRNBA==" }, "node_modules/@remix-run/router": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.13.1.tgz", - "integrity": "sha512-so+DHzZKsoOcoXrILB4rqDkMDy7NLMErRdOxvzvOKb507YINKUP4Di+shbTZDhSE/pBZ+vr7XGIpcOO0VLSA+Q==", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.14.0.tgz", + "integrity": "sha512-WOHih+ClN7N8oHk9N4JUiMxQJmRVaOxcg8w7F/oHUXzJt920ekASLI/7cYX8XkntDWRhLZtsk6LbGrkgOAvi5A==", "engines": { "node": ">=14.0.0" } @@ -4496,22 +4479,54 @@ "integrity": "sha512-2/U3GXA6YiPYQDLGwtGlnNgKYBSwCFIHf8Y9LUY5VATHdtbLlU0Y1R3QoBnT0aB4qv/BEiVVsj7LJXoQCgJ2vA==" }, "node_modules/@sentry-internal/feedback": { - "version": "7.86.0", - "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-7.86.0.tgz", - "integrity": "sha512-6rl0JYjmAKnhm4/fuFaROh4Ht8oi9f6ZeIcViCuGJcrGICZJJY0s+R77XJI78rNa82PYFrSCcnWXcGji4T8E7g==", + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-7.87.0.tgz", + "integrity": "sha512-31nvAvcchoBQJoZSxAaMh6FOLIoZEbTOGutiMTPzPLhL4bQF4fNl20Bc/mRD1IL/L7hyKsIl2ahxKjo1ZFbPfg==", "dependencies": { - "@sentry/core": "7.86.0", - "@sentry/types": "7.86.0", - "@sentry/utils": "7.86.0" + "@sentry/core": "7.87.0", + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" }, "engines": { "node": ">=12" } }, + "node_modules/@sentry-internal/feedback/node_modules/@sentry/core": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.87.0.tgz", + "integrity": "sha512-jkoXqK/nuYh8DYS+n7uaSuSIdw4HJemyRkXsWjAEPtEgD7taGMafZGbP5pl+XE38SE59jTBxmKnkUEZOFMgZGA==", + "dependencies": { + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry-internal/feedback/node_modules/@sentry/types": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.87.0.tgz", + "integrity": "sha512-w8jKFHq/Llupmr2FezmFgQsnm3y/CnqLjb7s6PstI78E409wrhH7p7oqX/OEuzccH1qNCNwes/3QKvPTRQDB4Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry-internal/feedback/node_modules/@sentry/utils": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.87.0.tgz", + "integrity": "sha512-7xgtPTnTNP/4IznFMFXxltuaXfLvzznrYCDMv9ny8EeUjJqlLX3CVA8Qq3YALsLCQCKcrGRARbAcd/EGG//w2w==", + "dependencies": { + "@sentry/types": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@sentry-internal/tracing": { "version": "7.86.0", "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.86.0.tgz", "integrity": "sha512-b4dUsNWlPWRwakGwR7bhOkqiFlqQszH1hhVFwrm/8s3kqEBZ+E4CeIfCvuHBHQ1cM/fx55xpXX/BU163cy+3iQ==", + "dev": true, "dependencies": { "@sentry/core": "7.86.0", "@sentry/types": "7.86.0", @@ -4522,16 +4537,60 @@ } }, "node_modules/@sentry/browser": { - "version": "7.86.0", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.86.0.tgz", - "integrity": "sha512-nfYWpVOmug+W7KJO7/xhA1JScMZcYHcoOVHLsUFm4znx51U4qZEk+zZDM11Q2Nw6MuDyEYg6bsH1QCwaoC6nLw==", + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.87.0.tgz", + "integrity": "sha512-+WVqIns2ZFF/tsjNf90Km3eIKUd6lGQSsBQ+cVa05v0ebMr5OtnOkKlOHN4CJZ0gT0lyDnNHoys9Af6edIbE1Q==", "dependencies": { - "@sentry-internal/feedback": "7.86.0", - "@sentry-internal/tracing": "7.86.0", - "@sentry/core": "7.86.0", - "@sentry/replay": "7.86.0", - "@sentry/types": "7.86.0", - "@sentry/utils": "7.86.0" + "@sentry-internal/feedback": "7.87.0", + "@sentry-internal/tracing": "7.87.0", + "@sentry/core": "7.87.0", + "@sentry/replay": "7.87.0", + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/browser/node_modules/@sentry-internal/tracing": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.87.0.tgz", + "integrity": "sha512-HYa0+rfFmYQ/DadXoiuarTSxrcnYDCd/fm0pFuOHjICtfja8IcLegVYP2/r3CgwB+IjquCtJ5kDcqS/NTgUcpA==", + "dependencies": { + "@sentry/core": "7.87.0", + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/browser/node_modules/@sentry/core": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.87.0.tgz", + "integrity": "sha512-jkoXqK/nuYh8DYS+n7uaSuSIdw4HJemyRkXsWjAEPtEgD7taGMafZGbP5pl+XE38SE59jTBxmKnkUEZOFMgZGA==", + "dependencies": { + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/browser/node_modules/@sentry/types": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.87.0.tgz", + "integrity": "sha512-w8jKFHq/Llupmr2FezmFgQsnm3y/CnqLjb7s6PstI78E409wrhH7p7oqX/OEuzccH1qNCNwes/3QKvPTRQDB4Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/browser/node_modules/@sentry/utils": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.87.0.tgz", + "integrity": "sha512-7xgtPTnTNP/4IznFMFXxltuaXfLvzznrYCDMv9ny8EeUjJqlLX3CVA8Qq3YALsLCQCKcrGRARbAcd/EGG//w2w==", + "dependencies": { + "@sentry/types": "7.87.0" }, "engines": { "node": ">=8" @@ -4703,6 +4762,7 @@ "version": "7.86.0", "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.86.0.tgz", "integrity": "sha512-SbLvqd1bRYzhDS42u7GMnmbDMfth/zRiLElQWbLK/shmuZzTcfQSwNNdF4Yj+VfjOkqPFgGmICHSHVUc9dh01g==", + "dev": true, "dependencies": { "@sentry/types": "7.86.0", "@sentry/utils": "7.86.0" @@ -4728,13 +4788,13 @@ } }, "node_modules/@sentry/react": { - "version": "7.86.0", - "resolved": "https://registry.npmjs.org/@sentry/react/-/react-7.86.0.tgz", - "integrity": "sha512-2bHi+YcG4cT+4xHXXzv+AZpU3pdPUlDBorSgHOpa9At4yxr17UWW2f8bP9wPYRgj+NEIM3YhDgR46FlBu9GSKg==", + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/react/-/react-7.87.0.tgz", + "integrity": "sha512-37O4Tr7Ij1T6B3eAKrlsLCkxjW+euHDRaDjjuD0gxYEyf4Tr+kx6x7s3x9wXZpkkehJCTCOflDSvYM7qH4uRFA==", "dependencies": { - "@sentry/browser": "7.86.0", - "@sentry/types": "7.86.0", - "@sentry/utils": "7.86.0", + "@sentry/browser": "7.87.0", + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0", "hoist-non-react-statics": "^3.3.2" }, "engines": { @@ -4744,26 +4804,133 @@ "react": "15.x || 16.x || 17.x || 18.x" } }, - "node_modules/@sentry/replay": { - "version": "7.86.0", - "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.86.0.tgz", - "integrity": "sha512-YYZO8bfQSx1H87Te/zzyHPLHvExWiYwUfMWW68yGX+PPZIIzxaM81/iCQHkoucxlvuPCOtxCgf7RSMbsnqEa8g==", + "node_modules/@sentry/react/node_modules/@sentry/types": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.87.0.tgz", + "integrity": "sha512-w8jKFHq/Llupmr2FezmFgQsnm3y/CnqLjb7s6PstI78E409wrhH7p7oqX/OEuzccH1qNCNwes/3QKvPTRQDB4Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/react/node_modules/@sentry/utils": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.87.0.tgz", + "integrity": "sha512-7xgtPTnTNP/4IznFMFXxltuaXfLvzznrYCDMv9ny8EeUjJqlLX3CVA8Qq3YALsLCQCKcrGRARbAcd/EGG//w2w==", "dependencies": { - "@sentry-internal/tracing": "7.86.0", - "@sentry/core": "7.86.0", - "@sentry/types": "7.86.0", - "@sentry/utils": "7.86.0" + "@sentry/types": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/replay": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.87.0.tgz", + "integrity": "sha512-QinY5uYARRkZsdInNy8cFY4p/H697DutRdpWEIi/v7hsOiRVRxIVZ3n8dJxVIpPbVQ9upI19s/J3bb4mSERLSg==", + "dependencies": { + "@sentry-internal/tracing": "7.87.0", + "@sentry/core": "7.87.0", + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" }, "engines": { "node": ">=12" } }, - "node_modules/@sentry/tracing": { - "version": "7.86.0", - "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-7.86.0.tgz", - "integrity": "sha512-WPqgmbLm6ntpIoTZd1L/RHIVEDMmvVjIDxKeXGiJeXHZG2VMtgwoxuZAFluVFaD0Sr20Nhj+ZS7HvKOWTxrjjA==", + "node_modules/@sentry/replay/node_modules/@sentry-internal/tracing": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.87.0.tgz", + "integrity": "sha512-HYa0+rfFmYQ/DadXoiuarTSxrcnYDCd/fm0pFuOHjICtfja8IcLegVYP2/r3CgwB+IjquCtJ5kDcqS/NTgUcpA==", "dependencies": { - "@sentry-internal/tracing": "7.86.0" + "@sentry/core": "7.87.0", + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/replay/node_modules/@sentry/core": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.87.0.tgz", + "integrity": "sha512-jkoXqK/nuYh8DYS+n7uaSuSIdw4HJemyRkXsWjAEPtEgD7taGMafZGbP5pl+XE38SE59jTBxmKnkUEZOFMgZGA==", + "dependencies": { + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/replay/node_modules/@sentry/types": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.87.0.tgz", + "integrity": "sha512-w8jKFHq/Llupmr2FezmFgQsnm3y/CnqLjb7s6PstI78E409wrhH7p7oqX/OEuzccH1qNCNwes/3QKvPTRQDB4Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/replay/node_modules/@sentry/utils": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.87.0.tgz", + "integrity": "sha512-7xgtPTnTNP/4IznFMFXxltuaXfLvzznrYCDMv9ny8EeUjJqlLX3CVA8Qq3YALsLCQCKcrGRARbAcd/EGG//w2w==", + "dependencies": { + "@sentry/types": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/tracing": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-7.87.0.tgz", + "integrity": "sha512-oEj4wo5K9WSyYgMInM/DA5DToS0F/dz2PNe5dkhIdEkMGTarSvLm7DIo3L44NfYUtj4DrKyMM61vXHNIeQitVg==", + "dependencies": { + "@sentry-internal/tracing": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/tracing/node_modules/@sentry-internal/tracing": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.87.0.tgz", + "integrity": "sha512-HYa0+rfFmYQ/DadXoiuarTSxrcnYDCd/fm0pFuOHjICtfja8IcLegVYP2/r3CgwB+IjquCtJ5kDcqS/NTgUcpA==", + "dependencies": { + "@sentry/core": "7.87.0", + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/tracing/node_modules/@sentry/core": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.87.0.tgz", + "integrity": "sha512-jkoXqK/nuYh8DYS+n7uaSuSIdw4HJemyRkXsWjAEPtEgD7taGMafZGbP5pl+XE38SE59jTBxmKnkUEZOFMgZGA==", + "dependencies": { + "@sentry/types": "7.87.0", + "@sentry/utils": "7.87.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/tracing/node_modules/@sentry/types": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.87.0.tgz", + "integrity": "sha512-w8jKFHq/Llupmr2FezmFgQsnm3y/CnqLjb7s6PstI78E409wrhH7p7oqX/OEuzccH1qNCNwes/3QKvPTRQDB4Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/tracing/node_modules/@sentry/utils": { + "version": "7.87.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.87.0.tgz", + "integrity": "sha512-7xgtPTnTNP/4IznFMFXxltuaXfLvzznrYCDMv9ny8EeUjJqlLX3CVA8Qq3YALsLCQCKcrGRARbAcd/EGG//w2w==", + "dependencies": { + "@sentry/types": "7.87.0" }, "engines": { "node": ">=8" @@ -4773,6 +4940,7 @@ "version": "7.86.0", "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.86.0.tgz", "integrity": "sha512-pGAt0+bMfWgo0KG2epthfNV4Wae03tURpoxNjGo5Fr4cXxvLTSijSAQ6rmmO4bXBJ7+rErEjX30g30o/eEdP9g==", + "dev": true, "engines": { "node": ">=8" } @@ -4781,6 +4949,7 @@ "version": "7.86.0", "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.86.0.tgz", "integrity": "sha512-6PejFtw9VTFFy5vu0ks+U7Ozkqz+eMt+HN8AZKBKErYzX5/xs0kpkOcSRpu3ETdTYcZf8VAmLVgFgE2BE+3WuQ==", + "dev": true, "dependencies": { "@sentry/types": "7.86.0" }, @@ -6404,11 +6573,6 @@ "react-dom": ">=16.9.0" } }, - "node_modules/antd/node_modules/dayjs": { - "version": "1.11.10", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", - "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" - }, "node_modules/any-promise": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", @@ -8582,12 +8746,6 @@ "undici-types": "~5.26.4" } }, - "node_modules/cypress/node_modules/dayjs": { - "version": "1.11.10", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", - "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==", - "dev": true - }, "node_modules/cypress/node_modules/proxy-from-env": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", @@ -8799,6 +8957,19 @@ "resolved": "https://registry.npmjs.org/date-arithmetic/-/date-arithmetic-4.1.0.tgz", "integrity": "sha512-QWxYLR5P/6GStZcdem+V1xoto6DMadYWpMXU82ES3/RfR3Wdwr3D0+be7mgOJ+Ov0G9D5Dmb9T17sNLQYj9XOg==" }, + "node_modules/dayjs": { + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" + }, + "node_modules/dayjs-business-days2": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/dayjs-business-days2/-/dayjs-business-days2-1.2.2.tgz", + "integrity": "sha512-tYwNKeMxuNEpGw2k5j/KTcH0c1lV+41wfqkTN21OvP2hwZFnpM4dH2biaOI2gElRmJOQQxkKByuH5bZPlea/Jg==", + "dependencies": { + "dayjs": "^1.11.10" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -14781,14 +14952,6 @@ "node": "*" } }, - "node_modules/moment-business-days": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/moment-business-days/-/moment-business-days-1.2.0.tgz", - "integrity": "sha512-QJlceLfMSxy/jZSOgJYCKeKw+qGYHj8W0jMa/fYruyoJ85+bJuLRiYv5DIaflyuRipmYRfD4kDlSwVYteLN+Jw==", - "peerDependencies": { - "moment": "2.x.x" - } - }, "node_modules/moment-timezone": { "version": "0.5.43", "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz", @@ -17954,11 +18117,6 @@ "react-dom": "^16.14.0 || ^17 || ^18" } }, - "node_modules/react-big-calendar/node_modules/dayjs": { - "version": "1.11.10", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", - "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" - }, "node_modules/react-big-calendar/node_modules/memoize-one": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz", @@ -18276,11 +18434,11 @@ } }, "node_modules/react-router": { - "version": "6.20.1", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.20.1.tgz", - "integrity": "sha512-ccvLrB4QeT5DlaxSFFYi/KR8UMQ4fcD8zBcR71Zp1kaYTC5oJKYAp1cbavzGrogwxca+ubjkd7XjFZKBW8CxPA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.21.0.tgz", + "integrity": "sha512-hGZ0HXbwz3zw52pLZV3j3+ec+m/PQ9cTpBvqjFQmy2XVUWGn5MD+31oXHb6dVTxYzmAeaiUBYjkoNz66n3RGCg==", "dependencies": { - "@remix-run/router": "1.13.1" + "@remix-run/router": "1.14.0" }, "engines": { "node": ">=14.0.0" @@ -18290,12 +18448,12 @@ } }, "node_modules/react-router-dom": { - "version": "6.20.1", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.20.1.tgz", - "integrity": "sha512-npzfPWcxfQN35psS7rJgi/EW0Gx6EsNjfdJSAk73U/HqMEJZ2k/8puxfwHFgDQhBGmS3+sjnGbMdMSV45axPQw==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.21.0.tgz", + "integrity": "sha512-1dUdVj3cwc1npzJaf23gulB562ESNvxf7E4x8upNJycqyUm5BRRZ6dd3LrlzhtLaMrwOCO8R0zoiYxdaJx4LlQ==", "dependencies": { - "@remix-run/router": "1.13.1", - "react-router": "6.20.1" + "@remix-run/router": "1.14.0", + "react-router": "6.21.0" }, "engines": { "node": ">=14.0.0" diff --git a/client/package.json b/client/package.json index 2fb97a03d..4ae94595f 100644 --- a/client/package.json +++ b/client/package.json @@ -11,14 +11,16 @@ "@craco/craco": "^7.1.0", "@fingerprintjs/fingerprintjs": "^4.2.1", "@jsreport/browser-client": "^3.1.0", - "@sentry/react": "^7.86.0", - "@sentry/tracing": "^7.86.0", + "@sentry/react": "^7.87.0", + "@sentry/tracing": "^7.87.0", "@splitsoftware/splitio-react": "^1.10.2", "@tanem/react-nprogress": "^5.0.51", "antd": "^5.12.2", "apollo-link-logger": "^2.0.1", "axios": "^1.3.6", "craco-less": "^3.0.1", + "dayjs": "^1.11.10", + "dayjs-business-days2": "^1.2.2", "dinero.js": "^1.9.1", "dotenv": "^16.3.1", "enquire-js": "^0.2.1", @@ -33,8 +35,6 @@ "libphonenumber-js": "^1.10.51", "logrocket": "^7.0.0", "markerjs2": "^2.31.4", - "moment-business-days": "^1.2.0", - "moment-timezone": "^0.5.43", "normalize-url": "^8.0.0", "phone": "^3.1.41", "preval.macro": "^5.0.0", @@ -57,7 +57,7 @@ "react-number-format": "^5.1.4", "react-redux": "^9.0.4", "react-resizable": "^3.0.5", - "react-router-dom": "^6.20.1", + "react-router-dom": "^6.21.0", "react-scripts": "^5.0.1", "react-sticky": "^6.0.3", "react-sublime-video": "^0.2.5", @@ -122,7 +122,6 @@ "react-error-overlay": "6.0.9" }, "devDependencies": { - "@ant-design/moment-webpack-plugin": "^0.0.4", "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@sentry/webpack-plugin": "^2.10.2", "@testing-library/cypress": "^10.0.1", diff --git a/client/src/App/App.container.jsx b/client/src/App/App.container.jsx index 74f6ba4df..31d86fd5f 100644 --- a/client/src/App/App.container.jsx +++ b/client/src/App/App.container.jsx @@ -2,14 +2,15 @@ import { ApolloProvider } from "@apollo/client"; import { SplitFactory, SplitSdk } from "@splitsoftware/splitio-react"; import { ConfigProvider } from "antd"; import enLocale from "antd/es/locale/en_US"; -import moment from "moment"; +import dayjs from "../utils/day"; +import 'dayjs/locale/en'; import React from "react"; import { useTranslation } from "react-i18next"; import GlobalLoadingBar from "../components/global-loading-bar/global-loading-bar.component"; import client from "../utils/GraphQLClient"; import App from "./App"; -moment.locale("en-US"); +dayjs.locale("en"); export const factory = SplitSdk({ core: { diff --git a/client/src/components/bill-detail-edit/bill-detail-edit-component.jsx b/client/src/components/bill-detail-edit/bill-detail-edit-component.jsx index 28458c9db..17dac6a24 100644 --- a/client/src/components/bill-detail-edit/bill-detail-edit-component.jsx +++ b/client/src/components/bill-detail-edit/bill-detail-edit-component.jsx @@ -1,6 +1,6 @@ import {useMutation, useQuery} from "@apollo/client"; import {Button, Form, Popconfirm, Space} from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import queryString from "query-string"; import React, {useState} from "react"; import {useTranslation} from "react-i18next"; @@ -240,7 +240,7 @@ const transformData = (data) => { }, }; }), - date: data.bills_by_pk ? moment(data.bills_by_pk.date) : null, + date: data.bills_by_pk ? dayjs(data.bills_by_pk.date) : null, } : {}; }; diff --git a/client/src/components/bill-form/bill-form.component.jsx b/client/src/components/bill-form/bill-form.component.jsx index 44b8cd815..3d805fe11 100644 --- a/client/src/components/bill-form/bill-form.component.jsx +++ b/client/src/components/bill-form/bill-form.component.jsx @@ -12,7 +12,7 @@ import { Switch, Upload, } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { MdOpenInNew } from "react-icons/md"; @@ -274,17 +274,17 @@ export function BillFormComponent({ bodyshop.accountingconfig.ClosingPeriod ) { if ( - moment(value) + dayjs(value) .startOf("day") .isSameOrAfter( - moment( + dayjs( bodyshop.accountingconfig.ClosingPeriod[0] ).startOf("day") ) && - moment(value) + dayjs(value) .startOf("day") .isSameOrBefore( - moment( + dayjs( bodyshop.accountingconfig.ClosingPeriod[1] ).endOf("day") ) diff --git a/client/src/components/billline-add-inventory/billline-add-inventory.component.jsx b/client/src/components/billline-add-inventory/billline-add-inventory.component.jsx index 08495d3bb..09b7978a0 100644 --- a/client/src/components/billline-add-inventory/billline-add-inventory.component.jsx +++ b/client/src/components/billline-add-inventory/billline-add-inventory.component.jsx @@ -2,7 +2,7 @@ import { FileAddFilled } from "@ant-design/icons"; import { useMutation } from "@apollo/client"; import { Button, notification, Tooltip } from "antd"; import { t } from "i18next"; -import moment from "moment"; +import dayjs from "./../../utils/day"; import React, { useState } from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -49,7 +49,7 @@ export function BilllineAddInventory({ jobid: jobid, isinhouse: true, is_credit_memo: true, - date: moment().format("YYYY-MM-DD"), + date: dayjs().format("YYYY-MM-DD"), federal_tax_rate: bodyshop.bill_tax_rates.federal_tax_rate, state_tax_rate: bodyshop.bill_tax_rates.state_tax_rate, local_tax_rate: bodyshop.bill_tax_rates.local_tax_rate, @@ -91,7 +91,7 @@ export function BilllineAddInventory({ pol: { returnfrombill: billid, vendorid: bodyshop.inhousevendorid, - deliver_by: moment().format("YYYY-MM-DD"), + deliver_by: dayjs().format("YYYY-MM-DD"), parts_order_lines: { data: [ { diff --git a/client/src/components/card-payment-modal/card-payment-modal.component..jsx b/client/src/components/card-payment-modal/card-payment-modal.component..jsx index 071e2a758..bfad6bbbe 100644 --- a/client/src/components/card-payment-modal/card-payment-modal.component..jsx +++ b/client/src/components/card-payment-modal/card-payment-modal.component..jsx @@ -13,7 +13,7 @@ import { notification, } from "antd"; import axios from "axios"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -117,7 +117,7 @@ const CardPaymentModalComponent = ({ payer: t("payments.labels.customer"), type: values.paymentResponse.cardbrand, jobid: payment.jobid, - date: moment(Date.now()), + date: dayjs(Date.now()), payment_responses: { data: [ { diff --git a/client/src/components/chat-messages-list/chat-message-list.component.jsx b/client/src/components/chat-messages-list/chat-message-list.component.jsx index d6460a89d..ff73794ee 100644 --- a/client/src/components/chat-messages-list/chat-message-list.component.jsx +++ b/client/src/components/chat-messages-list/chat-message-list.component.jsx @@ -1,7 +1,7 @@ import Icon from "@ant-design/icons"; import { Tooltip } from "antd"; import i18n from "i18next"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useRef } from "react"; import { MdDone, MdDoneAll } from "react-icons/md"; import { @@ -52,7 +52,7 @@ export default function ChatMessageListComponent({ messages }) {
{i18n.t("messaging.labels.sentby", { by: messages[index].userid, - time: moment(messages[index].created_at).format( + time: dayjs(messages[index].created_at).format( "MM/DD/YYYY @ hh:mm a" ), })} diff --git a/client/src/components/contract-cars/contract-cars.container.jsx b/client/src/components/contract-cars/contract-cars.container.jsx index bc1421c27..68633c51b 100644 --- a/client/src/components/contract-cars/contract-cars.container.jsx +++ b/client/src/components/contract-cars/contract-cars.container.jsx @@ -1,5 +1,5 @@ import { useQuery } from "@apollo/client"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React from "react"; import { QUERY_AVAILABLE_CC } from "../../graphql/courtesy-car.queries"; import AlertComponent from "../alert/alert.component"; @@ -7,7 +7,7 @@ import ContractCarsComponent from "./contract-cars.component"; export default function ContractCarsContainer({ selectedCarState, form }) { const { loading, error, data } = useQuery(QUERY_AVAILABLE_CC, { - variables: { today: moment().format("YYYY-MM-DD") }, + variables: { today: dayjs().format("YYYY-MM-DD") }, fetchPolicy: "network-only", nextFetchPolicy: "network-only", }); diff --git a/client/src/components/contract-convert-to-ro/contract-convert-to-ro.component.jsx b/client/src/components/contract-convert-to-ro/contract-convert-to-ro.component.jsx index c9f401659..63d0472b7 100644 --- a/client/src/components/contract-convert-to-ro/contract-convert-to-ro.component.jsx +++ b/client/src/components/contract-convert-to-ro/contract-convert-to-ro.component.jsx @@ -10,7 +10,7 @@ import { Space, } from "antd"; import axios from "axios"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -46,8 +46,8 @@ export function ContractConvertToRo({ const handleFinish = async (values) => { setLoading(true); - const contractLength = moment(contract.actualreturn).diff( - moment(contract.start), + const contractLength = dayjs(contract.actualreturn).diff( + dayjs(contract.start), "days" ); const billingLines = []; diff --git a/client/src/components/contract-form/contract-form.component.jsx b/client/src/components/contract-form/contract-form.component.jsx index f41933625..3536db602 100644 --- a/client/src/components/contract-form/contract-form.component.jsx +++ b/client/src/components/contract-form/contract-form.component.jsx @@ -1,6 +1,6 @@ import { WarningFilled } from "@ant-design/icons"; import { Form, Input, InputNumber, Space } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React from "react"; import { useTranslation } from "react-i18next"; import { DateFormatter } from "../../utils/DateFormatter"; @@ -96,8 +96,8 @@ export default function ContractFormComponent({ const dueForService = selectedCar && selectedCar.nextservicedate && - moment(selectedCar.nextservicedate).isBefore( - moment(form.getFieldValue("scheduledreturn")) + dayjs(selectedCar.nextservicedate).isBefore( + dayjs(form.getFieldValue("scheduledreturn")) ); if (mileageOver || dueForService) @@ -190,9 +190,9 @@ export default function ContractFormComponent({ } > {() => { - const dlExpiresBeforeReturn = moment( + const dlExpiresBeforeReturn = dayjs( form.getFieldValue("driver_dlexpiry") - ).isBefore(moment(form.getFieldValue("scheduledreturn"))); + ).isBefore(dayjs(form.getFieldValue("scheduledreturn"))); return (
diff --git a/client/src/components/contract-license-decode-button/contract-license-decode-button.component.jsx b/client/src/components/contract-license-decode-button/contract-license-decode-button.component.jsx index fb635c783..2e158c435 100644 --- a/client/src/components/contract-license-decode-button/contract-license-decode-button.component.jsx +++ b/client/src/components/contract-license-decode-button/contract-license-decode-button.component.jsx @@ -1,5 +1,5 @@ import { Button, Input, Modal, Typography } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import aamva from "../../utils/aamva"; @@ -26,8 +26,8 @@ export default function ContractLicenseDecodeButton({ form }) { const values = { driver_dlnumber: decodedBarcode.dl, - driver_dlexpiry: moment( - `20${decodedBarcode.expiration_date}${moment( + driver_dlexpiry: dayjs( + `20${decodedBarcode.expiration_date}${dayjs( decodedBarcode.birthday ).format("DD")}` ), @@ -38,7 +38,7 @@ export default function ContractLicenseDecodeButton({ form }) { driver_city: decodedBarcode.city, driver_state: decodedBarcode.state, driver_zip: decodedBarcode.postal_code, - driver_dob: moment(decodedBarcode.birthday), + driver_dob: dayjs(decodedBarcode.birthday), }; form.setFieldsValue(values); @@ -94,14 +94,14 @@ export default function ContractLicenseDecodeButton({ form }) { {decodedBarcode.address} - {moment( - `20${decodedBarcode.expiration_date}${moment( + {dayjs( + `20${decodedBarcode.expiration_date}${dayjs( decodedBarcode.birthday ).format("DD")}` ).format("MM/DD/YYYY")} - {moment(decodedBarcode.birthday).format("MM/DD/YYYY")} + {dayjs(decodedBarcode.birthday).format("MM/DD/YYYY")}
diff --git a/client/src/components/contracts-list/contracts-list.component.jsx b/client/src/components/contracts-list/contracts-list.component.jsx index db7d9aec7..d309d9118 100644 --- a/client/src/components/contracts-list/contracts-list.component.jsx +++ b/client/src/components/contracts-list/contracts-list.component.jsx @@ -9,7 +9,7 @@ import { DateTimeFormatter } from "../../utils/DateFormatter"; import { alphaSort } from "../../utils/sorters"; import ContractsFindModalContainer from "../contracts-find-modal/contracts-find-modal.container"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; @@ -152,8 +152,8 @@ export function ContractsList({ render: (text, record) => (record.actualreturn && record.start && - `${moment(record.actualreturn) - .diff(moment(record.start), "days", true) + `${dayjs(record.actualreturn) + .diff(dayjs(record.start), "days", true) .toFixed(1)} days`) || "", }, diff --git a/client/src/components/courtesy-car-form/courtesy-car-form.component.jsx b/client/src/components/courtesy-car-form/courtesy-car-form.component.jsx index 378e618ac..fbc163c32 100644 --- a/client/src/components/courtesy-car-form/courtesy-car-form.component.jsx +++ b/client/src/components/courtesy-car-form/courtesy-car-form.component.jsx @@ -2,7 +2,7 @@ import { WarningFilled } from "@ant-design/icons"; import { useApolloClient } from "@apollo/client"; import { Button, Form, Input, InputNumber, Space } from "antd"; import {PageHeader} from "@ant-design/pro-layout"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React from "react"; import { useTranslation } from "react-i18next"; import { CHECK_CC_FLEET_NUMBER } from "../../graphql/courtesy-car.queries"; @@ -259,7 +259,7 @@ export default function CourtesyCarCreateFormComponent({ form, saveLoading }) { const nextservicedate = form.getFieldValue("nextservicedate"); const dueForService = nextservicedate && - moment(nextservicedate).endOf("day").isSameOrBefore(moment()); + dayjs(nextservicedate).endOf("day").isSameOrBefore(dayjs()); if (dueForService) return ( @@ -300,7 +300,7 @@ export default function CourtesyCarCreateFormComponent({ form, saveLoading }) { const expires = form.getFieldValue("registrationexpires"); const dateover = - expires && moment(expires).endOf("day").isBefore(moment()); + expires && dayjs(expires).endOf("day").isBefore(dayjs()); if (dateover) return ( @@ -336,7 +336,7 @@ export default function CourtesyCarCreateFormComponent({ form, saveLoading }) { const expires = form.getFieldValue("insuranceexpires"); const dateover = - expires && moment(expires).endOf("day").isBefore(moment()); + expires && dayjs(expires).endOf("day").isBefore(dayjs()); if (dateover) return ( diff --git a/client/src/components/courtesy-car-return-modal/courtesy-car-return-modal.container.jsx b/client/src/components/courtesy-car-return-modal/courtesy-car-return-modal.container.jsx index ed98c4575..f4744c920 100644 --- a/client/src/components/courtesy-car-return-modal/courtesy-car-return-modal.container.jsx +++ b/client/src/components/courtesy-car-return-modal/courtesy-car-return-modal.container.jsx @@ -7,7 +7,7 @@ import { toggleModalVisible } from "../../redux/modals/modals.actions"; import { selectCourtesyCarReturn } from "../../redux/modals/modals.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors"; import CourtesyCarReturnModalComponent from "./courtesy-car-return-modal.component"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { RETURN_CONTRACT } from "../../graphql/cccontracts.queries"; import { useMutation } from "@apollo/client"; @@ -74,7 +74,7 @@ export function CCReturnModalContainer({
diff --git a/client/src/components/courtesy-cars-list/courtesy-cars-list.component.jsx b/client/src/components/courtesy-cars-list/courtesy-cars-list.component.jsx index ab85f95bc..1e145dade 100644 --- a/client/src/components/courtesy-cars-list/courtesy-cars-list.component.jsx +++ b/client/src/components/courtesy-cars-list/courtesy-cars-list.component.jsx @@ -9,7 +9,7 @@ import { Table, Tooltip, } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; @@ -77,7 +77,7 @@ export default function CourtesyCarsList({ loading, courtesycars, refetch }) { const mileageOver = nextservicekm <= mileage; const dueForService = - nextservicedate && moment(nextservicedate).isBefore(moment()); + nextservicedate && dayjs(nextservicedate).isBefore(dayjs()); return ( diff --git a/client/src/components/dashboard-components/monthly-employee-efficiency/monthly-employee-efficiency.component.jsx b/client/src/components/dashboard-components/monthly-employee-efficiency/monthly-employee-efficiency.component.jsx index c4aa9ec6b..f2056e515 100644 --- a/client/src/components/dashboard-components/monthly-employee-efficiency/monthly-employee-efficiency.component.jsx +++ b/client/src/components/dashboard-components/monthly-employee-efficiency/monthly-employee-efficiency.component.jsx @@ -1,6 +1,6 @@ import { Card } from "antd"; import _ from "lodash"; -import moment from "moment"; +import dayjs from "../../../utils/day"; import React from "react"; import { useTranslation } from "react-i18next"; import { @@ -27,7 +27,7 @@ export default function DashboardMonthlyEmployeeEfficiency({ return ; const ticketsByDate = _.groupBy(data.monthly_employee_efficiency, (item) => - moment(item.date).format("YYYY-MM-DD") + dayjs(item.date).format("YYYY-MM-DD") ); const listOfDays = Utils.ListOfDaysInCurrentMonth(); @@ -53,7 +53,7 @@ export default function DashboardMonthlyEmployeeEfficiency({ ((dailyHrs.productive - dailyHrs.actual) / dailyHrs.actual + 1) * 100; const theValue = { - date: moment(val).format("DD"), + date: dayjs(val).format("DD"), // ...dailyHrs, actual: dailyHrs.actual.toFixed(1), productive: dailyHrs.productive.toFixed(1), @@ -159,9 +159,9 @@ export default function DashboardMonthlyEmployeeEfficiency({ } export const DashboardMonthlyEmployeeEfficiencyGql = ` - monthly_employee_efficiency: timetickets(where: {_and: [{date: {_gte: "${moment() + monthly_employee_efficiency: timetickets(where: {_and: [{date: {_gte: "${dayjs() .startOf("month") - .format("YYYY-MM-DD")}"}},{date: {_lte: "${moment() + .format("YYYY-MM-DD")}"}},{date: {_lte: "${dayjs() .endOf("month") .format("YYYY-MM-DD")}"}} ]}) { actualhrs diff --git a/client/src/components/dashboard-components/monthly-revenue-graph/monthly-revenue-graph.component.jsx b/client/src/components/dashboard-components/monthly-revenue-graph/monthly-revenue-graph.component.jsx index 8c68e29e9..c3f7c2cd4 100644 --- a/client/src/components/dashboard-components/monthly-revenue-graph/monthly-revenue-graph.component.jsx +++ b/client/src/components/dashboard-components/monthly-revenue-graph/monthly-revenue-graph.component.jsx @@ -1,5 +1,5 @@ import { Card } from "antd"; -import moment from "moment"; +import dayjs from "../../../utils/day"; import React from "react"; import { useTranslation } from "react-i18next"; import _ from "lodash"; @@ -24,7 +24,7 @@ export default function DashboardMonthlyRevenueGraph({ data, ...cardProps }) { if (!data.monthly_sales) return ; const jobsByDate = _.groupBy(data.monthly_sales, (item) => - moment(item.date_invoiced).format("YYYY-MM-DD") + dayjs(item.date_invoiced).format("YYYY-MM-DD") ); const listOfDays = Utils.ListOfDaysInCurrentMonth(); @@ -43,7 +43,7 @@ export default function DashboardMonthlyRevenueGraph({ data, ...cardProps }) { } const theValue = { - date: moment(val).format("DD"), + date: dayjs(val).format("DD"), dailySales: dailySales.getAmount() / 100, accSales: acc.length > 0 diff --git a/client/src/components/dashboard-components/pojected-monthly-sales/projected-monthly-sales.component.jsx b/client/src/components/dashboard-components/pojected-monthly-sales/projected-monthly-sales.component.jsx index 10b268f0d..870133200 100644 --- a/client/src/components/dashboard-components/pojected-monthly-sales/projected-monthly-sales.component.jsx +++ b/client/src/components/dashboard-components/pojected-monthly-sales/projected-monthly-sales.component.jsx @@ -1,6 +1,6 @@ import { Card, Statistic } from "antd"; import Dinero from "dinero.js"; -import moment from "moment"; +import dayjs from "../../../utils/day"; import React from "react"; import { useTranslation } from "react-i18next"; import DashboardRefreshRequired from "../refresh-required.component"; @@ -36,10 +36,10 @@ export const DashboardProjectedMonthlySalesGql = ` _or: [ {_and: [ {date_invoiced:{_is_null: false }}, - {date_invoiced: {_gte: "${moment() + {date_invoiced: {_gte: "${dayjs() .startOf("month") .startOf("day") - .toISOString()}"}}, {date_invoiced: {_lte: "${moment() + .toISOString()}"}}, {date_invoiced: {_lte: "${dayjs() .endOf("month") .endOf("day") .toISOString()}"}}]}, @@ -47,10 +47,10 @@ export const DashboardProjectedMonthlySalesGql = ` _and:[ {date_invoiced:{_is_null: true }}, - {actual_completion: {_gte: "${moment() + {actual_completion: {_gte: "${dayjs() .startOf("month") .startOf("day") - .toISOString()}"}}, {actual_completion: {_lte: "${moment() + .toISOString()}"}}, {actual_completion: {_lte: "${dayjs() .endOf("month") .endOf("day") .toISOString()}"}} @@ -61,10 +61,10 @@ _and:[ {_and: [ {date_invoiced: {_is_null: true}}, {actual_completion: {_is_null: true}} - {scheduled_completion: {_gte: "${moment() + {scheduled_completion: {_gte: "${dayjs() .startOf("month") .startOf("day") - .toISOString()}"}}, {scheduled_completion: {_lte: "${moment() + .toISOString()}"}}, {scheduled_completion: {_lte: "${dayjs() .endOf("month") .endOf("day") .toISOString()}"}} diff --git a/client/src/components/dashboard-components/scheduled-in-today/scheduled-in-today.component.jsx b/client/src/components/dashboard-components/scheduled-in-today/scheduled-in-today.component.jsx index 74609ca49..5c1e93dd7 100644 --- a/client/src/components/dashboard-components/scheduled-in-today/scheduled-in-today.component.jsx +++ b/client/src/components/dashboard-components/scheduled-in-today/scheduled-in-today.component.jsx @@ -4,7 +4,7 @@ import { PauseCircleOutlined, } from "@ant-design/icons"; import { Card, Space, Table, Tooltip } from "antd"; -import moment from "moment"; +import dayjs from "../../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; @@ -49,14 +49,14 @@ export default function DashboardScheduledInToday({ data, ...cardProps }) { v_vin: item.job.v_vin, vehicleid: item.job.vehicleid, note: item.note, - start: moment(item.start).format("hh:mm a"), + start: dayjs(item.start).format("hh:mm a"), title: item.title, }; appt.push(i); } }); appt.sort(function (a, b) { - return new moment(a.start) - new moment(b.start); + return new dayjs(a.start) - new dayjs(b.start); }); const columns = [ @@ -189,7 +189,7 @@ export default function DashboardScheduledInToday({ data, ...cardProps }) { return ( @@ -209,9 +209,9 @@ export default function DashboardScheduledInToday({ data, ...cardProps }) { } export const DashboardScheduledInTodayGql = ` - scheduled_in_today: appointments(where: {start: {_gte: "${moment() + scheduled_in_today: appointments(where: {start: {_gte: "${dayjs() .startOf("day") - .toISOString()}", _lte: "${moment() + .toISOString()}", _lte: "${dayjs() .endOf("day") .toISOString()}"}, canceled: {_eq: false}, block: {_neq: true}}) { canceled diff --git a/client/src/components/dashboard-components/scheduled-out-today/scheduled-out-today.component.jsx b/client/src/components/dashboard-components/scheduled-out-today/scheduled-out-today.component.jsx index 0407e3aad..0c794f1db 100644 --- a/client/src/components/dashboard-components/scheduled-out-today/scheduled-out-today.component.jsx +++ b/client/src/components/dashboard-components/scheduled-out-today/scheduled-out-today.component.jsx @@ -4,7 +4,7 @@ import { PauseCircleOutlined, } from "@ant-design/icons"; import { Card, Space, Table, Tooltip } from "antd"; -import moment from "moment"; +import dayjs from "../../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; @@ -23,7 +23,7 @@ export default function DashboardScheduledOutToday({ data, ...cardProps }) { return ; data.scheduled_out_today.forEach((item) => { - item.scheduled_completion= moment(item.scheduled_completion).format("hh:mm a") + item.scheduled_completion= dayjs(item.scheduled_completion).format("hh:mm a") }); data.scheduled_out_today.sort(function (a, b) { return new Date(a.scheduled_completion) - new Date(b.scheduled_completion); @@ -159,7 +159,7 @@ export default function DashboardScheduledOutToday({ data, ...cardProps }) { return ( @@ -183,8 +183,8 @@ export const DashboardScheduledOutTodayGql = ` date_invoiced: {_is_null: true}, ro_number: {_is_null: false}, voided: {_eq: false}, - scheduled_completion: {_gte: "${moment().startOf("day").toISOString()}", - _lte: "${moment().endOf("day").toISOString()}"}}) { + scheduled_completion: {_gte: "${dayjs().startOf("day").toISOString()}", + _lte: "${dayjs().endOf("day").toISOString()}"}}) { alt_transport clm_no jobid: id diff --git a/client/src/components/dashboard-grid/dashboard-grid.component.jsx b/client/src/components/dashboard-grid/dashboard-grid.component.jsx index d5f3532ff..0c6e6bdb6 100644 --- a/client/src/components/dashboard-grid/dashboard-grid.component.jsx +++ b/client/src/components/dashboard-grid/dashboard-grid.component.jsx @@ -4,7 +4,7 @@ import { Button, Dropdown, Menu, Space, notification } from "antd"; import {PageHeader} from "@ant-design/pro-layout"; import i18next from "i18next"; import _ from "lodash"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { Responsive, WidthProvider } from "react-grid-layout"; import { useTranslation } from "react-i18next"; @@ -277,7 +277,7 @@ const componentList = { }, ScheduleInToday: { label: i18next.t("dashboard.titles.scheduledintoday", { - date: moment().startOf("day").format("MM/DD/YYYY"), + date: dayjs().startOf("day").format("MM/DD/YYYY"), }), component: DashboardScheduledInToday, gqlFragment: DashboardScheduledInTodayGql, @@ -288,7 +288,7 @@ const componentList = { }, ScheduleOutToday: { label: i18next.t("dashboard.titles.scheduledouttoday", { - date: moment().startOf("day").format("MM/DD/YYYY"), + date: dayjs().startOf("day").format("MM/DD/YYYY"), }), component: DashboardScheduledOutToday, gqlFragment: DashboardScheduledOutTodayGql, @@ -311,10 +311,10 @@ const createDashboardQuery = (state) => { ${componentBasedAdditions || ""} monthly_sales: jobs(where: {_and: [ { voided: {_eq: false}}, - {date_invoiced: {_gte: "${moment() + {date_invoiced: {_gte: "${dayjs() .startOf("month") .startOf("day") - .toISOString()}"}}, {date_invoiced: {_lte: "${moment() + .toISOString()}"}}, {date_invoiced: {_lte: "${dayjs() .endOf("month") .endOf("day") .toISOString()}"}}]}) { diff --git a/client/src/components/dms-log-events/dms-log-events.component.jsx b/client/src/components/dms-log-events/dms-log-events.component.jsx index 8925262dd..25830cdc7 100644 --- a/client/src/components/dms-log-events/dms-log-events.component.jsx +++ b/client/src/components/dms-log-events/dms-log-events.component.jsx @@ -1,5 +1,5 @@ import { Divider, Space, Tag, Timeline } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -29,7 +29,7 @@ export function DmsLogEvents({ socket, logs, bodyshop }) { {log.level} - {moment(log.timestamp).format("MM/DD/YYYY HH:mm:ss")} + {dayjs(log.timestamp).format("MM/DD/YYYY HH:mm:ss")} {log.message} diff --git a/client/src/components/dms-post-form/dms-post-form.component.jsx b/client/src/components/dms-post-form/dms-post-form.component.jsx index f575c096e..8a1897b93 100644 --- a/client/src/components/dms-post-form/dms-post-form.component.jsx +++ b/client/src/components/dms-post-form/dms-post-form.component.jsx @@ -15,7 +15,7 @@ import { Typography, } from "antd"; import Dinero from "dinero.js"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -101,7 +101,7 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) { }) : "" }`.substr(0, 239), - inservicedate: moment("2019-01-01"), + inservicedate: dayjs("2019-01-01"), }} > diff --git a/client/src/components/email-test/email-test-component.jsx b/client/src/components/email-test/email-test-component.jsx index ea891785c..d64bd0422 100644 --- a/client/src/components/email-test/email-test-component.jsx +++ b/client/src/components/email-test/email-test-component.jsx @@ -7,7 +7,7 @@ import { selectCurrentUser } from "../../redux/user/user.selectors"; import { GenerateDocument } from "../../utils/RenderTemplate"; import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; -import moment from "moment"; +import dayjs from "../../utils/day"; const mapStateToProps = createStructuredSelector({ currentUser: selectCurrentUser, @@ -27,16 +27,16 @@ export function EmailTestComponent({ currentUser, setEmailOptions }) { variables: { ...(values.start ? { - start: moment(values.start).startOf("day").format("YYYY-MM-DD"), + start: dayjs(values.start).startOf("day").format("YYYY-MM-DD"), } : {}), ...(values.end - ? { end: moment(values.end).endOf("day").format("YYYY-MM-DD") } + ? { end: dayjs(values.end).endOf("day").format("YYYY-MM-DD") } : {}), ...(values.start - ? { starttz: moment(values.start).startOf("day") } + ? { starttz: dayjs(values.start).startOf("day") } : {}), - ...(values.end ? { endtz: moment(values.end).endOf("day") } : {}), + ...(values.end ? { endtz: dayjs(values.end).endOf("day") } : {}), ...(values.id ? { id: values.id } : {}), }, diff --git a/client/src/components/feature-wrapper/feature-wrapper.component.jsx b/client/src/components/feature-wrapper/feature-wrapper.component.jsx index af609ac1f..33f7f911b 100644 --- a/client/src/components/feature-wrapper/feature-wrapper.component.jsx +++ b/client/src/components/feature-wrapper/feature-wrapper.component.jsx @@ -1,4 +1,4 @@ -import moment from "moment"; +import dayjs from "../../utils/day"; import React from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -34,7 +34,7 @@ function FeatureWrapper({ export function HasFeatureAccess({ featureName, bodyshop }) { return ( bodyshop.features.allAccess || - moment(bodyshop.features[featureName]).isAfter(moment()) + dayjs(bodyshop.features[featureName]).isAfter(dayjs()) ); } diff --git a/client/src/components/form-date-picker/form-date-picker.component.jsx b/client/src/components/form-date-picker/form-date-picker.component.jsx index 05a894e8b..c58db4739 100644 --- a/client/src/components/form-date-picker/form-date-picker.component.jsx +++ b/client/src/components/form-date-picker/form-date-picker.component.jsx @@ -1,31 +1,29 @@ import { DatePicker } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useRef } from "react"; -//To be used as a form element only. import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; const mapStateToProps = createStructuredSelector({ - //currentUser: selectCurrentUser bodyshop: selectBodyshop, }); -const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) -}); +const mapDispatchToProps = (dispatch) => ({}); export default connect(mapStateToProps, mapDispatchToProps)(FormDatePicker); const dateFormat = "MM/DD/YYYY"; + +// TODO, this is causing a dirty change when it should not (click the picker, click off the picker) export function FormDatePicker({ - bodyshop, - value, - onChange, - onBlur, - onlyFuture, - isDateOnly = true, - ...restProps -}) { + bodyshop, + value, + onChange, + onBlur, + onlyFuture, + isDateOnly = true, + ...restProps + }) { const ref = useRef(); const handleChange = (newDate) => { @@ -37,8 +35,7 @@ export function FormDatePicker({ const handleKeyDown = (e) => { if (e.key.toLowerCase() === "t") { if (onChange) { - onChange(isDateOnly ? moment().format("YYYY-MM-DD") : moment()); - // if (ref.current && ref.current.blur) ref.current.blur(); + onChange(isDateOnly ? dayjs().format("YYYY-MM-DD") : dayjs()); } } else if (e.key.toLowerCase() === "enter") { if (ref.current && ref.current.blur) ref.current.blur(); @@ -49,14 +46,23 @@ export function FormDatePicker({ const v = e.target.value; if (!v) return; - const _a = moment( - v, - ["MMDDYY", "MMDDYYYY", "MMDD", "MM/DD/YY"], - "en", - false + const _a = dayjs( + v, + ["MMDDYY", "MMDDYYYY", "MMDD", "MM/DD/YY"], + "en", + false ); - if (_a.isValid() && value && value.isValid && value.isValid()) { + if ( + _a.isValid() + && value + && value.isValid + && value.isValid() + && typeof value.hours === 'function' + && typeof value.minutes === 'function' + && typeof value.seconds === 'function' + && typeof value.milliseconds === 'function' + ) { _a.set({ hours: value.hours(), minutes: value.minutes(), @@ -67,10 +73,10 @@ export function FormDatePicker({ if (_a.isValid() && onChange) { if (onlyFuture) { - if (moment().subtract(1, "day").isBefore(_a)) { + if (dayjs().subtract(1, "day").isBefore(_a)) { onChange(isDateOnly ? _a.format("YYYY-MM-DD") : _a); } else { - onChange(isDateOnly ? moment().format("YYYY-MM-DD") : moment()); + onChange(isDateOnly ? dayjs().format("YYYY-MM-DD") : dayjs()); } } else { onChange(isDateOnly ? _a.format("YYYY-MM-DD") : _a); @@ -79,20 +85,20 @@ export function FormDatePicker({ }; return ( -
- moment().subtract(1, "day").isAfter(d), - })} - {...restProps} - /> -
+
+ dayjs().subtract(1, "day").isAfter(d), + })} + {...restProps} + /> +
); -} +} \ No newline at end of file diff --git a/client/src/components/form-date-time-picker/form-date-time-picker.component.jsx b/client/src/components/form-date-time-picker/form-date-time-picker.component.jsx index a086c253e..43b90cfc7 100644 --- a/client/src/components/form-date-time-picker/form-date-time-picker.component.jsx +++ b/client/src/components/form-date-time-picker/form-date-time-picker.component.jsx @@ -2,7 +2,7 @@ import React, { forwardRef } from "react"; //import DatePicker from "react-datepicker"; //import "react-datepicker/src/stylesheets/datepicker.scss"; import { TimePicker } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import FormDatePicker from "../form-date-picker/form-date-picker.component"; //To be used as a form element only. @@ -21,7 +21,7 @@ const DateTimePicker = ( moment().subtract(1, "day").isAfter(d), + disabledDate: (d) => dayjs().subtract(1, "day").isAfter(d), })} value={value} onBlur={onBlur} @@ -31,9 +31,9 @@ const DateTimePicker = ( /> moment().isAfter(d), + disabledDate: (d) => dayjs().isAfter(d), })} onChange={onChange} showSecond={false} diff --git a/client/src/components/inventory-bill-ro/inventory-bill-ro.component.jsx b/client/src/components/inventory-bill-ro/inventory-bill-ro.component.jsx index 033192dbd..14f97e2c9 100644 --- a/client/src/components/inventory-bill-ro/inventory-bill-ro.component.jsx +++ b/client/src/components/inventory-bill-ro/inventory-bill-ro.component.jsx @@ -4,7 +4,7 @@ import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { setModalContext } from "../../redux/modals/modals.actions"; import { selectBodyshop } from "../../redux/user/user.selectors"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { useTranslation } from "react-i18next"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -35,7 +35,7 @@ export function InventoryBillRo({ vendorid: bodyshop.inhousevendorid, invoice_number: "ih", isinhouse: true, - date: moment(), + date: dayjs(), total: 0, billlines: [{}], // billlines: selectedLines.map((p) => { diff --git a/client/src/components/job-at-change/schedule-event.component.jsx b/client/src/components/job-at-change/schedule-event.component.jsx index 1b5136b29..2d3e56547 100644 --- a/client/src/components/job-at-change/schedule-event.component.jsx +++ b/client/src/components/job-at-change/schedule-event.component.jsx @@ -12,7 +12,7 @@ import { Space, } from "antd"; import parsePhoneNumber from "libphonenumber-js"; -import moment from "moment"; +import dayjs from "../../utils/day"; import queryString from "query-string"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; @@ -218,8 +218,8 @@ export function ScheduleEventComponent({ setMessage( t("appointments.labels.reminder", { shopname: bodyshop.shopname, - date: moment(event.start).format("MM/DD/YYYY"), - time: moment(event.start).format("HH:mm a"), + date: dayjs(event.start).format("MM/DD/YYYY"), + time: dayjs(event.start).format("HH:mm a"), }) ); setVisible(false); diff --git a/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx b/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx index 551202652..0b11ebb27 100644 --- a/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx +++ b/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx @@ -1,6 +1,6 @@ import { useMutation } from "@apollo/client"; import { Button, Card, Form, Input, notification, Switch } from "antd"; -import moment from "moment-business-days"; +import dayjs from "../../../../utils/day"; import queryString from "query-string"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; @@ -87,7 +87,7 @@ export function JobChecklistForm({ bodyshop.intakechecklist && bodyshop.intakechecklist.next_contact_hours && bodyshop.intakechecklist.next_contact_hours > 0 && { - date_next_contact: moment().add( + date_next_contact: dayjs().add( bodyshop.intakechecklist.next_contact_hours, "hours" ), @@ -218,26 +218,26 @@ export function JobChecklistForm({ scheduled_completion: (job && job.scheduled_completion && - moment(job.scheduled_completion)) || + dayjs(job.scheduled_completion)) || (job && job.labhrs && job.larhrs && - moment().businessAdd( + dayjs().businessDaysAdd( (job.labhrs.aggregate.sum.mod_lb_hrs || 0 + job.larhrs.aggregate.sum.mod_lb_hrs || 0) / bodyshop.target_touchtime, "days" )), scheduled_delivery: - job.scheduled_delivery && moment(job.scheduled_delivery), + job.scheduled_delivery && dayjs(job.scheduled_delivery), production_vars: job.production_vars, }), ...(type === "deliver" && { removeFromProduction: true, actual_completion: - job && job.actual_completion && moment(job.actual_completion), + job && job.actual_completion && dayjs(job.actual_completion), actual_delivery: - job && job.actual_delivery && moment(job.actual_delivery), + job && job.actual_delivery && dayjs(job.actual_delivery), }), ...formItems .filter((fi) => fi.value) diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index 0b53a8824..19015729c 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -43,7 +43,7 @@ import _ from "lodash"; import JobCreateIOU from "../job-create-iou/job-create-iou.component"; import JobLinesExpander from "./job-lines-expander.component"; import { selectBodyshop } from "../../redux/user/user.selectors"; -import moment from "moment"; +import dayjs from "../../utils/day"; import JobLineConvertToLabor from "../job-line-convert-to-labor/job-line-convert-to-labor.component"; const mapStateToProps = createStructuredSelector({ @@ -466,7 +466,7 @@ export function JobLinesComponent({ vendorid: bodyshop.inhousevendorid, invoice_number: "ih", isinhouse: true, - date: new moment(), + date: new dayjs(), total: 0, billlines: selectedLines.map((p) => { return { diff --git a/client/src/components/job-line-convert-to-labor/job-line-convert-to-labor.component.jsx b/client/src/components/job-line-convert-to-labor/job-line-convert-to-labor.component.jsx index e887fd646..91227dd85 100644 --- a/client/src/components/job-line-convert-to-labor/job-line-convert-to-labor.component.jsx +++ b/client/src/components/job-line-convert-to-labor/job-line-convert-to-labor.component.jsx @@ -210,7 +210,7 @@ export function JobLineConvertToLabor({ setLoading(true); form.setFieldsValue({ - // date: new moment(), + // date: new dayjs(), // bodyhrs: Math.round(v.bodyhrs * 10) / 10, // painthrs: Math.round(v.painthrs * 10) / 10, }); diff --git a/client/src/components/job-scoreboard-add-button/job-scoreboard-add-button.component.jsx b/client/src/components/job-scoreboard-add-button/job-scoreboard-add-button.component.jsx index c426e2c1a..93735c2a8 100644 --- a/client/src/components/job-scoreboard-add-button/job-scoreboard-add-button.component.jsx +++ b/client/src/components/job-scoreboard-add-button/job-scoreboard-add-button.component.jsx @@ -9,7 +9,7 @@ import { Popover, Space, } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { logImEXEvent } from "../../firebase/firebase.utils"; @@ -177,7 +177,7 @@ export default function ScoreboardAddButton({ return acc + job.lbr_adjustments[val]; }, 0); form.setFieldsValue({ - date: new moment(), + date: new dayjs(), bodyhrs: Math.round(v.bodyhrs * 10) / 10, painthrs: Math.round(v.painthrs * 10) / 10, }); diff --git a/client/src/components/jobs-admin-dates/jobs-admin-dates.component.jsx b/client/src/components/jobs-admin-dates/jobs-admin-dates.component.jsx index 5ac31da74..0ecb1128b 100644 --- a/client/src/components/jobs-admin-dates/jobs-admin-dates.component.jsx +++ b/client/src/components/jobs-admin-dates/jobs-admin-dates.component.jsx @@ -1,6 +1,6 @@ import { useMutation } from "@apollo/client"; import { Button, Form, notification } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { UPDATE_JOB } from "../../graphql/jobs.queries"; @@ -53,7 +53,7 @@ export function JobsAdminDatesChange({ insertAuditTrail, job }) { jobid: job.id, operation: AuditTrailMapping.admin_jobfieldchange( key, - changedAuditFields[key] instanceof moment + changedAuditFields[key] instanceof dayjs ? DateTimeFormat(changedAuditFields[key]) : changedAuditFields[key] ), @@ -89,7 +89,7 @@ export function JobsAdminDatesChange({ insertAuditTrail, job }) { initialValues={{ ...job, date_estimated: job.date_estimated - ? moment(job.date_estimated) + ? dayjs(job.date_estimated) : null, }} > diff --git a/client/src/components/jobs-admin-mark-reexport/jobs-admin-mark-reexport.component.jsx b/client/src/components/jobs-admin-mark-reexport/jobs-admin-mark-reexport.component.jsx index c47c30def..1f52b6df5 100644 --- a/client/src/components/jobs-admin-mark-reexport/jobs-admin-mark-reexport.component.jsx +++ b/client/src/components/jobs-admin-mark-reexport/jobs-admin-mark-reexport.component.jsx @@ -3,7 +3,7 @@ import { Button, notification } from "antd"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries"; @@ -108,7 +108,7 @@ export function JobAdminMarkReexport({ const handleMarkExported = async () => { setLoading(true); const result = await markJobExported({ - variables: { jobId: job.id, date_exported: moment() }, + variables: { jobId: job.id, date_exported: dayjs() }, }); await insertExportLog({ diff --git a/client/src/components/jobs-admin-unvoid/jobs-admin-unvoid.component.jsx b/client/src/components/jobs-admin-unvoid/jobs-admin-unvoid.component.jsx index 7963fd05f..b147c07d8 100644 --- a/client/src/components/jobs-admin-unvoid/jobs-admin-unvoid.component.jsx +++ b/client/src/components/jobs-admin-unvoid/jobs-admin-unvoid.component.jsx @@ -63,8 +63,8 @@ mutation UNVOID_JOB($jobId: uuid!) { // created_by: currentUser.email, // audit: true, // text: t("jobs.labels.voidnote", { - // date: moment().format("MM/DD/yyy"), - // time: moment().format("hh:mm a"), + // date: dayjs().format("MM/DD/yyy"), + // time: dayjs().format("hh:mm a"), // }), // }, // ], diff --git a/client/src/components/jobs-available-table/jobs-available-table.container.jsx b/client/src/components/jobs-available-table/jobs-available-table.container.jsx index 37986bd9a..87b90e8c8 100644 --- a/client/src/components/jobs-available-table/jobs-available-table.container.jsx +++ b/client/src/components/jobs-available-table/jobs-available-table.container.jsx @@ -9,7 +9,7 @@ import { useTreatments } from "@splitsoftware/splitio-react"; import { Col, notification, Row } from "antd"; import Axios from "axios"; import Dinero from "dinero.js"; -import moment from "moment"; +import dayjs from "../../utils/day"; import queryString from "query-string"; import React, { useCallback, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -137,7 +137,7 @@ export function JobsAvailableContainer({ clm_total: Dinero(newTotals.totals.total_repairs).toFormat("0.00"), owner_owing: Dinero(newTotals.totals.custPayable.total).toFormat("0.00"), job_totals: newTotals, - date_open: moment(), + date_open: dayjs(), status: bodyshop.md_ro_statuses.default_imported, notes: { data: { diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addevent.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addevent.jsx index f157df24e..cae421315 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addevent.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.addevent.jsx @@ -10,7 +10,7 @@ import { Select, Space, } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -110,7 +110,7 @@ export function JobsDetailHeaderAddEvent({ bodyshop, jobid, ...props }) { async validator(rule, value) { if (value) { const { start } = form.getFieldsValue(); - if (moment(start).isAfter(moment(value))) { + if (dayjs(start).isAfter(dayjs(value))) { return Promise.reject( t("employees.labels.endmustbeafterstart") ); diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.duplicate.util.js b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.duplicate.util.js index 503bcc740..de4944f93 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.duplicate.util.js +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.duplicate.util.js @@ -2,7 +2,7 @@ import Axios from "axios"; import _ from "lodash"; import { logImEXEvent } from "../../firebase/firebase.utils"; import { INSERT_NEW_JOB, QUERY_JOB_FOR_DUPE } from "../../graphql/jobs.queries"; -import moment from "moment"; +import dayjs from "../../utils/day"; import i18n from "i18next"; export default async function DuplicateJob( @@ -92,7 +92,7 @@ export async function CreateIouForJob( converted: true, status: status, iouparent: jobId, - date_open: moment(), + date_open: dayjs(), audit_trails: { data: [ { diff --git a/client/src/components/parts-order-modal/parts-order-modal.container.jsx b/client/src/components/parts-order-modal/parts-order-modal.container.jsx index 464064773..de37dc5da 100644 --- a/client/src/components/parts-order-modal/parts-order-modal.container.jsx +++ b/client/src/components/parts-order-modal/parts-order-modal.container.jsx @@ -1,6 +1,6 @@ import { useMutation, useQuery, useApolloClient } from "@apollo/client"; import { Form, Modal, notification } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -108,7 +108,7 @@ export function PartsOrderModalContainer({ po: [ { ...values, - order_date: moment().format("YYYY-MM-DD"), + order_date: dayjs().format("YYYY-MM-DD"), orderedby: currentUser.email, jobid: jobId, user_email: currentUser.email, @@ -185,7 +185,7 @@ export function PartsOrderModalContainer({ vendorid: bodyshop.inhousevendorid, invoice_number: "ih", isinhouse: true, - date: new moment(), + date: new dayjs(), total: 0, billlines: values.parts_order_lines.data.map((p) => { return { @@ -318,7 +318,7 @@ export function PartsOrderModalContainer({ const initialValues = { jobid: jobId, return: isReturn, - deliver_by: isReturn ? moment(new Date()) : null, + deliver_by: isReturn ? dayjs(new Date()) : null, vendorid: vendorId, returnfrombill: returnFromBill, diff --git a/client/src/components/payment-expanded-row/payment-expanded-row.component.jsx b/client/src/components/payment-expanded-row/payment-expanded-row.component.jsx index a150eee78..8ea48b809 100644 --- a/client/src/components/payment-expanded-row/payment-expanded-row.component.jsx +++ b/client/src/components/payment-expanded-row/payment-expanded-row.component.jsx @@ -8,7 +8,7 @@ import { notification, } from "antd"; import axios from "axios"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { @@ -64,7 +64,7 @@ const PaymentExpandedRowComponent = ({ record, bodyshop }) => { payer: record.payer, type: "Refund", jobid: payment_response.jobid, - date: moment(Date.now()), + date: dayjs(Date.now()), }, }, update(cache, { data }) { diff --git a/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx b/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx index dca5d3a70..ad28a75c9 100644 --- a/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx +++ b/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx @@ -14,7 +14,7 @@ import ProductionAlert from "../production-list-columns/production-list-columns. import ProductionListColumnProductionNote from "../production-list-columns/production-list-columns.productionnote.component"; import ProductionSubletsManageComponent from "../production-sublets-manage/production-sublets-manage.component"; import "./production-board-card.styles.scss"; -import moment from "moment"; +import dayjs from "../../utils/day"; import OwnerNameDisplay from "../owner-name-display/owner-name-display.component"; import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component"; @@ -72,11 +72,11 @@ export default function ProductionBoardCard( const pastDueAlert = !!card.scheduled_completion && - ((moment().isSameOrAfter(moment(card.scheduled_completion), "day") && + ((dayjs().isSameOrAfter(dayjs(card.scheduled_completion), "day") && "production-completion-past") || - (moment() + (dayjs() .add(1, "day") - .isSame(moment(card.scheduled_completion), "day") && + .isSame(dayjs(card.scheduled_completion), "day") && "production-completion-soon")); const totalHrs = diff --git a/client/src/components/production-list-columns/production-list-columns.data.js b/client/src/components/production-list-columns/production-list-columns.data.js index a93e0f3e6..e9b57df19 100644 --- a/client/src/components/production-list-columns/production-list-columns.data.js +++ b/client/src/components/production-list-columns/production-list-columns.data.js @@ -1,7 +1,7 @@ import { PauseCircleOutlined, BranchesOutlined } from "@ant-design/icons"; import { Space, Tooltip } from "antd"; import i18n from "i18next"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { Link } from "react-router-dom"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; import { TimeFormatter } from "../../utils/DateFormatter"; @@ -176,7 +176,7 @@ const r = ({ technician, state, activeStatuses, bodyshop }) => { style={{ color: record.date_next_contact && - moment(record.date_next_contact).isBefore(moment()) + dayjs(record.date_next_contact).isBefore(dayjs()) ? "red" : "", }} diff --git a/client/src/components/production-list-columns/production-list-columns.date.component.jsx b/client/src/components/production-list-columns/production-list-columns.date.component.jsx index 43647d75a..ed220eba0 100644 --- a/client/src/components/production-list-columns/production-list-columns.date.component.jsx +++ b/client/src/components/production-list-columns/production-list-columns.date.component.jsx @@ -1,6 +1,6 @@ import { useMutation } from "@apollo/client"; import { Button, Card, Dropdown, TimePicker } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { logImEXEvent } from "../../firebase/firebase.utils"; @@ -20,7 +20,7 @@ export default function ProductionListDate({ const handleChange = (date) => { logImEXEvent("product_toggle_date", { field }); - // if (date.isSame(record[field] && moment(record[field]))) { + // if (date.isSame(record[field] && dayjs(record[field]))) { // return; // } @@ -50,9 +50,9 @@ export default function ProductionListDate({ if (pastIndicator) { className = !!record[field] && - ((moment().isSameOrAfter(moment(record[field]), "day") && + ((dayjs().isSameOrAfter(dayjs(record[field]), "day") && "production-completion-past") || - (moment().add(1, "day").isSame(moment(record[field]), "day") && + (dayjs().add(1, "day").isSame(dayjs(record[field]), "day") && "production-completion-soon")); } @@ -68,7 +68,7 @@ export default function ProductionListDate({ e.stopPropagation()}> e.stopPropagation()} - value={(record[field] && moment(record[field])) || null} + value={(record[field] && dayjs(record[field])) || null} onChange={handleChange} format="MM/DD/YYYY" isDateOnly={!time} @@ -76,7 +76,7 @@ export default function ProductionListDate({ {time && ( e.stopPropagation()} - value={(record[field] && moment(record[field])) || null} + value={(record[field] && dayjs(record[field])) || null} onChange={handleChange} minuteStep={15} format="hh:mm a" diff --git a/client/src/components/production-list-columns/production-list-columns.lastcontacted.component.jsx b/client/src/components/production-list-columns/production-list-columns.lastcontacted.component.jsx index 6f4bd5668..382ace0e4 100644 --- a/client/src/components/production-list-columns/production-list-columns.lastcontacted.component.jsx +++ b/client/src/components/production-list-columns/production-list-columns.lastcontacted.component.jsx @@ -1,6 +1,6 @@ import { useMutation } from "@apollo/client"; import { Button, Card, Dropdown, Form, Input, notification, Space } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -84,7 +84,7 @@ export function ProductionLastContacted({ currentUser, record }) { form.setFieldsValue({ note: null, date_last_contacted: - record.date_last_contacted && moment(record.date_last_contacted), + record.date_last_contacted && dayjs(record.date_last_contacted), }); } }, [visible, form, record.date_last_contacted]); diff --git a/client/src/components/production-list-columns/prodution-list-columns.touchtime.component.jsx b/client/src/components/production-list-columns/prodution-list-columns.touchtime.component.jsx index c651b7f8d..c6ff374e7 100644 --- a/client/src/components/production-list-columns/prodution-list-columns.touchtime.component.jsx +++ b/client/src/components/production-list-columns/prodution-list-columns.touchtime.component.jsx @@ -1,4 +1,4 @@ -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useMemo } from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -21,8 +21,8 @@ export function ProductionlistColumnTouchTime({ bodyshop, job }) { (job.larhrs.aggregate.sum.mod_lb_hrs || 0) + (job.labhrs.aggregate.sum.mod_lb_hrs || 0); - const Difference_In_Days = moment().diff( - moment(job.actual_in), + const Difference_In_Days = dayjs().diff( + dayjs(job.actual_in), "days", true ); diff --git a/client/src/components/report-center-modal/report-center-modal.component.jsx b/client/src/components/report-center-modal/report-center-modal.component.jsx index 913d27282..d32be9e72 100644 --- a/client/src/components/report-center-modal/report-center-modal.component.jsx +++ b/client/src/components/report-center-modal/report-center-modal.component.jsx @@ -11,7 +11,7 @@ import { Typography, } from "antd"; import _ from "lodash"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -77,13 +77,13 @@ export function ReportCenterModalComponent({ reportCenterModal }) { name: values.key, variables: { ...(start - ? { start: moment(start).startOf("day").format("YYYY-MM-DD") } + ? { start: dayjs(start).startOf("day").format("YYYY-MM-DD") } : {}), ...(end - ? { end: moment(end).endOf("day").format("YYYY-MM-DD") } + ? { end: dayjs(end).endOf("day").format("YYYY-MM-DD") } : {}), - ...(start ? { starttz: moment(start).startOf("day") } : {}), - ...(end ? { endtz: moment(end).endOf("day") } : {}), + ...(start ? { starttz: dayjs(start).startOf("day") } : {}), + ...(end ? { endtz: dayjs(end).endOf("day") } : {}), ...(id ? { id: id } : {}), }, diff --git a/client/src/components/schedule-block-day/schedule-block-day.component.jsx b/client/src/components/schedule-block-day/schedule-block-day.component.jsx index 548da1f9f..9bbc76c28 100644 --- a/client/src/components/schedule-block-day/schedule-block-day.component.jsx +++ b/client/src/components/schedule-block-day/schedule-block-day.component.jsx @@ -1,6 +1,6 @@ import { useMutation } from "@apollo/client"; import { Dropdown, Menu, notification } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -34,8 +34,8 @@ export function ScheduleBlockDay({ block: true, isintake: false, bodyshopid: bodyshop.id, - start: moment(date).startOf("day"), - end: moment(date).endOf("day"), + start: dayjs(date).startOf("day"), + end: dayjs(date).endOf("day"), }; logImEXEvent("dashboard_change_layout"); 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 732bcc2c2..cfd09aec3 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 @@ -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; diff --git a/client/src/components/schedule-calendar-wrapper/schedule-calendar-util.js b/client/src/components/schedule-calendar-wrapper/schedule-calendar-util.js index e03b48ba0..1f2fbadea 100644 --- a/client/src/components/schedule-calendar-wrapper/schedule-calendar-util.js +++ b/client/src/components/schedule-calendar-wrapper/schedule-calendar-util.js @@ -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 }; diff --git a/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx b/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx index ebcccc3fa..298b2eae8 100644 --- a/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx +++ b/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx @@ -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 ( <> diff --git a/client/src/components/schedule-calendar/schedule-calendar.container.jsx b/client/src/components/schedule-calendar/schedule-calendar.container.jsx index 27e05258a..8c2f90868 100644 --- a/client/src/components/schedule-calendar/schedule-calendar.container.jsx +++ b/client/src/components/schedule-calendar/schedule-calendar.container.jsx @@ -10,7 +10,7 @@ import ScheduleCalendarComponent from "./schedule-calendar.component"; import { calculateScheduleLoad } from "../../redux/application/application.actions"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; -import moment from "moment"; +import dayjs from "../../utils/day"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser }); @@ -63,8 +63,8 @@ export function ScheduleCalendarContainer({ calculateScheduleLoad }) { (e.employee.first_name && e.employee.first_name.substr(0, 1)) || "" } ${e.employee.last_name || ""} OUT`, color: "red", - start: moment(e.start).startOf("day").toDate(), - end: moment(e.end).startOf("day").toDate(), + start: dayjs(e.start).startOf("day").toDate(), + end: dayjs(e.end).startOf("day").toDate(), allDay: true, vacation: true, }; diff --git a/client/src/components/schedule-day-view/schedule-day-view.container.jsx b/client/src/components/schedule-day-view/schedule-day-view.container.jsx index e35b44873..0f69a6e40 100644 --- a/client/src/components/schedule-day-view/schedule-day-view.container.jsx +++ b/client/src/components/schedule-day-view/schedule-day-view.container.jsx @@ -3,18 +3,18 @@ import ScheduleDayViewComponent from "./schedule-day-view.component"; import { useQuery } from "@apollo/client"; import { QUERY_APPOINTMENT_BY_DATE } from "../../graphql/appointments.queries"; import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { useTranslation } from "react-i18next"; export default function ScheduleDayViewContainer({ day }) { const { loading, error, data } = useQuery(QUERY_APPOINTMENT_BY_DATE, { variables: { - start: moment(day).startOf("day"), - end: moment(day).endOf("day"), - startd: moment(day).startOf("day").format("YYYY-MM-DD"), - endd: moment(day).add(1, "day").format("YYYY-MM-DD"), + start: dayjs(day).startOf("day"), + end: dayjs(day).endOf("day"), + startd: dayjs(day).startOf("day").format("YYYY-MM-DD"), + endd: dayjs(day).add(1, "day").format("YYYY-MM-DD"), }, - skip: !moment(day).isValid(), + skip: !dayjs(day).isValid(), fetchPolicy: "network-only", nextFetchPolicy: "network-only", }); @@ -43,8 +43,8 @@ export default function ScheduleDayViewContainer({ day }) { (e.employee.first_name && e.employee.first_name.substr(0, 1)) || "" } ${e.employee.last_name || ""} OUT`, color: "red", - start: moment(e.start).startOf("day").toDate(), - end: moment(e.end).startOf("day").toDate(), + start: dayjs(e.start).startOf("day").toDate(), + end: dayjs(e.end).startOf("day").toDate(), vacation: true, }; }), diff --git a/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx b/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx index fdfb9932c..1e60264ff 100644 --- a/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx +++ b/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx @@ -10,7 +10,7 @@ import { Typography, } from "antd"; import axios from "axios"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -68,7 +68,7 @@ export function ScheduleJobModalComponent({ if (values.start && !values.scheduled_completion) form.setFieldsValue({ - scheduled_completion: moment(values.start).businessAdd( + scheduled_completion: dayjs(values.start).businessAdd( totalHours / bodyshop.target_touchtime, "days" ), @@ -134,11 +134,11 @@ export function ScheduleJobModalComponent({ className="imex-flex-row__margin" key={idx} onClick={() => { - const ssDate = moment(d); - if (ssDate.isBefore(moment())) { - form.setFieldsValue({ start: moment() }); + const ssDate = dayjs(d); + if (ssDate.isBefore(dayjs())) { + form.setFieldsValue({ start: dayjs() }); } else { - form.setFieldsValue({ start: moment(d).add(8, "hours") }); + form.setFieldsValue({ start: dayjs(d).add(8, "hours") }); } handleDateBlur(); }} @@ -201,7 +201,7 @@ export function ScheduleJobModalComponent({ {() => { const values = form.getFieldsValue(); if (values.start) { - calculateScheduleLoad(moment(values.start).add(3, "days")); + calculateScheduleLoad(dayjs(values.start).add(3, "days")); } return (
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 3df5cf555..b62b1d1c6 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 @@ -1,7 +1,6 @@ import { useMutation, useQuery } from "@apollo/client"; -//import moment from "moment"; import { Form, Modal, notification } from "antd"; -import moment from "moment-business-days"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -129,8 +128,8 @@ export function ScheduleJobModalContainer({ app: { jobid: jobId, bodyshopid: bodyshop.id, - start: moment(values.start), - end: moment(values.start).add(bodyshop.appt_length || 60, "minutes"), + start: dayjs(values.start), + end: dayjs(values.start).add(bodyshop.appt_length || 60, "minutes"), color: values.color, note: values.note, created_by: currentUser.email, diff --git a/client/src/components/schedule-manual-event/schedule-manual-event.component.jsx b/client/src/components/schedule-manual-event/schedule-manual-event.component.jsx index c0b7ba54b..fea8a4f96 100644 --- a/client/src/components/schedule-manual-event/schedule-manual-event.component.jsx +++ b/client/src/components/schedule-manual-event/schedule-manual-event.component.jsx @@ -1,6 +1,6 @@ import { useMutation } from "@apollo/client"; import { Button, Card, Form, Input, Popover, Select, Space } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -111,7 +111,7 @@ export function ScheduleManualEvent({ bodyshop, event }) { async validator(rule, value) { if (value) { const { start } = form.getFieldsValue(); - if (moment(start).isAfter(moment(value))) { + if (dayjs(start).isAfter(dayjs(value))) { return Promise.reject( t("employees.labels.endmustbeafterstart") ); diff --git a/client/src/components/schedule-verify-integrity/schedule-verify-integrity.component.jsx b/client/src/components/schedule-verify-integrity/schedule-verify-integrity.component.jsx index 061b15b2c..6e390d09f 100644 --- a/client/src/components/schedule-verify-integrity/schedule-verify-integrity.component.jsx +++ b/client/src/components/schedule-verify-integrity/schedule-verify-integrity.component.jsx @@ -1,6 +1,6 @@ import { useApolloClient } from "@apollo/client"; import { Button } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -27,7 +27,7 @@ export function ScheduleVerifyIntegrity({ currentUser }) { data: { arrJobs, compJobs, prodJobs }, } = await client.query({ query: QUERY_SCHEDULE_LOAD_DATA, - variables: { start: moment(), end: moment().add(180, "days") }, + variables: { start: dayjs(), end: dayjs().add(180, "days") }, }); //check that the leaving jobs are either in the arriving list, or in production. diff --git a/client/src/components/scoreboard-chart/scoreboard-chart.component.jsx b/client/src/components/scoreboard-chart/scoreboard-chart.component.jsx index 4e9aa85d0..3660680dc 100644 --- a/client/src/components/scoreboard-chart/scoreboard-chart.component.jsx +++ b/client/src/components/scoreboard-chart/scoreboard-chart.component.jsx @@ -1,7 +1,7 @@ import { Card } from "antd"; import Dinero from "dinero.js"; import _ from "lodash"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React from "react"; import { connect } from "react-redux"; import { @@ -61,7 +61,7 @@ export function ScoreboardChart({ sbEntriesByDate, bodyshop }) { } const theValue = { - date: moment(val).format("D ddd"), + date: dayjs(val).format("D ddd"), paintHrs: _.round(dayhrs.painthrs, 1), bodyHrs: _.round(dayhrs.bodyhrs, 1), accTargetHrs: _.round( diff --git a/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx b/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx index cfd6d945d..3e4626027 100644 --- a/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx +++ b/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx @@ -1,5 +1,5 @@ import { Card, Divider, Statistic } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -27,7 +27,7 @@ export function ScoreboardDayStats({ bodyshop, date, entries }) { return ( diff --git a/client/src/components/scoreboard-display/scoreboard-display.component.jsx b/client/src/components/scoreboard-display/scoreboard-display.component.jsx index a27b5c633..02339eebf 100644 --- a/client/src/components/scoreboard-display/scoreboard-display.component.jsx +++ b/client/src/components/scoreboard-display/scoreboard-display.component.jsx @@ -7,7 +7,7 @@ import ScoreboardTargetsTable from "../scoreboard-targets-table/scoreboard-targe import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { useApolloClient, useQuery } from "@apollo/client"; import { GET_BLOCKED_DAYS, @@ -28,8 +28,8 @@ export default connect( export function ScoreboardDisplayComponent({ bodyshop }) { const scoreboardSubscription = useQuery(QUERY_SCOREBOARD, { variables: { - start: moment().startOf("month"), - end: moment().endOf("month"), + start: dayjs().startOf("month"), + end: dayjs().endOf("month"), }, pollInterval: 60000, }); @@ -50,26 +50,26 @@ export function ScoreboardDisplayComponent({ bodyshop }) { useEffect(() => { //Update the locals. - async function setMomentSettings() { + async function setDayJSSettings() { let appointments; if (!bodyshop.scoreboard_target.ignoreblockeddays) { const { data } = await client.query({ query: GET_BLOCKED_DAYS, variables: { - start: moment().startOf("month"), - end: moment().endOf("month"), + start: dayjs().startOf("month"), + end: dayjs().endOf("month"), }, }); appointments = data.appointments; } - moment.updateLocale("ca", { + dayjs.updateLocale("ca", { workingWeekdays: translateSettingsToWorkingDays(bodyshop.workingdays), ...(appointments ? { holidays: appointments.map((h) => - moment(h.start).format("MM-DD-YYYY") + dayjs(h.start).format("MM-DD-YYYY") ), } : {}), @@ -77,7 +77,7 @@ export function ScoreboardDisplayComponent({ bodyshop }) { }); } - setMomentSettings(); + setDayJSSettings(); }, [client, bodyshop]); return ( diff --git a/client/src/components/scoreboard-last-days/scoreboard-last-days.component.jsx b/client/src/components/scoreboard-last-days/scoreboard-last-days.component.jsx index f88b897ef..e3c25b028 100644 --- a/client/src/components/scoreboard-last-days/scoreboard-last-days.component.jsx +++ b/client/src/components/scoreboard-last-days/scoreboard-last-days.component.jsx @@ -2,7 +2,7 @@ import React from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; -import moment from "moment"; +import dayjs from "../../utils/day"; import ScoreboardDayStat from "../scoreboard-day-stats/scoreboard-day-stats.component"; import { Row, Col } from "antd"; import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component"; @@ -15,11 +15,12 @@ const mapDispatchToProps = (dispatch) => ({ }); export function ScoreboardLastDays({ bodyshop, sbEntriesByDate }) { + const { lastNumberWorkingDays } = bodyshop.scoreboard_target; const ArrayOfDate = []; for (var i = lastNumberWorkingDays - 1; i >= 0; i--) { - ArrayOfDate.push(moment().businessSubtract(i, "day").format("yyyy-MM-DD")); + ArrayOfDate.push(dayjs().businessDaysSubtract(i, "day").format("yyyy-MM-DD")); } return ( diff --git a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx index 112d441f6..40123a375 100644 --- a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx +++ b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx @@ -1,7 +1,7 @@ import { CalendarOutlined } from "@ant-design/icons"; import { Card, Col, Divider, Row, Statistic } 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 { connect } from "react-redux"; @@ -35,7 +35,7 @@ export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) { toDatePaint: 0, }; - const today = moment(); + const today = dayjs(); if (dateHash[today.format("YYYY-MM-DD")]) { dateHash[today.format("YYYY-MM-DD")].forEach((d) => { ret.todayBody = ret.todayBody + d.bodyhrs; @@ -43,7 +43,7 @@ export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) { }); } - let StartOfWeek = moment().startOf("week"); + let StartOfWeek = dayjs().startOf("week"); while (StartOfWeek.isSameOrBefore(today)) { if (dateHash[StartOfWeek.format("YYYY-MM-DD")]) { dateHash[StartOfWeek.format("YYYY-MM-DD")].forEach((d) => { @@ -54,7 +54,7 @@ export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) { StartOfWeek = StartOfWeek.add(1, "day"); } - let startOfMonth = moment().startOf("month"); + let startOfMonth = dayjs().startOf("month"); while (startOfMonth.isSameOrBefore(today)) { if (dateHash[startOfMonth.format("YYYY-MM-DD")]) { dateHash[startOfMonth.format("YYYY-MM-DD")].forEach((d) => { diff --git a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.util.js b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.util.js index c69493108..8acfae1e5 100644 --- a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.util.js +++ b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.util.js @@ -1,31 +1,31 @@ -import moment from "moment-business-days"; +import dayjs from "../../utils/day"; -// moment.updateLocale("ca", { +// dayjs.updateLocale("ca", { // workingWeekdays: [1, 2, 3, 4, 5, 6], // }); export const CalculateWorkingDaysThisMonth = () => { - return moment().endOf("month").businessDaysIntoMonth(); + return dayjs().endOf("month").businessDaysInMonth(); }; export const CalculateWorkingDaysInPeriod = (start, end) => { - return moment(start).businessDiff(moment(end)); + return dayjs(start).businessDiff(dayjs(end)); }; export const CalculateWorkingDaysAsOfToday = () => { - return moment().businessDaysIntoMonth(); + return dayjs().businessDaysInMonth(); }; export const CalculateWorkingDaysLastMonth = () => { - return moment().subtract(1, "month").endOf("month").businessDaysIntoMonth(); + return dayjs().subtract(1, "month").endOf("month").businessDaysInMonth(); }; export const WeeklyTargetHrs = (dailyTargetHrs, bodyshop) => { return ( dailyTargetHrs * CalculateWorkingDaysInPeriod( - moment().startOf("week"), - moment().endOf("week") + dayjs().startOf("week"), + dayjs().endOf("week") ) ); }; @@ -53,20 +53,22 @@ export const AsOfTodayTargetHrs = (dailyTargetHrs, bodyshop) => { export const AsOfDateTargetHours = (dailyTargetHours, date) => { return ( - dailyTargetHours * moment().startOf("month").businessDiff(moment(date)) + dailyTargetHours * dayjs().startOf("month").businessDiff(dayjs(date)) ); }; export const ListOfBusinessDaysInCurrentMonth = () => { - const momentListOfDays = moment().monthBusinessDays(); + // TODO This is probably broken :/ + console.log('Hit!!!!') + const momentListOfDays = dayjs().businessDaysInMonth(); return momentListOfDays.map((i) => i.format("YYYY-MM-DD")); }; export const ListOfDaysInCurrentMonth = () => { const days = []; - const dateStart = moment().startOf("month"); - const dateEnd = moment().endOf("month"); + const dateStart = dayjs().startOf("month"); + const dateEnd = dayjs().endOf("month"); while (dateEnd.diff(dateStart, "days") > 0) { days.push(dateStart.format("YYYY-MM-DD")); dateStart.add(1, "days"); @@ -77,8 +79,8 @@ export const ListOfDaysInCurrentMonth = () => { export const ListDaysBetween = ({ start, end }) => { const days = []; - const dateStart = moment(start); - const dateEnd = moment(end); + const dateStart = dayjs(start); + const dateEnd = dayjs(end); while (dateEnd.diff(dateStart, "days") > 0) { days.push(dateStart.format("YYYY-MM-DD")); dateStart.add(1, "days"); diff --git a/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.component.jsx b/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.component.jsx index 0117279d5..10f3a669b 100644 --- a/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.component.jsx +++ b/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.component.jsx @@ -1,7 +1,7 @@ import { useQuery } from "@apollo/client"; import { Col, Row } 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 { connect } from "react-redux"; @@ -29,24 +29,24 @@ export default connect( export function ScoreboardTimeTicketsStats({ bodyshop }) { const { t } = useTranslation(); - const startDate = moment().startOf("month") - const endDate = moment().endOf("month"); + const startDate = dayjs().startOf("month") + const endDate = dayjs().endOf("month"); const fixedPeriods = useMemo(() => { - const endOfThisMonth = moment().endOf("month"); - const startofthisMonth = moment().startOf("month"); + const endOfThisMonth = dayjs().endOf("month"); + const startofthisMonth = dayjs().startOf("month"); - const endOfLastmonth = moment().subtract(1, "month").endOf("month"); - const startOfLastmonth = moment().subtract(1, "month").startOf("month"); + const endOfLastmonth = dayjs().subtract(1, "month").endOf("month"); + const startOfLastmonth = dayjs().subtract(1, "month").startOf("month"); - const endOfThisWeek = moment().endOf("week"); - const startOfThisWeek = moment().startOf("week"); + const endOfThisWeek = dayjs().endOf("week"); + const startOfThisWeek = dayjs().startOf("week"); - const endOfLastWeek = moment().subtract(1, "week").endOf("week"); - const startOfLastWeek = moment().subtract(1, "week").startOf("week"); + const endOfLastWeek = dayjs().subtract(1, "week").endOf("week"); + const startOfLastWeek = dayjs().subtract(1, "week").startOf("week"); - const endOfPriorWeek = moment().subtract(2, "week").endOf("week"); - const startOfPriorWeek = moment().subtract(2, "week").startOf("week"); + const endOfPriorWeek = dayjs().subtract(2, "week").endOf("week"); + const startOfPriorWeek = dayjs().subtract(2, "week").startOf("week"); const allDates = [ endOfThisMonth, @@ -60,8 +60,8 @@ export function ScoreboardTimeTicketsStats({ bodyshop }) { endOfPriorWeek, startOfPriorWeek, ]; - const start = moment.min(allDates); - const end = moment.max(allDates); + const start = dayjs.min(allDates); + const end = dayjs.max(allDates); return { start, end, @@ -155,7 +155,7 @@ export function ScoreboardTimeTicketsStats({ bodyshop }) { }; data.fixedperiod.forEach((ticket) => { - const ticketDate = moment(ticket.date); + const ticketDate = dayjs(ticket.date); if ( ticketDate.isBetween( fixedPeriods.startOfThisWeek, @@ -172,24 +172,24 @@ export function ScoreboardTimeTicketsStats({ bodyshop }) { //Seperate out to Day of Week ret.seperatedThisWeek[ - moment(ticket.date).format("dddd").toLowerCase() + dayjs(ticket.date).format("dddd").toLowerCase() ].total = ret.seperatedThisWeek[ - moment(ticket.date).format("dddd").toLowerCase() + dayjs(ticket.date).format("dddd").toLowerCase() ].total + ticket.productivehrs; if (ticket.ciecacode !== "LAR") ret.seperatedThisWeek[ - moment(ticket.date).format("dddd").toLowerCase() + dayjs(ticket.date).format("dddd").toLowerCase() ].lab = ret.seperatedThisWeek[ - moment(ticket.date).format("dddd").toLowerCase() + dayjs(ticket.date).format("dddd").toLowerCase() ].lab + ticket.productivehrs; if (ticket.ciecacode === "LAR") ret.seperatedThisWeek[ - moment(ticket.date).format("dddd").toLowerCase() + dayjs(ticket.date).format("dddd").toLowerCase() ].lar = ret.seperatedThisWeek[ - moment(ticket.date).format("dddd").toLowerCase() + dayjs(ticket.date).format("dddd").toLowerCase() ].lar + ticket.productivehrs; } else if ( ticketDate.isBetween( @@ -280,7 +280,7 @@ export function ScoreboardTimeTicketsStats({ bodyshop }) { listOfDays.forEach((day) => { const r = { - date: moment(day).format("MM/DD"), + date: dayjs(day).format("MM/DD"), actualhrs: 0, productivehrs: 0, }; diff --git a/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.stats.component.jsx b/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.stats.component.jsx index 016bd137e..d0a2b9ea1 100644 --- a/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.stats.component.jsx +++ b/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.stats.component.jsx @@ -8,7 +8,7 @@ import { Switch, Typography, } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -49,8 +49,8 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { const statisticWeight = isLarge ? 550 : "normal"; const daySpan = Util.CalculateWorkingDaysInPeriod( - moment().startOf("week"), - moment().endOf("week") + dayjs().startOf("week"), + dayjs().endOf("week") ) > 5 ? 3 : 4; @@ -170,14 +170,14 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { parseFloat(data.totalThisWeek) >= Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyBodyTarget, - moment().startOf("week"), - moment().endOf("week"), + dayjs().startOf("week"), + dayjs().endOf("week"), bodyshop ) + Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyPaintTarget, - moment().startOf("week"), - moment().endOf("week"), + dayjs().startOf("week"), + dayjs().endOf("week"), bodyshop ) ? "green" @@ -202,8 +202,8 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { parseFloat(data.totalThisWeekLAB) >= Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyBodyTarget, - moment().startOf("week"), - moment().endOf("week"), + dayjs().startOf("week"), + dayjs().endOf("week"), bodyshop ) ? "green" @@ -226,8 +226,8 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { parseFloat(data.totalThisWeekLAR) >= Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyPaintTarget, - moment().startOf("week"), - moment().endOf("week"), + dayjs().startOf("week"), + dayjs().endOf("week"), bodyshop ) ? "green" @@ -252,14 +252,14 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { parseFloat(data.totalLastWeek) >= Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyBodyTarget, - moment().subtract(1, "week").startOf("week"), - moment().subtract(1, "week").endOf("week"), + dayjs().subtract(1, "week").startOf("week"), + dayjs().subtract(1, "week").endOf("week"), bodyshop ) + Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyPaintTarget, - moment().subtract(1, "week").startOf("week"), - moment().subtract(1, "week").endOf("week"), + dayjs().subtract(1, "week").startOf("week"), + dayjs().subtract(1, "week").endOf("week"), bodyshop ) ? "green" @@ -284,8 +284,8 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { parseFloat(data.totalLastWeekLAB) >= Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyBodyTarget, - moment().subtract(1, "week").startOf("week"), - moment().subtract(1, "week").endOf("week"), + dayjs().subtract(1, "week").startOf("week"), + dayjs().subtract(1, "week").endOf("week"), bodyshop ) ? "green" @@ -308,8 +308,8 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { parseFloat(data.totalLastWeekLAR) >= Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyPaintTarget, - moment().subtract(1, "week").startOf("week"), - moment().subtract(1, "week").endOf("week"), + dayjs().subtract(1, "week").startOf("week"), + dayjs().subtract(1, "week").endOf("week"), bodyshop ) ? "green" @@ -334,14 +334,14 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { parseFloat(data.totalPriorWeek) >= Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyBodyTarget, - moment().subtract(2, "week").startOf("week"), - moment().subtract(2, "week").endOf("week"), + dayjs().subtract(2, "week").startOf("week"), + dayjs().subtract(2, "week").endOf("week"), bodyshop ) + Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyPaintTarget, - moment().subtract(2, "week").startOf("week"), - moment().subtract(2, "week").endOf("week"), + dayjs().subtract(2, "week").startOf("week"), + dayjs().subtract(2, "week").endOf("week"), bodyshop ) ? "green" @@ -366,8 +366,8 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { parseFloat(data.totalPriorWeekLAB) >= Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyBodyTarget, - moment().subtract(2, "week").startOf("week"), - moment().subtract(2, "week").endOf("week"), + dayjs().subtract(2, "week").startOf("week"), + dayjs().subtract(2, "week").endOf("week"), bodyshop ) ? "green" @@ -390,8 +390,8 @@ export function ScoreboardTicketsStats({ data, bodyshop }) { parseFloat(data.totalPriorWeekLAR) >= Util.WeeklyTargetHrsInPeriod( bodyshop.scoreboard_target.dailyPaintTarget, - moment().subtract(2, "week").startOf("week"), - moment().subtract(2, "week").endOf("week"), + dayjs().subtract(2, "week").startOf("week"), + dayjs().subtract(2, "week").endOf("week"), bodyshop ) ? "green" diff --git a/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.targets-table.component.jsx b/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.targets-table.component.jsx index d7bab48ad..e9dc3b991 100644 --- a/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.targets-table.component.jsx +++ b/client/src/components/scoreboard-timetickets-stats/scoreboard-timetickets.targets-table.component.jsx @@ -1,6 +1,6 @@ import { CalendarOutlined } from "@ant-design/icons"; import { Card, Col, Divider, Row, Statistic } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -46,8 +46,8 @@ export function ScoreboardTimeticketsTargetsTable({ bodyshop }) { title={t("scoreboard.labels.thisweek")} value={Util.WeeklyTargetHrs( bodyshop.scoreboard_target.dailyBodyTarget, - moment().startOf("week"), - moment().endOf("week"), + dayjs().startOf("week"), + dayjs().endOf("week"), bodyshop )} /> @@ -57,8 +57,8 @@ export function ScoreboardTimeticketsTargetsTable({ bodyshop }) { title={t("scoreboard.labels.lastweek")} value={Util.WeeklyTargetHrs( bodyshop.scoreboard_target.dailyBodyTarget, - moment().subtract(1, "week").startOf("week"), - moment().subtract(1, "week").endOf("week"), + dayjs().subtract(1, "week").startOf("week"), + dayjs().subtract(1, "week").endOf("week"), bodyshop )} /> @@ -68,8 +68,8 @@ export function ScoreboardTimeticketsTargetsTable({ bodyshop }) { title={t("scoreboard.labels.priorweek")} value={Util.WeeklyTargetHrs( bodyshop.scoreboard_target.dailyBodyTarget, - moment().subtract(2, "week").startOf("week"), - moment().subtract(2, "week").endOf("week"), + dayjs().subtract(2, "week").startOf("week"), + dayjs().subtract(2, "week").endOf("week"), bodyshop )} /> @@ -113,8 +113,8 @@ export function ScoreboardTimeticketsTargetsTable({ bodyshop }) { @@ -123,8 +123,8 @@ export function ScoreboardTimeticketsTargetsTable({ bodyshop }) { @@ -133,8 +133,8 @@ export function ScoreboardTimeticketsTargetsTable({ bodyshop }) { @@ -182,14 +182,14 @@ export function ScoreboardTimeticketsTargetsTable({ bodyshop }) { value={( Util.WeeklyTargetHrs( bodyshop.scoreboard_target.dailyBodyTarget, - moment().startOf("week"), - moment().endOf("week"), + dayjs().startOf("week"), + dayjs().endOf("week"), bodyshop ) + Util.WeeklyTargetHrs( bodyshop.scoreboard_target.dailyPaintTarget, - moment().startOf("week"), - moment().endOf("week"), + dayjs().startOf("week"), + dayjs().endOf("week"), bodyshop ) ).toFixed(1)} @@ -200,14 +200,14 @@ export function ScoreboardTimeticketsTargetsTable({ bodyshop }) { value={( Util.WeeklyTargetHrs( bodyshop.scoreboard_target.dailyBodyTarget, - moment().subtract(1, "week").startOf("week"), - moment().subtract(1, "week").endOf("week"), + dayjs().subtract(1, "week").startOf("week"), + dayjs().subtract(1, "week").endOf("week"), bodyshop ) + Util.WeeklyTargetHrs( bodyshop.scoreboard_target.dailyPaintTarget, - moment().subtract(1, "week").startOf("week"), - moment().subtract(1, "week").endOf("week"), + dayjs().subtract(1, "week").startOf("week"), + dayjs().subtract(1, "week").endOf("week"), bodyshop ) ).toFixed(1)} @@ -218,14 +218,14 @@ export function ScoreboardTimeticketsTargetsTable({ bodyshop }) { value={( Util.WeeklyTargetHrs( bodyshop.scoreboard_target.dailyBodyTarget, - moment().subtract(2, "week").startOf("week"), - moment().subtract(2, "week").endOf("week"), + dayjs().subtract(2, "week").startOf("week"), + dayjs().subtract(2, "week").endOf("week"), bodyshop ) + Util.WeeklyTargetHrs( bodyshop.scoreboard_target.dailyPaintTarget, - moment().subtract(2, "week").startOf("week"), - moment().subtract(2, "week").endOf("week"), + dayjs().subtract(2, "week").startOf("week"), + dayjs().subtract(2, "week").endOf("week"), bodyshop ) ).toFixed(1)} diff --git a/client/src/components/scoreboard-timetickets/scoreboard-timetickets.component.jsx b/client/src/components/scoreboard-timetickets/scoreboard-timetickets.component.jsx index 0fc84af6d..b764e2bc7 100644 --- a/client/src/components/scoreboard-timetickets/scoreboard-timetickets.component.jsx +++ b/client/src/components/scoreboard-timetickets/scoreboard-timetickets.component.jsx @@ -1,7 +1,7 @@ import { useQuery } from "@apollo/client"; import { Col, Row } from "antd"; import _ from "lodash"; -import moment from "moment"; +import dayjs from "../../utils/day"; import queryString from "query-string"; import React, { useMemo } from "react"; import { useLocation } from "react-router-dom"; @@ -16,22 +16,22 @@ export default function ScoreboardTimeTickets() { const searchParams = queryString.parse(useLocation().search); const { start, end } = searchParams; const startDate = start - ? moment(start) - : moment().startOf("week").subtract(7, "days"); - const endDate = end ? moment(end) : moment().endOf("week"); + ? dayjs(start) + : dayjs().startOf("week").subtract(7, "days"); + const endDate = end ? dayjs(end) : dayjs().endOf("week"); const fixedPeriods = useMemo(() => { - const endOfThisMonth = moment().endOf("month"); - const startofthisMonth = moment().startOf("month"); + const endOfThisMonth = dayjs().endOf("month"); + const startofthisMonth = dayjs().startOf("month"); - const endOfLastmonth = moment().subtract(1, "month").endOf("month"); - const startOfLastmonth = moment().subtract(1, "month").startOf("month"); + const endOfLastmonth = dayjs().subtract(1, "month").endOf("month"); + const startOfLastmonth = dayjs().subtract(1, "month").startOf("month"); - const endOfThisWeek = moment().endOf("week"); - const startOfThisWeek = moment().startOf("week"); + const endOfThisWeek = dayjs().endOf("week"); + const startOfThisWeek = dayjs().startOf("week"); - const endOfLastWeek = moment().subtract(1, "week").endOf("week"); - const startOfLastWeek = moment().subtract(1, "week").startOf("week"); + const endOfLastWeek = dayjs().subtract(1, "week").endOf("week"); + const startOfLastWeek = dayjs().subtract(1, "week").startOf("week"); const allDates = [ endOfThisMonth, @@ -43,8 +43,8 @@ export default function ScoreboardTimeTickets() { endOfLastWeek, startOfLastWeek, ]; - const start = moment.min(allDates); - const end = moment.max(allDates); + const start = dayjs.min(allDates); + const end = dayjs.max(allDates); return { start, end, @@ -85,7 +85,7 @@ export default function ScoreboardTimeTickets() { employees: {}, }; data.fixedperiod.forEach((ticket) => { - const ticketDate = moment(ticket.date); + const ticketDate = dayjs(ticket.date); if (!ret.employees[ticket.employee.employee_number]) { ret.employees[ticket.employee.employee_number] = { @@ -167,7 +167,7 @@ export default function ScoreboardTimeTickets() { listOfDays.forEach((day) => { const r = { - date: moment(day).format("MM/DD"), + date: dayjs(day).format("MM/DD"), actualtotal: 0, productivetotal: 0, employees: {}, diff --git a/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx b/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx index 01d115f6a..3b293f8b2 100644 --- a/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx +++ b/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx @@ -1,6 +1,6 @@ import { useMutation } from "@apollo/client"; import { Button, Card, Form, notification, Popover, Space } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { logImEXEvent } from "../../firebase/firebase.utils"; @@ -78,7 +78,7 @@ export default function ShopEmployeeAddVacation({ employee }) { async validator(rule, value) { if (value) { const { start } = form.getFieldsValue(); - if (moment(start).isAfter(moment(value))) { + if (dayjs(start).isAfter(dayjs(value))) { return Promise.reject( t("employees.labels.endmustbeafterstart") ); diff --git a/client/src/components/shop-employees/shop-employees-form.component.jsx b/client/src/components/shop-employees/shop-employees-form.component.jsx index ab855ee28..2778d00ba 100644 --- a/client/src/components/shop-employees/shop-employees-form.component.jsx +++ b/client/src/components/shop-employees/shop-employees-form.component.jsx @@ -12,7 +12,7 @@ import { Table, } from "antd"; import { useForm } from "antd/es/form/Form"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -132,7 +132,7 @@ export function ShopEmployeesFormComponent({ bodyshop }) { dataIndex: "length", key: "length", render: (text, record) => - moment(record.end).diff(moment(record.start), "days", true).toFixed(1), + dayjs(record.end).diff(dayjs(record.start), "days", true).toFixed(1), }, { title: t("general.labels.actions"), diff --git a/client/src/components/shop-info/shop-info.container.jsx b/client/src/components/shop-info/shop-info.container.jsx index dd254a4cb..5708d72fd 100644 --- a/client/src/components/shop-info/shop-info.container.jsx +++ b/client/src/components/shop-info/shop-info.container.jsx @@ -1,6 +1,6 @@ import { useMutation, useQuery } from "@apollo/client"; import { Form, notification } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { logImEXEvent } from "../../firebase/firebase.utils"; @@ -58,21 +58,21 @@ export default function ShopInfoContainer() { accountingconfig: { ...data.bodyshops[0].accountingconfig, ClosingPeriod: [ - moment(data.bodyshops[0].accountingconfig.ClosingPeriod[0]), - moment(data.bodyshops[0].accountingconfig.ClosingPeriod[1]), + dayjs(data.bodyshops[0].accountingconfig.ClosingPeriod[0]), + dayjs(data.bodyshops[0].accountingconfig.ClosingPeriod[1]), ], }, - schedule_start_time: moment( + schedule_start_time: dayjs( data.bodyshops[0].schedule_start_time ), - schedule_end_time: moment(data.bodyshops[0].schedule_end_time), + schedule_end_time: dayjs(data.bodyshops[0].schedule_end_time), } : { ...data.bodyshops[0], - schedule_start_time: moment( + schedule_start_time: dayjs( data.bodyshops[0].schedule_start_time ), - schedule_end_time: moment(data.bodyshops[0].schedule_end_time), + schedule_end_time: dayjs(data.bodyshops[0].schedule_end_time), } : null } diff --git a/client/src/components/shop-info/shop-info.general.component.jsx b/client/src/components/shop-info/shop-info.general.component.jsx index 5f7d31c03..546d21796 100644 --- a/client/src/components/shop-info/shop-info.general.component.jsx +++ b/client/src/components/shop-info/shop-info.general.component.jsx @@ -11,7 +11,6 @@ import { Space, Switch, } from "antd"; -import momentTZ from "moment-timezone"; import React from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -25,7 +24,8 @@ import PhoneFormItem, { } from "../form-items-formatted/phone-form-item.component"; import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; -const timeZonesList = momentTZ.tz.names(); +// TODO: Client Update, this might break +const timeZonesList = Intl.supportedValuesOf('timeZone'); const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, }); diff --git a/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx b/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx index 3d7c88635..e500c1f8d 100644 --- a/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx +++ b/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx @@ -1,8 +1,7 @@ import { useMutation } from "@apollo/client"; import { Button, Card, Form, notification, Space } from "antd"; import axios from "axios"; -import moment from "moment"; -import momenttz from "moment-timezone"; +import dayjs from "../../utils/day"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -58,13 +57,14 @@ export function TechClockInContainer({ employeeid: technician.id, date: typeof bodyshop.timezone === "string" - ? momenttz.tz(theTime, bodyshop.timezone).format("YYYY-MM-DD") + // TODO: Client Update - This may be broken + ? dayjs.tz(theTime, bodyshop.timezone).format("YYYY-MM-DD") : typeof bodyshop.timezone === "number" - ? moment(theTime) + ? dayjs(theTime) .format("YYYY-MM-DD") .utcOffset(bodyshop.timezone) - : moment(theTime).format("YYYY-MM-DD"), - clockon: moment(theTime), + : dayjs(theTime).format("YYYY-MM-DD"), + clockon: dayjs(theTime), jobid: values.jobid, cost_center: values.cost_center, ciecacode: diff --git a/client/src/components/tech-job-print-tickets/tech-job-print-tickets.component.jsx b/client/src/components/tech-job-print-tickets/tech-job-print-tickets.component.jsx index 2378048e3..4cc1b9eed 100644 --- a/client/src/components/tech-job-print-tickets/tech-job-print-tickets.component.jsx +++ b/client/src/components/tech-job-print-tickets/tech-job-print-tickets.component.jsx @@ -1,5 +1,5 @@ import { Button, Card, DatePicker, Form, Popover, Radio, Space } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -51,13 +51,13 @@ export function TechJobPrintTickets({ technician, event, attendacePrint }) { : Templates.timetickets_employee.key, variables: { ...(start - ? { start: moment(start).startOf("day").format("YYYY-MM-DD") } + ? { start: dayjs(start).startOf("day").format("YYYY-MM-DD") } : {}), ...(end - ? { end: moment(end).endOf("day").format("YYYY-MM-DD") } + ? { end: dayjs(end).endOf("day").format("YYYY-MM-DD") } : {}), - ...(start ? { starttz: moment(start).startOf("day") } : {}), - ...(end ? { endtz: moment(end).endOf("day") } : {}), + ...(start ? { starttz: dayjs(start).startOf("day") } : {}), + ...(end ? { endtz: dayjs(end).endOf("day") } : {}), id: technician.id, }, diff --git a/client/src/components/tech-job-statistics/tech-job-statistics.component.jsx b/client/src/components/tech-job-statistics/tech-job-statistics.component.jsx index df7f2af75..479aacb33 100644 --- a/client/src/components/tech-job-statistics/tech-job-statistics.component.jsx +++ b/client/src/components/tech-job-statistics/tech-job-statistics.component.jsx @@ -1,6 +1,6 @@ import { useQuery } from "@apollo/client"; import { Card, Col, Space, Statistic, Typography } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -19,8 +19,8 @@ const mapDispatchToProps = (dispatch) => ({}); const TechJobStatistics = ({ technician }) => { const { t } = useTranslation(); - const startDate = moment().startOf("week"); - const endDate = moment().endOf("week"); + const startDate = dayjs().startOf("week"); + const endDate = dayjs().endOf("week"); const { loading, error, data } = useQuery( QUERY_TIME_TICKETS_TECHNICIAN_IN_RANGE, @@ -28,8 +28,8 @@ const TechJobStatistics = ({ technician }) => { variables: { start: startDate.format("YYYY-MM-DD"), end: endDate.format("YYYY-MM-DD"), - fixedStart: moment().startOf("month").format("YYYY-MM-DD"), - fixedEnd: moment().endOf("month").format("YYYY-MM-DD"), + fixedStart: dayjs().startOf("month").format("YYYY-MM-DD"), + fixedEnd: dayjs().endOf("month").format("YYYY-MM-DD"), employeeid: technician.id, }, fetchPolicy: "network-only", diff --git a/client/src/components/ticket-tickets-dates-selector/time-tickets-dates-selector.component.jsx b/client/src/components/ticket-tickets-dates-selector/time-tickets-dates-selector.component.jsx index d1066daf7..3b5932fba 100644 --- a/client/src/components/ticket-tickets-dates-selector/time-tickets-dates-selector.component.jsx +++ b/client/src/components/ticket-tickets-dates-selector/time-tickets-dates-selector.component.jsx @@ -1,6 +1,6 @@ import DatePickerRanges from "../../utils/DatePickerRanges"; import { DatePicker } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import queryString from "query-string"; import React from "react"; import { useNavigate, useLocation } from "react-router-dom"; @@ -37,8 +37,8 @@ export default function TimeTicketsDatesSelector() { return ( - {moment(record.clockoff) - .diff(moment(record.clockon), "hours", true) + {dayjs(record.clockoff) + .diff(dayjs(record.clockon), "hours", true) .toFixed(2)}
); diff --git a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx index 6df9f2b9f..01c273486 100644 --- a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx +++ b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx @@ -291,6 +291,7 @@ export function TimeTicketModalComponent({ return Promise.reject( t("timetickets.validation.clockoffwithoutclockon") ); + // TODO - Verify this exists if ( value && value.isSameOrAfter && diff --git a/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx b/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx index de2abff5e..c365ff5ca 100644 --- a/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx +++ b/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx @@ -1,7 +1,7 @@ import { useMutation, useQuery } from "@apollo/client"; import { Button, Form, Modal, Space, notification } from "antd"; import {PageHeader} from "@ant-design/pro-layout"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -210,7 +210,7 @@ export function TimeTicketModalContainer({ timeTicketModal.context.timeticket.jobid || null, date: timeTicketModal.context.timeticket.date - ? moment(timeTicketModal.context.timeticket.date) + ? dayjs(timeTicketModal.context.timeticket.date) : null, } : { jobid: timeTicketModal.context.jobId || null } diff --git a/client/src/components/time-ticket-shift-form/time-ticket-shift-form.container.jsx b/client/src/components/time-ticket-shift-form/time-ticket-shift-form.container.jsx index 8c3c3cd0d..759840780 100644 --- a/client/src/components/time-ticket-shift-form/time-ticket-shift-form.container.jsx +++ b/client/src/components/time-ticket-shift-form/time-ticket-shift-form.container.jsx @@ -1,8 +1,7 @@ import { useMutation } from "@apollo/client"; import { Button, Form, Space, notification } from "antd"; import axios from "axios"; -import moment from "moment"; -import momenttz from "moment-timezone"; +import dayjs from "../../utils/day"; import React, { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -59,7 +58,7 @@ export function TimeTicektShiftContainer({ message: t("timetickets.errors.shiftalreadyclockedon"), }); } else { - const theTime = moment((await axios.post("/utils/time")).data); + const theTime = dayjs((await axios.post("/utils/time")).data); const result = await insertTimeTicket({ variables: { @@ -71,12 +70,13 @@ export function TimeTicektShiftContainer({ clockon: theTime, date: typeof bodyshop.timezone === "string" - ? momenttz.tz(theTime, bodyshop.timezone).format("YYYY-MM-DD") + // TODO: Client Update - This may be broken + ? dayjs.tz(theTime, bodyshop.timezone).format("YYYY-MM-DD") : typeof bodyshop.timezone === "number" - ? moment(theTime) + ? dayjs(theTime) .utcOffset(bodyshop.timezone) .format("YYYY-MM-DD") - : moment(theTime).format("YYYY-MM-DD"), + : dayjs(theTime).format("YYYY-MM-DD"), memo: values.memo, created_by: isTechConsole ? currentUser.email.concat( diff --git a/client/src/components/time-tickets-attendance-table/time-tickets-attendance-table.component.jsx b/client/src/components/time-tickets-attendance-table/time-tickets-attendance-table.component.jsx index ce7c4b34f..b30f62b7d 100644 --- a/client/src/components/time-tickets-attendance-table/time-tickets-attendance-table.component.jsx +++ b/client/src/components/time-tickets-attendance-table/time-tickets-attendance-table.component.jsx @@ -5,7 +5,7 @@ import { useLocation } from "react-router-dom"; import { GenerateDocument } from "../../utils/RenderTemplate"; import { TemplateList } from "../../utils/TemplateConstants"; import { useTranslation } from "react-i18next"; -import moment from "moment"; +import dayjs from "../../utils/day"; const AttendanceCsv = TemplateList("special").attendance_detail_csv; export default function TimeTicketsAttendanceTable() { @@ -23,8 +23,8 @@ export default function TimeTicketsAttendanceTable() { variables: { start: start ? start - : moment().startOf("week").subtract(7, "days").format("YYYY-MM-DD"), - end: end ? end : moment().endOf("week").format("YYYY-MM-DD"), + : dayjs().startOf("week").subtract(7, "days").format("YYYY-MM-DD"), + end: end ? end : dayjs().endOf("week").format("YYYY-MM-DD"), }, }, {}, diff --git a/client/src/components/time-tickets-payroll-table/time-tickets-payroll-table.component.jsx b/client/src/components/time-tickets-payroll-table/time-tickets-payroll-table.component.jsx index 731d94273..2083b15dc 100644 --- a/client/src/components/time-tickets-payroll-table/time-tickets-payroll-table.component.jsx +++ b/client/src/components/time-tickets-payroll-table/time-tickets-payroll-table.component.jsx @@ -5,7 +5,7 @@ import { useLocation } from "react-router-dom"; import { GenerateDocument } from "../../utils/RenderTemplate"; import { TemplateList } from "../../utils/TemplateConstants"; import { useTranslation } from "react-i18next"; -import moment from "moment"; +import dayjs from "../../utils/day"; const PayrollTemplate = TemplateList("special").exported_payroll; export default function TimeTicketsPayrollTable() { const searchParams = queryString.parse(useLocation().search); @@ -22,8 +22,8 @@ export default function TimeTicketsPayrollTable() { variables: { start: start ? start - : moment().startOf("week").subtract(7, "days").format("YYYY-MM-DD"), - end: end ? end : moment().endOf("week").format("YYYY-MM-DD"), + : dayjs().startOf("week").subtract(7, "days").format("YYYY-MM-DD"), + end: end ? end : dayjs().endOf("week").format("YYYY-MM-DD"), }, }, {}, diff --git a/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx b/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx index b51d45680..a6745aee7 100644 --- a/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx +++ b/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx @@ -1,6 +1,6 @@ import { Card, Col, Row, Table } from "antd"; import _ from "lodash"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -124,7 +124,7 @@ const JobRelatedTicketsTable = ({ if (!!val.clockoff && !!val.clockon) return ( acc + - moment(val.clockoff).diff(moment(val.clockon), "hours", true) + dayjs(val.clockoff).diff(dayjs(val.clockon), "hours", true) ); return acc; }, 0); @@ -251,7 +251,7 @@ const ShiftRelatedTicketsTable = ({ const clockHrs = item.tickets.reduce((acc, val) => { if (!!val.clockoff && !!val.clockon) return ( - acc + moment(val.clockoff).diff(moment(val.clockon), "hours", true) + acc + dayjs(val.clockoff).diff(dayjs(val.clockon), "hours", true) ); return acc; }, 0); diff --git a/client/src/components/vehicle-detail-form/vehicle-detail-form.container.jsx b/client/src/components/vehicle-detail-form/vehicle-detail-form.container.jsx index 22e72c673..0fc7f9cd1 100644 --- a/client/src/components/vehicle-detail-form/vehicle-detail-form.container.jsx +++ b/client/src/components/vehicle-detail-form/vehicle-detail-form.container.jsx @@ -4,7 +4,7 @@ import {PageHeader} from "@ant-design/pro-layout"; import { useMutation } from "@apollo/client"; import VehicleDetailFormComponent from "./vehicle-detail-form.component"; import { useTranslation } from "react-i18next"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { DELETE_VEHICLE, UPDATE_VEHICLE } from "../../graphql/vehicles.queries"; import { useNavigate } from "react-router-dom"; @@ -97,7 +97,7 @@ function VehicleDetailFormContainer({ vehicle, refetch }) { layout="vertical" initialValues={{ ...vehicle, - v_prod_dt: vehicle.v_prod_dt ? moment(vehicle.v_prod_dt) : null, + v_prod_dt: vehicle.v_prod_dt ? dayjs(vehicle.v_prod_dt) : null, }} > diff --git a/client/src/pages/contract-detail/contract-detail.page.container.jsx b/client/src/pages/contract-detail/contract-detail.page.container.jsx index 86d5148b1..84058f39d 100644 --- a/client/src/pages/contract-detail/contract-detail.page.container.jsx +++ b/client/src/pages/contract-detail/contract-detail.page.container.jsx @@ -1,6 +1,6 @@ import { useMutation, useQuery } from "@apollo/client"; import { Form, notification } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -139,19 +139,19 @@ export function ContractDetailPageContainer({ initialValues={{ ...data.cccontracts_by_pk, start: data.cccontracts_by_pk.start - ? moment(data.cccontracts_by_pk.start) + ? dayjs(data.cccontracts_by_pk.start) : null, scheduledreturn: data.cccontracts_by_pk.scheduledreturn - ? moment(data.cccontracts_by_pk.scheduledreturn) + ? dayjs(data.cccontracts_by_pk.scheduledreturn) : null, actualreturn: data.cccontracts_by_pk.actualreturn - ? moment(data.cccontracts_by_pk.actualreturn) + ? dayjs(data.cccontracts_by_pk.actualreturn) : null, driver_dlexpiry: data.cccontracts_by_pk.driver_dlexpiry - ? moment(data.cccontracts_by_pk.driver_dlexpiry) + ? dayjs(data.cccontracts_by_pk.driver_dlexpiry) : null, driver_dob: data.cccontracts_by_pk.driver_dob - ? moment(data.cccontracts_by_pk.driver_dob) + ? dayjs(data.cccontracts_by_pk.driver_dob) : null, }} > diff --git a/client/src/pages/courtesy-car-detail/courtesy-car-detail.page.container.jsx b/client/src/pages/courtesy-car-detail/courtesy-car-detail.page.container.jsx index 92e176960..ba2bb5501 100644 --- a/client/src/pages/courtesy-car-detail/courtesy-car-detail.page.container.jsx +++ b/client/src/pages/courtesy-car-detail/courtesy-car-detail.page.container.jsx @@ -1,6 +1,6 @@ import { useMutation, useQuery } from "@apollo/client"; import { Form, notification } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -154,25 +154,25 @@ export function CourtesyCarDetailPageContainer({ ? { ...data.courtesycars_by_pk, purchasedate: data.courtesycars_by_pk.purchasedate - ? moment(data.courtesycars_by_pk.purchasedate) + ? dayjs(data.courtesycars_by_pk.purchasedate) : null, servicestartdate: data.courtesycars_by_pk.servicestartdate - ? moment(data.courtesycars_by_pk.servicestartdate) + ? dayjs(data.courtesycars_by_pk.servicestartdate) : null, serviceenddate: data.courtesycars_by_pk.serviceenddate - ? moment(data.courtesycars_by_pk.serviceenddate) + ? dayjs(data.courtesycars_by_pk.serviceenddate) : null, leaseenddate: data.courtesycars_by_pk.leaseenddate - ? moment(data.courtesycars_by_pk.leaseenddate) + ? dayjs(data.courtesycars_by_pk.leaseenddate) : null, nextservicedate: data.courtesycars_by_pk.nextservicedate - ? moment(data.courtesycars_by_pk.nextservicedate) + ? dayjs(data.courtesycars_by_pk.nextservicedate) : null, registrationexpires: data.courtesycars_by_pk.registrationexpires - ? moment(data.courtesycars_by_pk.registrationexpires) + ? dayjs(data.courtesycars_by_pk.registrationexpires) : null, insuranceexpires: data.courtesycars_by_pk.insuranceexpires - ? moment(data.courtesycars_by_pk.insuranceexpires) + ? dayjs(data.courtesycars_by_pk.insuranceexpires) : null, } : {} diff --git a/client/src/pages/jobs-checklist-view/jobs-checklist-view.page.jsx b/client/src/pages/jobs-checklist-view/jobs-checklist-view.page.jsx index d53a83a90..d0999dd72 100644 --- a/client/src/pages/jobs-checklist-view/jobs-checklist-view.page.jsx +++ b/client/src/pages/jobs-checklist-view/jobs-checklist-view.page.jsx @@ -1,6 +1,6 @@ import { useQuery } from "@apollo/client"; import { Col, Row, Typography } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -66,7 +66,7 @@ export function JobsChecklistViewContainer({
{t("jobs.labels.checklistcompletedby", { by: checklist.completed_by, - at: moment(checklist.completed_at).format("MM/DD/YYYY @ h:mm a"), + at: dayjs(checklist.completed_at).format("MM/DD/YYYY @ h:mm a"), })}
diff --git a/client/src/pages/jobs-close/jobs-close.component.jsx b/client/src/pages/jobs-close/jobs-close.component.jsx index 892fe3458..6ef38b23c 100644 --- a/client/src/pages/jobs-close/jobs-close.component.jsx +++ b/client/src/pages/jobs-close/jobs-close.component.jsx @@ -25,7 +25,7 @@ import { connect } from "react-redux"; // import { useNavigate } from 'react-router-dom'; import { useTreatments } from "@splitsoftware/splitio-react"; import Dinero from "dinero.js"; -import moment from "moment"; +import dayjs from "../../utils/day"; import { Link } from "react-router-dom"; import { createStructuredSelector } from "reselect"; import DateTimePicker from "../../components/form-date-time-picker/form-date-time-picker.component"; @@ -137,17 +137,17 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) { initialValues={{ joblines: job.joblines, actual_in: job.actual_in - ? moment(job.actual_in) - : job.scheduled_in && moment(job.scheduled_in), + ? dayjs(job.actual_in) + : job.scheduled_in && dayjs(job.scheduled_in), actual_completion: job.actual_completion - ? moment(job.actual_completion) - : job.scheduled_completion && moment(job.scheduled_completion), + ? dayjs(job.actual_completion) + : job.scheduled_completion && dayjs(job.scheduled_completion), actual_delivery: job.actual_delivery - ? moment(job.actual_delivery) - : job.scheduled_delivery && moment(job.scheduled_delivery), + ? dayjs(job.actual_delivery) + : job.scheduled_delivery && dayjs(job.scheduled_delivery), date_invoiced: job.date_invoiced - ? moment(job.date_invoiced) - : moment(), + ? dayjs(job.date_invoiced) + : dayjs(), kmin: job.kmin, kmout: job.kmout, dms_allocation: job.dms_allocation, @@ -259,7 +259,7 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) { ({ getFieldValue }) => ({ validator(_, value) { if (!bodyshop.cdk_dealerid) return Promise.resolve(); - if (!value || moment(value).isSameOrAfter(moment(), "day")) { + if (!value || dayjs(value).isSameOrAfter(dayjs(), "day")) { return Promise.resolve(); } return Promise.reject( @@ -274,13 +274,13 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) { bodyshop.accountingconfig.ClosingPeriod ) { if ( - moment(value).isSameOrAfter( - moment( + dayjs(value).isSameOrAfter( + dayjs( bodyshop.accountingconfig.ClosingPeriod[0] ).startOf("day") ) && - moment(value).isSameOrBefore( - moment( + dayjs(value).isSameOrBefore( + dayjs( bodyshop.accountingconfig.ClosingPeriod[1] ).endOf("day") ) diff --git a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx index 52edabf11..2fc49b530 100644 --- a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx +++ b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx @@ -19,7 +19,7 @@ import { import {PageHeader} from "@ant-design/pro-layout"; import Axios from "axios"; -import moment from "moment"; +import dayjs from "../../utils/day"; import queryString from "query-string"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -172,7 +172,7 @@ export function JobsDetailPage({ jobid: job.id, operation: AuditTrailMapping.jobfieldchange( key, - changedAuditFields[key] instanceof moment + changedAuditFields[key] instanceof dayjs ? DateTimeFormat(changedAuditFields[key]) : changedAuditFields[key] ), @@ -392,7 +392,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(JobsDetailPage); const transormJobToForm = (job) => { return { ...job, - loss_date: job.loss_date ? moment(job.loss_date) : null, - date_estimated: job.date_estimated ? moment(job.date_estimated) : null, + loss_date: job.loss_date ? dayjs(job.loss_date) : null, + date_estimated: job.date_estimated ? dayjs(job.date_estimated) : null, }; }; diff --git a/client/src/pages/time-tickets/time-tickets.container.jsx b/client/src/pages/time-tickets/time-tickets.container.jsx index bb9f6c2d1..e07289ea8 100644 --- a/client/src/pages/time-tickets/time-tickets.container.jsx +++ b/client/src/pages/time-tickets/time-tickets.container.jsx @@ -1,6 +1,6 @@ import { useQuery } from "@apollo/client"; import { Col, Row, Space } from "antd"; -import moment from "moment"; +import dayjs from "../../utils/day"; import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -36,9 +36,9 @@ export function TimeTicketsContainer({ const { start, end } = Object.fromEntries(searchParams); const startDate = start - ? moment(start) - : moment().startOf("week").subtract(7, "days"); - const endDate = end ? moment(end) : moment().endOf("week"); + ? dayjs(start) + : dayjs().startOf("week").subtract(7, "days"); + const endDate = end ? dayjs(end) : dayjs().endOf("week"); const { loading, error, data } = useQuery(QUERY_TIME_TICKETS_IN_RANGE, { variables: { diff --git a/client/src/redux/application/application.sagas.js b/client/src/redux/application/application.sagas.js index 447fed0e6..4c5f6c426 100644 --- a/client/src/redux/application/application.sagas.js +++ b/client/src/redux/application/application.sagas.js @@ -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]) { diff --git a/client/src/redux/user/user.sagas.js b/client/src/redux/user/user.sagas.js index 4b071362a..03c217df0 100644 --- a/client/src/redux/user/user.sagas.js +++ b/client/src/redux/user/user.sagas.js @@ -268,7 +268,7 @@ export function* SetAuthLevelFromShopDetails({ payload }) { const userEmail = yield select((state) => state.user.currentUser.email); try { //console.log("Setting shop timezone."); - // moment.tz.setDefault(payload.timezone); + // dayjs.tz.setDefault(payload.timezone); } catch (error) { console.log(error); } diff --git a/client/src/utils/DateFormatter.jsx b/client/src/utils/DateFormatter.jsx index d034266e3..b7275b772 100644 --- a/client/src/utils/DateFormatter.jsx +++ b/client/src/utils/DateFormatter.jsx @@ -1,10 +1,10 @@ import { Tooltip } from "antd"; -import moment from "moment"; +import dayjs from "../utils/day"; import React from "react"; export function DateFormatter(props) { return props.children - ? moment(props.children).format( + ? dayjs(props.children).format( props.includeDay ? "ddd MM/DD/YYYY" : "MM/DD/YYYY" ) : null; @@ -12,19 +12,19 @@ export function DateFormatter(props) { export function DateTimeFormatter(props) { return props.children - ? moment(props.children).format( + ? dayjs(props.children).format( props.format ? props.format : "MM/DD/YYYY hh:mm a" ) : null; } export function TimeFormatter(props) { return props.children - ? moment(props.children).format(props.format ? props.format : "hh:mm a") + ? dayjs(props.children).format(props.format ? props.format : "hh:mm a") : null; } export function TimeAgoFormatter(props) { - const m = moment(props.children); + const m = dayjs(props.children); return props.children ? ( {m.fromNow()} @@ -33,5 +33,5 @@ export function TimeAgoFormatter(props) { } export function DateTimeFormat(value) { - return moment(value).format("MM/DD/YYYY hh:mm A"); + return dayjs(value).format("MM/DD/YYYY hh:mm A"); } diff --git a/client/src/utils/DatePickerRanges.js b/client/src/utils/DatePickerRanges.js index aeed206c5..e86287686 100644 --- a/client/src/utils/DatePickerRanges.js +++ b/client/src/utils/DatePickerRanges.js @@ -1,27 +1,27 @@ -import moment from "moment"; +import dayjs from "./day"; const range = { - 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, "days"), dayjs()], + "Last 7 days": [dayjs().subtract(7, "days"), dayjs()], + "Next 7 days": [dayjs(), dayjs().add(7, "days")], + "Next 14 days": [dayjs(), dayjs().add(14, "days")], "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")], + "This 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, "quarters"), + dayjs().startOf("quarter").subtract(1, "day"), ], "This Quarter": [ - moment().startOf("quarter"), - moment().startOf("quarter").add(1, "quarter").subtract(1, "day"), + dayjs().startOf("quarter"), + dayjs().startOf("quarter").add(1, "quarter").subtract(1, "day"), ], - "Last 90 Days": [moment().add(-90, "days"), moment()], + "Last 90 Days": [dayjs().add(-90, "days"), dayjs()], }; export default range; diff --git a/client/src/utils/RenderTemplate.js b/client/src/utils/RenderTemplate.js index 8cb4691fe..4d20dc117 100644 --- a/client/src/utils/RenderTemplate.js +++ b/client/src/utils/RenderTemplate.js @@ -73,7 +73,7 @@ export default async function RenderTemplate( headerpath: `/${bodyshop.imexshopid}/header.html`, footerpath: `/${bodyshop.imexshopid}/footer.html`, bodyshop: bodyshop, - offset: bodyshop.timezone, //moment().utcOffset(), + offset: bodyshop.timezone, //dayjs().utcOffset(), }, }; diff --git a/client/src/utils/day.js b/client/src/utils/day.js new file mode 100644 index 000000000..9ee744acc --- /dev/null +++ b/client/src/utils/day.js @@ -0,0 +1,15 @@ +import dayjs from 'dayjs'; +import dayjsBusinessDays from "dayjs-business-days2"; +import isSameOrAfter from "dayjs/plugin/isSameOrAfter"; +import isSameOrBefore from "dayjs/plugin/isSameOrBefore"; +import timezone from 'dayjs/plugin/timezone'; +import utc from 'dayjs/plugin/utc'; + +dayjs.extend(utc); +dayjs.extend(timezone); +dayjs.extend(dayjsBusinessDays); +dayjs.extend(isSameOrAfter); +dayjs.extend(isSameOrBefore); + + +export default dayjs; \ No newline at end of file