Fix turnstile

This commit is contained in:
2026-10-15 15:53:32 +02:00
parent 7dc93ac5ed
commit 70b676660d
80 changed files with 1136 additions and 902 deletions
+11 -12
View File
@@ -1,14 +1,13 @@
import type { Payload } from 'payload'
import type { IntegrationStatus } from './status.js'
type Props = {
/** Admin route, for the link. Default '/admin'. */
adminRoute?: string
/** Status groups to check: field name → label. */
checks?: Record<string, string>
/** Injected by Payload into admin server components. */
payload?: Payload
/** Status groups to check: field name → label. */
checks?: Record<string, string>
/** Admin route, for the link. Default '/admin'. */
adminRoute?: string
}
/**
@@ -16,8 +15,8 @@ type Props = {
* are currently failing, with a link to Site Integrations. Renders nothing when
* everything is fine — and never throws (DB not ready → nothing).
*/
export async function IntegrationAlerts({ adminRoute = '/admin', checks = { turnstileStatus: 'Turnstile' }, payload }: Props) {
if (!payload) {return null}
export async function IntegrationAlerts({ payload, checks = { turnstileStatus: 'Turnstile', emailStatus: 'Email' }, adminRoute = '/admin' }: Props) {
if (!payload) return null
let doc: Record<string, unknown>
try {
doc = (await payload.findGlobal({ slug: 'site-integrations' as never, depth: 0 })) as Record<string, unknown>
@@ -27,20 +26,20 @@ export async function IntegrationAlerts({ adminRoute = '/admin', checks = { turn
const failing = Object.entries(checks)
.map(([field, label]) => ({ label, status: doc?.[field] as IntegrationStatus | undefined }))
.filter((x) => x.status?.state === 'degraded')
if (!failing.length) {return null}
if (!failing.length) return null
return (
<div
role="alert"
style={{
background: 'var(--theme-error-50, rgba(229, 72, 77, 0.08))',
border: '1px solid var(--theme-error-400, #e5484d)',
borderRadius: 4,
marginBottom: '1.5rem',
padding: '1rem 1.25rem',
borderRadius: 4,
border: '1px solid var(--theme-error-400, #e5484d)',
background: 'var(--theme-error-50, rgba(229, 72, 77, 0.08))',
}}
>
<strong>Integration problem — the site still works, but a safeguard is off.</strong>
<strong>Integration problem — the site still works, but something needs attention.</strong>
<ul style={{ margin: '0.5rem 0 0', paddingLeft: '1.2rem' }}>
{failing.map(({ label, status }) => (
<li key={label}>