61 lines
2.6 KiB
Haskell
61 lines
2.6 KiB
Haskell
|
|
module Web.View.ApiConsumers.Edit where
|
||
|
|
|
||
|
|
import Web.Types
|
||
|
|
import Generated.Types
|
||
|
|
import IHP.Prelude
|
||
|
|
import IHP.ViewPrelude
|
||
|
|
|
||
|
|
data EditView = EditView
|
||
|
|
{ consumer :: !ApiConsumer
|
||
|
|
, manifests :: ![HubCapabilityManifest]
|
||
|
|
}
|
||
|
|
|
||
|
|
instance View EditView where
|
||
|
|
html EditView { .. } = [hsx|
|
||
|
|
<div class="max-w-lg">
|
||
|
|
<h1 class="text-2xl font-semibold mb-6">Edit API Consumer</h1>
|
||
|
|
<form method="POST" action={UpdateApiConsumerAction consumer.id} class="space-y-4">
|
||
|
|
{hiddenField #id}
|
||
|
|
<input type="hidden" name="_method" value="PATCH"/>
|
||
|
|
<div>
|
||
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">Name *</label>
|
||
|
|
{textField #name}
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">Description</label>
|
||
|
|
{textareaField #description}
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">Linked Hub Manifest (optional)</label>
|
||
|
|
<select name="hubCapabilityManifestId" class="border rounded px-3 py-2 text-sm w-full">
|
||
|
|
<option value="">— none —</option>
|
||
|
|
{forEach manifests manifestOption}
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
<div class="grid grid-cols-2 gap-4">
|
||
|
|
<div>
|
||
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">Rate Limit (req/min)</label>
|
||
|
|
{numberField #rateLimitPerMinute}
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">Quota (req/day)</label>
|
||
|
|
{numberField #quotaPerDay}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="pt-2 flex gap-3">
|
||
|
|
<button type="submit" class="bg-indigo-600 text-white text-sm font-medium px-4 py-2 rounded hover:bg-indigo-700">
|
||
|
|
Save Changes
|
||
|
|
</button>
|
||
|
|
<a href={ShowApiConsumerAction consumer.id} class="text-sm text-gray-500 px-4 py-2 hover:text-gray-700">Cancel</a>
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
</div>
|
||
|
|
|]
|
||
|
|
where
|
||
|
|
manifestOption m = [hsx|
|
||
|
|
<option value={show m.id}
|
||
|
|
{if consumer.hubCapabilityManifestId == Just m.id then "selected" else "" :: Text}>
|
||
|
|
Manifest {show m.id} ({m.status})
|
||
|
|
</option>
|
||
|
|
|]
|