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 29edf5243..a6da8ddc3 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 @@ -34,7 +34,7 @@ export default function CourtesyCarCreateFormComponent({ form, saveLoading }) { {/* */} - - + - - - +
+ + + + + p.mileage !== c.mileage || p.nextservicekm !== c.nextservicekm + } + > + {() => { + const nextservicekm = form.getFieldValue("nextservicekm"); + const mileageOver = + nextservicekm <= form.getFieldValue("mileage"); + + if (mileageOver) + return ( + + + + {t("contracts.labels.cardueforservice")} + + {`${nextservicekm} km`} + + ); + + return <>; + }} + +
- p.mileage !== c.mileage || - p.nextservicedate !== c.nextservicedate || - p.nextservicekm !== c.nextservicekm - } + shouldUpdate={(p, c) => p.nextservicedate !== c.nextservicedate} > {() => { const nextservicedate = form.getFieldValue("nextservicedate"); - const nextservicekm = form.getFieldValue("nextservicekm"); - - const mileageOver = - nextservicekm <= form.getFieldValue("mileage"); - const dueForService = - nextservicedate && moment(nextservicedate).isBefore(moment()); + nextservicedate && + moment(nextservicedate).endOf("day").isSameOrBefore(moment()); - if (mileageOver || dueForService) + if (dueForService) return ( {t("contracts.labels.cardueforservice")} - {`${nextservicekm} km`} {nextservicedate} @@ -282,7 +299,8 @@ export default function CourtesyCarCreateFormComponent({ form, saveLoading }) { {() => { const expires = form.getFieldValue("registrationexpires"); - const dateover = expires && moment(expires).isBefore(moment()); + const dateover = + expires && moment(expires).endOf("day").isBefore(moment()); if (dateover) return ( @@ -317,7 +335,8 @@ export default function CourtesyCarCreateFormComponent({ form, saveLoading }) { {() => { const expires = form.getFieldValue("insuranceexpires"); - const dateover = expires && moment(expires).isBefore(moment()); + const dateover = + expires && moment(expires).endOf("day").isBefore(moment()); if (dateover) return (