generated from coulomb/repo-seed
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>
68 lines
2.5 KiB
Haskell
68 lines
2.5 KiB
Haskell
module Web.View.EnvelopeEmissionContracts.Index where
|
|
|
|
import Web.Types
|
|
import Generated.Types
|
|
import IHP.Prelude
|
|
import IHP.ViewPrelude
|
|
import Application.Helper.View (adapterStatusBadge)
|
|
|
|
data IndexView = IndexView
|
|
{ contracts :: ![EnvelopeEmissionContract]
|
|
}
|
|
|
|
instance View IndexView where
|
|
html IndexView { .. } = [hsx|
|
|
<div class="flex items-center justify-between mb-6">
|
|
<div>
|
|
<h1 class="text-2xl font-semibold">Envelope Emission Contracts</h1>
|
|
<p class="text-sm text-gray-500 mt-1">
|
|
Formalises which <code>data-*</code> attributes every widget envelope must emit.
|
|
</p>
|
|
</div>
|
|
<a href={InteractionReportingContractsAction}
|
|
class="text-sm text-gray-500 hover:text-gray-800">
|
|
→ Reporting Contracts
|
|
</a>
|
|
</div>
|
|
|
|
{if null contracts
|
|
then [hsx|<p class="text-sm text-gray-400">No contracts found.</p>|]
|
|
else renderTable contracts}
|
|
|]
|
|
|
|
renderTable :: [EnvelopeEmissionContract] -> 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">Required Attributes</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 :: EnvelopeEmissionContract -> Html
|
|
renderRow c = [hsx|
|
|
<tr class="hover:bg-gray-50">
|
|
<td class="px-4 py-3">
|
|
<a href={ShowEnvelopeEmissionContractAction { envelopeEmissionContractId = c.id }}
|
|
class="font-mono text-indigo-600 hover:underline">v{c.contractVersion}</a>
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-600 font-mono text-xs">{tshow c.requiredAttributes}</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>
|
|
|]
|