fix: Verification in provisioning fixed

This commit is contained in:
2026-02-27 11:15:39 +02:00
parent 7f51c60062
commit 47570257bd

View File

@@ -749,7 +749,7 @@ function StepVerify({ device, onVerified }) {
setTimedOut(false);
setError("");
const startTime = new Date().toISOString();
const startTime = Date.now();
intervalRef.current = setInterval(async () => {
try {
@@ -761,7 +761,12 @@ function StepVerify({ device, onVerified }) {
if (hbData.heartbeats && hbData.heartbeats.length > 0) {
const latest = hbData.heartbeats[0];
const receivedAt = latest.received_at;
if (receivedAt && receivedAt > startTime) {
// SQLite stores datetime as "YYYY-MM-DD HH:MM:SS" (UTC, no T/Z suffix).
// Replace the space with T and append Z so Date.parse() treats it as UTC.
const receivedMs = receivedAt
? Date.parse(receivedAt.replace(" ", "T") + "Z")
: NaN;
if (!isNaN(receivedMs) && receivedMs > startTime) {
clearInterval(intervalRef.current);
clearTimeout(timeoutRef.current);
// Promote device status to provisioned