69 lines
2.5 KiB
JavaScript
69 lines
2.5 KiB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
/**
|
|
* Dashboard alert (admin.components.beforeDashboard): lists integrations that
|
|
* 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' }) {
|
|
if (!payload) return null;
|
|
let doc;
|
|
try {
|
|
doc = await payload.findGlobal({
|
|
slug: 'site-integrations',
|
|
depth: 0
|
|
});
|
|
} catch {
|
|
return null;
|
|
}
|
|
const failing = Object.entries(checks).map(([field, label])=>({
|
|
label,
|
|
status: doc?.[field]
|
|
})).filter((x)=>x.status?.state === 'degraded');
|
|
if (!failing.length) return null;
|
|
return /*#__PURE__*/ _jsxs("div", {
|
|
role: "alert",
|
|
style: {
|
|
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))'
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ _jsx("strong", {
|
|
children: "Integration problem — the site still works, but something needs attention."
|
|
}),
|
|
/*#__PURE__*/ _jsx("ul", {
|
|
style: {
|
|
margin: '0.5rem 0 0',
|
|
paddingLeft: '1.2rem'
|
|
},
|
|
children: failing.map(({ label, status })=>/*#__PURE__*/ _jsxs("li", {
|
|
children: [
|
|
/*#__PURE__*/ _jsxs("strong", {
|
|
children: [
|
|
label,
|
|
":"
|
|
]
|
|
}),
|
|
" ",
|
|
status?.message ?? status?.code ?? 'error'
|
|
]
|
|
}, label))
|
|
}),
|
|
/*#__PURE__*/ _jsx("a", {
|
|
href: `${adminRoute.replace(/\/$/, '')}/globals/site-integrations`,
|
|
style: {
|
|
display: 'inline-block',
|
|
marginTop: '0.5rem'
|
|
},
|
|
children: "Open Site Integrations →"
|
|
})
|
|
]
|
|
});
|
|
}
|
|
export default IntegrationAlerts;
|
|
|
|
//# sourceMappingURL=IntegrationAlerts.js.map
|