From ebcd1eebb5a7ecbd7b6538302ec703c13c29bd09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B0=D1=80=D1=87=D0=B5=D0=BD=D0=BA=D0=BE=20=D0=92?= =?UTF-8?q?=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80?= Date: Tue, 21 Dec 2021 16:38:30 +0500 Subject: [PATCH] Fixed null dates display (for stats table) --- src/pages/Cluster/ClusterWells.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pages/Cluster/ClusterWells.jsx b/src/pages/Cluster/ClusterWells.jsx index 57457b3..520c54f 100644 --- a/src/pages/Cluster/ClusterWells.jsx +++ b/src/pages/Cluster/ClusterWells.jsx @@ -55,6 +55,13 @@ export default function ClusterWells({statsWells}) { if (!filtersWellsType.some((el) => el.text === well.wellType)) filtersWellsType.push({ text: well.wellType, value: well.wellType,}) + let periodPlanValue = well.total?.plan?.start && well.total?.plan?.end + ? (new Date(well.total?.plan?.end) - new Date(well.total?.plan?.start)) / DAY_IN_MS + : '-' + let periodFactValue = well.total?.fact?.start && well.total?.fact?.end + ? (new Date(well.total?.fact?.end) - new Date(well.total?.fact?.start)) / DAY_IN_MS + : '-' + return { key: well.caption, id: well.id, @@ -62,8 +69,8 @@ export default function ClusterWells({statsWells}) { wellType: well.wellType, factStart: well.total?.fact?.start, factEnd: well.total?.fact?.end, - periodPlan: (new Date(well.total?.plan?.end) - new Date(well.total?.plan?.start)) / DAY_IN_MS, - periodFact: (new Date(well.total?.fact?.end) - new Date(well.total?.fact?.start)) / DAY_IN_MS, + periodPlan: periodPlanValue, + periodFact: periodFactValue, rateOfPenetrationPlan: well.total?.plan?.rop, rateOfPenetrationFact: well.total?.fact?.rop, routeSpeedPlan: well.total?.plan?.routeSpeed, @@ -91,7 +98,9 @@ export default function ClusterWells({statsWells}) { setTableData(data) }, [statsWells]) - const getDate = (str) => Number.isNaN(+new Date(str)) ? '-' : new Date(str).toLocaleString() + const getDate = (str) => Number.isNaN(+new Date(str)) || +new Date(str) === 0 + ? '-' + : new Date(str).toLocaleString() const columns = [ makeTextColumn('скв №', 'caption', null, null,