Files
inter-hub/Web/View/InteractionReportingContracts/Index.hs
Bernd Worsch 14779f0768 feat(P6/T02-T03): EnvelopeEmissionContract and InteractionReportingContract
T02: EnvelopeEmissionContractsController (index+show, read-only); widgetEnvelope
helper validates against contract v1.0 required attributes with inline warning
on missing view-context; adapterStatusBadge helper added to Application.Helper.View.

T03: InteractionReportingContractsController (index+show, read-only); API endpoint
POST /api/v1/interaction-events with bearer token auth against hub.api_key,
contract v1.0 field validation, and 201/422/401 responses.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 21:11:03 +00:00

70 lines
2.7 KiB
Haskell

module Web.View.InteractionReportingContracts.Index where
import Web.Types
import Generated.Types
import IHP.Prelude
import IHP.ViewPrelude
import Application.Helper.View (adapterStatusBadge)
data IndexView = IndexView
{ contracts :: ![InteractionReportingContract]
}
instance View IndexView where
html IndexView { .. } = [hsx|
<div class="flex items-center justify-between mb-6">
<div>
<h1 class="text-2xl font-semibold">Interaction Reporting Contracts</h1>
<p class="text-sm text-gray-500 mt-1">
Defines the REST endpoint and payload schema for external adapter event submission.
</p>
</div>
<a href={EnvelopeEmissionContractsAction}
class="text-sm text-gray-500 hover:text-gray-800">
Envelope Contracts
</a>
</div>
{if null contracts
then [hsx|<p class="text-sm text-gray-400">No contracts found.</p>|]
else renderTable contracts}
|]
renderTable :: [InteractionReportingContract] -> Html
renderTable contracts = [hsx|
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
<table class="w-full text-sm">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th class="text-left px-4 py-3 font-medium text-gray-600">Version</th>
<th class="text-left px-4 py-3 font-medium text-gray-600">Endpoint</th>
<th class="text-left px-4 py-3 font-medium text-gray-600">Auth</th>
<th class="text-left px-4 py-3 font-medium text-gray-600">Status</th>
<th class="text-left px-4 py-3 font-medium text-gray-600">Created</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
{forEach contracts renderRow}
</tbody>
</table>
</div>
|]
renderRow :: InteractionReportingContract -> Html
renderRow c = [hsx|
<tr class="hover:bg-gray-50">
<td class="px-4 py-3">
<a href={ShowInteractionReportingContractAction { interactionReportingContractId = c.id }}
class="font-mono text-indigo-600 hover:underline">v{c.contractVersion}</a>
</td>
<td class="px-4 py-3 font-mono text-xs text-gray-700">{c.endpointPath}</td>
<td class="px-4 py-3 text-xs text-gray-500">{c.authScheme}</td>
<td class="px-4 py-3">
<span class={adapterStatusBadge c.status <> " text-xs px-2 py-0.5 rounded font-medium"}>
{c.status}
</span>
</td>
<td class="px-4 py-3 text-gray-400 text-xs">{show c.createdAt}</td>
</tr>
|]