Fixed null dates display (for stats table)

This commit is contained in:
Харченко Владимир 2021-12-21 16:38:30 +05:00
parent 996065bd58
commit ebcd1eebb5

View File

@ -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,