Merge branch 'contract_page_load' into dev_environment

This commit is contained in:
Carter 2025-11-13 10:56:13 -06:00
commit 4ffcc06dd6

View file

@ -226,7 +226,7 @@ export default function Devices() {
if (device.status.plenum?.timestamp) {
const now = new Date();
const oneDayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000);
if (compareTimestamps(device.status.plenum?.timestamp, oneDayAgo.toISOString()) < 0) {
if (compareTimestamps(device.status.plenum?.timestamp, oneDayAgo.toISOString()) > 0) {
return true
}
} else {
@ -241,13 +241,20 @@ export default function Devices() {
if (device.status.sen5x?.timestamp) {
const now = new Date();
const oneDayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000);
if (compareTimestamps(device.status.sen5x?.timestamp, oneDayAgo.toISOString()) < 0) {
if (compareTimestamps(device.status.sen5x?.timestamp, oneDayAgo.toISOString()) > 0) {
// console.log("timestamp success " + device.settings?.deviceId)
return true
} else {
// console.log("timestamp fail " + device.settings?.deviceId)
}
} else {
// console.log("no timestamp " + device.settings?.deviceId)
return false
}
} else {
// console.log("no temp and timestamp " + device.settings?.deviceId)
}
return false
}
@ -261,7 +268,7 @@ export default function Devices() {
if (device.status.sen5x?.timestamp) {
const now = new Date();
const oneDayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000);
if (compareTimestamps(device.status.o2?.timestamp, oneDayAgo.toISOString()) < 0) {
if (compareTimestamps(device.status.o2?.timestamp, oneDayAgo.toISOString()) > 0) {
return true
}
} else {
@ -276,7 +283,7 @@ export default function Devices() {
if (device.status.co?.timestamp) {
const now = new Date();
const oneDayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000);
if (compareTimestamps(device.status.co?.timestamp, oneDayAgo.toISOString()) < 0) {
if (compareTimestamps(device.status.co?.timestamp, oneDayAgo.toISOString()) > 0) {
return true
}
} else {
@ -291,7 +298,7 @@ export default function Devices() {
if (device.status.co2?.timestamp) {
const now = new Date();
const oneDayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000);
if (compareTimestamps(device.status.co2?.timestamp, oneDayAgo.toISOString()) < 0) {
if (compareTimestamps(device.status.co2?.timestamp, oneDayAgo.toISOString()) > 0) {
return true
}
} else {
@ -306,7 +313,7 @@ export default function Devices() {
if (device.status.no2?.timestamp) {
const now = new Date();
const oneDayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000);
if (compareTimestamps(device.status.no2?.timestamp, oneDayAgo.toISOString()) < 0) {
if (compareTimestamps(device.status.no2?.timestamp, oneDayAgo.toISOString()) > 0) {
return true
}
} else {
@ -430,16 +437,29 @@ export default function Devices() {
as
).then(resp => {
let newDevices: Device[] = []
let hasPlenum = false
let hasSen5x = false
let hasO2 = false
let hasCo = false
let hasCo2 = false
let hasNo2 = false
resp.data.devices.forEach(device => {
setHasPlenums(doesDeviceHavePlenum(device))
if (doesDeviceHavePlenum(device)) hasPlenum = true
// setHasPlenums(true)
setHasSen5x(doesDeviceHaveSen5x(device))
setHasO2(doesDeviceHaveO2(device))
setHasCo(doesDeviceHaveCo(device))
setHasCo2(doesDeviceHaveCo2(device))
setHasNo2(doesDeviceHaveNo2(device))
if (doesDeviceHaveSen5x(device)) hasSen5x = true
if (doesDeviceHaveO2(device)) hasO2 = true
if (doesDeviceHaveCo(device)) hasCo = true
if (doesDeviceHaveCo2(device)) hasCo2 = true
if (doesDeviceHaveNo2(device)) hasNo2 = true
newDevices.push(Device.create(device))
})
setHasPlenums(hasPlenum)
setHasSen5x(hasSen5x)
setHasO2(hasO2)
setHasCo(hasCo)
setHasCo2(hasCo2)
setHasNo2(hasNo2)
setDevices(newDevices)
setTotal(resp.data.total)
}).finally(() => {
@ -921,15 +941,29 @@ export default function Devices() {
as
).then(resp => {
let newDevices: Device[] = []
let hasPlenum = false
let hasSen5x = false
let hasO2 = false
let hasCo = false
let hasCo2 = false
let hasNo2 = false
resp.data.devices.forEach(device => {
setHasPlenums(doesDeviceHavePlenum(device))
setHasSen5x(doesDeviceHaveSen5x(device))
setHasO2(doesDeviceHaveO2(device))
setHasCo(doesDeviceHaveCo(device))
setHasCo2(doesDeviceHaveCo2(device))
setHasNo2(doesDeviceHaveNo2(device))
if (doesDeviceHavePlenum(device)) hasPlenum = true
// setHasPlenums(true)
if (doesDeviceHaveSen5x(device)) hasSen5x = true
if (doesDeviceHaveO2(device)) hasO2 = true
if (doesDeviceHaveCo(device)) hasCo = true
if (doesDeviceHaveCo2(device)) hasCo2 = true
if (doesDeviceHaveNo2(device)) hasNo2 = true
newDevices.push(Device.create(device))
})
setHasPlenums(hasPlenum)
setHasSen5x(hasSen5x)
setHasO2(hasO2)
setHasCo(hasCo)
setHasCo2(hasCo2)
setHasNo2(hasNo2)
setDevices(currentRows.concat(newDevices))
}).catch(_err => {