Lint: fix all ESLint errors (391 -> 0), lint and typecheck tests
Mostly perfectionist import/key sorting and curly braces from --fix, plus: - spread instead of .apply() in the Meta Pixel stub - non-capturing group in the locale-code pattern - React 19 use(Context) / <Context value> in TurnstileProvider - email regex rewritten without super-linear backtracking (covered by a test) - console.warn/error allowed (deliberate server diagnostics) - test/tsconfig.json so the project service and tsc see test files Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import type { Payload } from 'payload'
|
||||
|
||||
import type { IntegrationStatus } from './status.js'
|
||||
|
||||
type Props = {
|
||||
/** 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
|
||||
/** Status groups to check: field name → label. */
|
||||
checks?: Record<string, string>
|
||||
/** Injected by Payload into admin server components. */
|
||||
payload?: Payload
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -15,8 +16,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({ payload, checks = { turnstileStatus: 'Turnstile', emailStatus: 'Email' }, adminRoute = '/admin' }: Props) {
|
||||
if (!payload) return null
|
||||
export async function IntegrationAlerts({ adminRoute = '/admin', checks = { emailStatus: 'Email', turnstileStatus: 'Turnstile' }, payload }: 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>
|
||||
@@ -26,17 +27,17 @@ export async function IntegrationAlerts({ payload, checks = { turnstileStatus: '
|
||||
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 something needs attention.</strong>
|
||||
|
||||
Reference in New Issue
Block a user