'use client' import { useFormFields } from '@payloadcms/ui' type Props = { /** Name of the hidden status group (buildIntegrationStatusField). */ statusField: string /** Integration name shown in the banner, e.g. 'Turnstile'. */ label: string } const fmt = (iso: unknown) => { if (typeof iso !== 'string' || !iso) return '' const d = new Date(iso) return Number.isNaN(d.getTime()) ? '' : d.toLocaleString() } /** * Status banner on an integration's tab (Site Integrations). Shows nothing until * the integration has been used once; a red box while it's failing; a short * green line once it works again. */ export function IntegrationStatusBanner({ statusField, label }: Props) { const state = useFormFields(([f]) => f[`${statusField}.state`]?.value) as string | undefined const message = useFormFields(([f]) => f[`${statusField}.message`]?.value) as string | undefined const code = useFormFields(([f]) => f[`${statusField}.code`]?.value) as string | undefined const since = useFormFields(([f]) => f[`${statusField}.since`]?.value) const checkedAt = useFormFields(([f]) => f[`${statusField}.checkedAt`]?.value) if (!state) return null if (state === 'ok') { return (