IO-1671 Improved date handling for form item.
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||||
import { Button, Result } from "antd";
|
import { Button, Result } from "antd";
|
||||||
|
import LogRocket from "logrocket";
|
||||||
import React, { lazy, Suspense, useEffect } from "react";
|
import React, { lazy, Suspense, useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -6,11 +8,10 @@ import { Route, Switch } from "react-router-dom";
|
|||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import DocumentEditorContainer from "../components/document-editor/document-editor.container";
|
import DocumentEditorContainer from "../components/document-editor/document-editor.container";
|
||||||
import ErrorBoundary from "../components/error-boundary/error-boundary.component";
|
import ErrorBoundary from "../components/error-boundary/error-boundary.component";
|
||||||
import LogRocket from "logrocket";
|
|
||||||
|
|
||||||
//Component Imports
|
//Component Imports
|
||||||
import LoadingSpinner from "../components/loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../components/loading-spinner/loading-spinner.component";
|
||||||
import DisclaimerPage from "../pages/disclaimer/disclaimer.page";
|
import DisclaimerPage from "../pages/disclaimer/disclaimer.page";
|
||||||
|
import LandingPage from "../pages/landing/landing.page";
|
||||||
import TechPageContainer from "../pages/tech/tech.page.container";
|
import TechPageContainer from "../pages/tech/tech.page.container";
|
||||||
import { setOnline } from "../redux/application/application.actions";
|
import { setOnline } from "../redux/application/application.actions";
|
||||||
import { selectOnline } from "../redux/application/application.selectors";
|
import { selectOnline } from "../redux/application/application.selectors";
|
||||||
@@ -22,8 +23,6 @@ import {
|
|||||||
import PrivateRoute from "../utils/private-route";
|
import PrivateRoute from "../utils/private-route";
|
||||||
import "./App.styles.scss";
|
import "./App.styles.scss";
|
||||||
|
|
||||||
import LandingPage from "../pages/landing/landing.page";
|
|
||||||
import { useTreatments } from "@splitsoftware/splitio-react";
|
|
||||||
const ResetPassword = lazy(() =>
|
const ResetPassword = lazy(() =>
|
||||||
import("../pages/reset-password/reset-password.component")
|
import("../pages/reset-password/reset-password.component")
|
||||||
);
|
);
|
||||||
@@ -58,11 +57,6 @@ export function App({
|
|||||||
bodyshop && bodyshop.imexshopid
|
bodyshop && bodyshop.imexshopid
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(
|
|
||||||
"🚀 ~ file: App.jsx ~ line 56 ~ LogRocket_Tracking",
|
|
||||||
LogRocket_Tracking
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!navigator.onLine) {
|
if (!navigator.onLine) {
|
||||||
setOnline(false);
|
setOnline(false);
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
import { DatePicker } from "antd";
|
import { DatePicker } from "antd";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import React, { forwardRef } from "react";
|
import React, { useRef } from "react";
|
||||||
//To be used as a form element only.
|
//To be used as a form element only.
|
||||||
|
|
||||||
const dateFormat = "MM/DD/YYYY";
|
const dateFormat = "MM/DD/YYYY";
|
||||||
|
|
||||||
const FormDatePicker = (
|
export default function FormDatePicker({
|
||||||
{ value, onChange, onBlur, onlyFuture, ...restProps },
|
value,
|
||||||
ref
|
onChange,
|
||||||
) => {
|
onBlur,
|
||||||
|
onlyFuture,
|
||||||
|
...restProps
|
||||||
|
}) {
|
||||||
|
const ref = useRef();
|
||||||
|
|
||||||
const handleChange = (newDate) => {
|
const handleChange = (newDate) => {
|
||||||
if (value !== newDate && onChange) {
|
if (value !== newDate && onChange) {
|
||||||
|
console.log("XXX1");
|
||||||
onChange(newDate);
|
onChange(newDate);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -19,17 +25,34 @@ const FormDatePicker = (
|
|||||||
if (e.key.toLowerCase() === "t") {
|
if (e.key.toLowerCase() === "t") {
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
onChange(new moment());
|
onChange(new moment());
|
||||||
|
if (ref.current && ref.current.blur) ref.current.blur();
|
||||||
}
|
}
|
||||||
|
} else if (e.key.toLowerCase() === "enter") {
|
||||||
|
if (ref.current && ref.current.blur) ref.current.blur();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleBlur = (e) => {
|
||||||
|
const v = e.target.value;
|
||||||
|
if (!v) return;
|
||||||
|
|
||||||
|
const _a = moment(
|
||||||
|
v,
|
||||||
|
["MMDDYY", "MMDDYYYY", "MMDD", "MM/DD/YY"],
|
||||||
|
"en",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
if (_a.isValid() && onChange) onChange(_a);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div onKeyDown={handleKeyDown}>
|
<div onKeyDown={handleKeyDown}>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
|
ref={ref}
|
||||||
value={value ? moment(value) : null}
|
value={value ? moment(value) : null}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
format={dateFormat}
|
format={dateFormat}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur || handleBlur}
|
||||||
disabledTime
|
disabledTime
|
||||||
{...(onlyFuture && {
|
{...(onlyFuture && {
|
||||||
disabledDate: (d) => moment().subtract(1, "day").isAfter(d),
|
disabledDate: (d) => moment().subtract(1, "day").isAfter(d),
|
||||||
@@ -38,6 +61,4 @@ const FormDatePicker = (
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
export default forwardRef(FormDatePicker);
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import { useMutation } from "@apollo/client";
|
import { useMutation } from "@apollo/client";
|
||||||
import { Button, Form, notification, DatePicker } from "antd";
|
import { Button, Form, notification } from "antd";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||||
import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component";
|
import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component";
|
||||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import FormDatePicker from "../form-date-picker/form-date-picker.component";
|
||||||
|
|
||||||
export default function JobsAdminDatesChange({ job }) {
|
export default function JobsAdminDatesChange({ job }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -54,7 +56,7 @@ export default function JobsAdminDatesChange({ job }) {
|
|||||||
label={t("jobs.fields.date_estimated")}
|
label={t("jobs.fields.date_estimated")}
|
||||||
name="date_estimated"
|
name="date_estimated"
|
||||||
>
|
>
|
||||||
<DatePicker format="MM/DD/YYYY" />
|
<FormDatePicker format="MM/DD/YYYY" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={t("jobs.fields.date_open")} name="date_open">
|
<Form.Item label={t("jobs.fields.date_open")} name="date_open">
|
||||||
<DateTimePicker />
|
<DateTimePicker />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DatePicker, Form, Statistic, Tooltip } from "antd";
|
import { Form, Statistic, Tooltip } from "antd";
|
||||||
import React, { useMemo } from "react";
|
import React, { useMemo } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -34,7 +34,7 @@ export function JobsDetailDatesComponent({ jobRO, job, bodyshop }) {
|
|||||||
label={t("jobs.fields.date_estimated")}
|
label={t("jobs.fields.date_estimated")}
|
||||||
name="date_estimated"
|
name="date_estimated"
|
||||||
>
|
>
|
||||||
<DatePicker disabled={jobRO} format="MM/DD/YYYY" />
|
<FormDatePicker disabled={jobRO} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={t("jobs.fields.date_open")} name="date_open">
|
<Form.Item label={t("jobs.fields.date_open")} name="date_open">
|
||||||
<DateTimePicker disabled={jobRO} />
|
<DateTimePicker disabled={jobRO} />
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { useMutation } from "@apollo/client";
|
import { useMutation } from "@apollo/client";
|
||||||
import { DatePicker, Dropdown, TimePicker, Button, Card } from "antd";
|
import { Button, Card, Dropdown, TimePicker } from "antd";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||||
import { DateFormatter } from "../../utils/DateFormatter";
|
import { DateFormatter } from "../../utils/DateFormatter";
|
||||||
|
import FormDatePicker from "../form-date-picker/form-date-picker.component";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
export default function ProductionListDate({
|
export default function ProductionListDate({
|
||||||
record,
|
record,
|
||||||
@@ -17,8 +17,12 @@ export default function ProductionListDate({
|
|||||||
const [updateAlert] = useMutation(UPDATE_JOB);
|
const [updateAlert] = useMutation(UPDATE_JOB);
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleChange = (date) => {
|
const handleChange = (date) => {
|
||||||
logImEXEvent("product_toggle_date", { field });
|
logImEXEvent("product_toggle_date", { field });
|
||||||
|
if (date.isSame(record[field] && moment(record[field]))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//e.stopPropagation();
|
//e.stopPropagation();
|
||||||
updateAlert({
|
updateAlert({
|
||||||
@@ -58,7 +62,7 @@ export default function ProductionListDate({
|
|||||||
style={{ padding: "1rem" }}
|
style={{ padding: "1rem" }}
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<DatePicker
|
<FormDatePicker
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
value={(record[field] && moment(record[field])) || null}
|
value={(record[field] && moment(record[field])) || null}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
|||||||
@@ -1506,7 +1506,8 @@
|
|||||||
"difference": "Difference",
|
"difference": "Difference",
|
||||||
"diskscan": "Scan Disk for Estimates",
|
"diskscan": "Scan Disk for Estimates",
|
||||||
"dms": {
|
"dms": {
|
||||||
"defaultstory": "Bodyshop RO {{ro_number}}. Damage to $t(jobs.fields.area_of_damage_impact.{{area_of_damage}}).",
|
"damageto": "Damage to $t(jobs.fields.area_of_damage_impact.{{area_of_damage}}).",
|
||||||
|
"defaultstory": "B/S RO: {{ro_number}}. Owner: {{ownr_nm}}. Insurance Co: {{ins_co_nm}}. Claim/PO #: {{clm_po}}",
|
||||||
"invoicedatefuture": "Invoice date must be today or in the future for CDK posting.",
|
"invoicedatefuture": "Invoice date must be today or in the future for CDK posting.",
|
||||||
"kmoutnotgreaterthankmin": "Mileage out must be greater than mileage in.",
|
"kmoutnotgreaterthankmin": "Mileage out must be greater than mileage in.",
|
||||||
"logs": "Logs",
|
"logs": "Logs",
|
||||||
|
|||||||
@@ -1506,6 +1506,7 @@
|
|||||||
"difference": "",
|
"difference": "",
|
||||||
"diskscan": "",
|
"diskscan": "",
|
||||||
"dms": {
|
"dms": {
|
||||||
|
"damageto": "",
|
||||||
"defaultstory": "",
|
"defaultstory": "",
|
||||||
"invoicedatefuture": "",
|
"invoicedatefuture": "",
|
||||||
"kmoutnotgreaterthankmin": "",
|
"kmoutnotgreaterthankmin": "",
|
||||||
|
|||||||
@@ -1506,6 +1506,7 @@
|
|||||||
"difference": "",
|
"difference": "",
|
||||||
"diskscan": "",
|
"diskscan": "",
|
||||||
"dms": {
|
"dms": {
|
||||||
|
"damageto": "",
|
||||||
"defaultstory": "",
|
"defaultstory": "",
|
||||||
"invoicedatefuture": "",
|
"invoicedatefuture": "",
|
||||||
"kmoutnotgreaterthankmin": "",
|
"kmoutnotgreaterthankmin": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user