src/examples/admin/Webhooks.tsx
src/examples/admin/Webhooks.tsximport { recentDeliveries } from '../../lib/deliveries'
import { demoOrg } from '../../lib/management'
// The org's webhook subscriptions, and the deliveries the demo's own
// receiver (src/examples/webhooks/receiver.ts) verified and kept.
export async function Webhooks() {
const tenant = await demoOrg()
if (!tenant) return <p>The demo tenant isn’t set up.</p>
const { data } = await tenant.synq.get('/v1/orgs/{org}/webhooks', {
path: { org: tenant.org.id },
})
const deliveries = recentDeliveries()
return (
<>
<ul aria-label="Subscriptions">
{data.map((hook) => (
<li key={hook.id}>
<code>{hook.url}</code>: {hook.events.join(', ')} ({hook.enabled ? 'on' : 'off'})
</li>
))}
</ul>
<h2 className="mt-6 font-bold">Verified deliveries</h2>
<ol aria-label="Verified deliveries">
{deliveries.length === 0 && <li>None yet: sign in, and watch them arrive.</li>}
{deliveries.map((d) => (
<li key={d.id}>
<code>{d.type}</code> at {d.receivedAt}
</li>
))}
</ol>
</>
)
}