Show registration credentials in client business structure

This commit is contained in:
A R R R Associates
2026-09-02 17:45:18 +05:30
parent 1ce2fd070e
commit 0c5f555eb4
2 changed files with 131 additions and 3 deletions
@@ -69,9 +69,84 @@
</section>
<section class="rounded-2xl bg-white shadow-soft overflow-hidden">
<div class="border-b p-4 font-semibold">Registrations</div>
<table class="min-w-full text-sm"><thead class="bg-slate-50"><tr><th class="p-3 text-left">Type</th><th class="p-3 text-left">Number</th><th class="p-3 text-left">Trade / Unit Name</th><th class="p-3 text-left">State</th><th class="p-3">Status</th><th></th></tr></thead>
<tbody>{% for row in registrations %}<tr class="border-t"><td class="p-3">{{ registration_type_codes.get(row.id, "-") }}</td><td class="p-3 font-medium">{{ row.registration_number }}</td><td class="p-3">{{ row.trade_name or row.legal_name or '-' }}</td><td class="p-3">{{ row.state or '-' }}</td><td class="p-3 text-center">{{ row.status|replace('_',' ')|title }}</td><td class="p-3">{% if can_edit %}<form method="post" action="/clients/{{ client.id }}/business-structure/registration/{{ row.id }}/toggle"><input type="hidden" name="csrf_token" value="{{ csrf_token }}"><button class="text-xs text-brand-700">{{ 'Deactivate' if row.status in ['active','valid','registered'] else 'Activate' }}</button></form>{% endif %}</td></tr>{% else %}<tr><td colspan="6" class="p-6 text-center text-slate-500">No registrations added.</td></tr>{% endfor %}</tbody></table>
<div class="flex flex-wrap items-center justify-between gap-2 border-b p-4">
<div>
<div class="font-semibold">Registrations</div>
<div class="mt-0.5 text-xs font-normal text-slate-500">Portal credentials linked to each registration are available here without exposing encrypted values.</div>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full text-sm">
<thead class="bg-slate-50">
<tr>
<th class="p-3 text-left">Type</th>
<th class="p-3 text-left">Number</th>
<th class="p-3 text-left">Trade / Unit Name</th>
<th class="p-3 text-left">State</th>
<th class="p-3 text-center">Status</th>
<th class="p-3 text-left">Credentials</th>
<th class="p-3 text-left">Actions</th>
</tr>
</thead>
<tbody>
{% for row in registrations %}
{% set linked_credentials = registration_credentials.get(row.id, []) %}
<tr class="border-t align-top">
<td class="p-3">{{ registration_type_codes.get(row.id, "-") }}</td>
<td class="p-3 font-medium">{{ row.registration_number }}</td>
<td class="p-3">{{ row.trade_name or row.legal_name or '-' }}</td>
<td class="p-3">{{ row.state or '-' }}</td>
<td class="p-3 text-center">{{ row.status|replace('_',' ')|title }}</td>
<td class="p-3 min-w-[260px]">
{% if can_open_credentials %}
{% if linked_credentials %}
<details class="group">
<summary class="cursor-pointer list-none inline-flex items-center gap-2 rounded-lg border border-violet-200 bg-violet-50 px-2.5 py-1.5 text-xs font-semibold text-violet-700">
{{ linked_credentials|length }} credential{{ '' if linked_credentials|length == 1 else 's' }}
<span class="text-[10px] group-open:rotate-180">▼</span>
</summary>
<div class="mt-2 space-y-2">
{% for credential in linked_credentials %}
<div class="rounded-lg border border-slate-200 bg-slate-50 p-2.5">
<div class="flex flex-wrap items-start justify-between gap-2">
<div>
<div class="font-medium text-slate-800">{{ credential.title }}</div>
<div class="text-xs text-slate-500">{{ credential_category_labels.get(credential.category, credential.category|replace('_',' ')|title) }}</div>
</div>
<span class="rounded-full px-2 py-0.5 text-[11px] font-medium {% if credential.status == 'active' %}bg-emerald-100 text-emerald-700{% else %}bg-slate-200 text-slate-600{% endif %}">{{ credential.status|replace('_',' ')|title }}</span>
</div>
<a href="/credential-vault/{{ credential.id }}" class="mt-1.5 inline-block text-xs font-semibold text-brand-700">View credential</a>
</div>
{% endfor %}
</div>
</details>
{% else %}
<span class="text-xs text-slate-400">No credentials added</span>
{% endif %}
{% else %}
<span class="text-xs text-slate-400">Restricted</span>
{% endif %}
</td>
<td class="p-3 min-w-[170px]">
<div class="flex flex-wrap items-center gap-x-3 gap-y-2">
{% if can_manage_credentials %}
<a href="/credential-vault/new?client_id={{ client.id }}&registration_id={{ row.id }}" class="text-xs font-semibold text-violet-700">{{ '+ Add Another Credential' if linked_credentials else '+ Add Credential' }}</a>
{% endif %}
{% if can_edit %}
<form method="post" action="/clients/{{ client.id }}/business-structure/registration/{{ row.id }}/toggle">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="text-xs text-brand-700">{{ 'Deactivate' if row.status in ['active','valid','registered'] else 'Activate' }}</button>
</form>
{% endif %}
</div>
</td>
</tr>
{% else %}
<tr><td colspan="7" class="p-6 text-center text-slate-500">No registrations added.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
</div>