Fix turnstile
This commit is contained in:
Vendored
+12
-16
@@ -42,11 +42,11 @@ const SITE_INTEGRATIONS = 'site-integrations';
|
||||
admin: {
|
||||
components: {
|
||||
Field: {
|
||||
path: '@intecion/ipal-kit/client#IntegrationStatusBanner',
|
||||
clientProps: {
|
||||
label,
|
||||
statusField
|
||||
},
|
||||
path: '@intecion/ipal-kit/client#IntegrationStatusBanner'
|
||||
statusField,
|
||||
label
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,29 +60,25 @@ const SITE_INTEGRATIONS = 'site-integrations';
|
||||
const changed = previous?.state !== next.state || next.state === 'degraded' && previous?.code !== next.code;
|
||||
const stale = next.state === 'degraded' && (!previous?.checkedAt || now.getTime() - new Date(previous.checkedAt).getTime() > REFRESH_MS);
|
||||
// Healthy and already recorded as healthy (or never recorded) → nothing to do.
|
||||
if (!changed && !stale) {
|
||||
return;
|
||||
}
|
||||
if (next.state === 'ok' && !previous?.state) {
|
||||
return;
|
||||
}
|
||||
if (!changed && !stale) return;
|
||||
if (next.state === 'ok' && !previous?.state) return;
|
||||
const status = {
|
||||
checkedAt: now.toISOString(),
|
||||
state: next.state,
|
||||
code: next.code ?? null,
|
||||
message: next.message ?? null,
|
||||
since: changed ? now.toISOString() : previous?.since ?? now.toISOString(),
|
||||
state: next.state
|
||||
checkedAt: now.toISOString()
|
||||
};
|
||||
try {
|
||||
await payload.updateGlobal({
|
||||
slug: SITE_INTEGRATIONS,
|
||||
context: {
|
||||
ipalIntegrationStatus: true
|
||||
},
|
||||
data: {
|
||||
[field]: status
|
||||
},
|
||||
depth: 0
|
||||
depth: 0,
|
||||
context: {
|
||||
ipalIntegrationStatus: true
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.warn(`[ipal] could not record ${field}:`, err instanceof Error ? err.message : err);
|
||||
|
||||
Reference in New Issue
Block a user