<%- include('partials/header', { title, flash, session, csrf }) %>
<section class="card">
  <h2>أوامر الربط داخل واتساب</h2>
  <pre>link username : mohamed
link provider : panel.com
1  = العربية
2  = English
provider alias : api.panel.com
unlink</pre>
</section>
<section class="card">
  <h2>الجروبات المربوطة</h2>
  <p class="muted">زر فتح الجروب يستخدم رابط دعوة واتساب. لازم رقم البوت يكون مشرفًا داخل الجروب علشان يقدر يجيب الرابط.</p>
  <div class="table-wrap"><table><thead><tr><th>الجروب</th><th>النوع</th><th>الربط</th><th>اللغة</th><th>الحالة</th><th>إجراءات</th></tr></thead><tbody>
  <% groups.forEach(row => { %><tr><td><strong><%= row.group_name %></strong><small class="block"><%= row.jid %></small><a class="button small" href="/groups/<%= encodeURIComponent(row.jid) %>/open" target="_blank" rel="noopener">فتح الجروب</a></td><td><%= row.group_type %></td><td><%= row.linked_username || row.provider_key || '-' %></td><td><%= row.language %></td><td><%= row.status %></td><td><div class="actions"><form method="post" action="/groups/<%= encodeURIComponent(row.jid) %>/disable"><input type="hidden" name="_csrf" value="<%= csrf %>"><button class="button small">إيقاف</button></form><form method="post" action="/groups/<%= encodeURIComponent(row.jid) %>/delete" onsubmit="return confirm('حذف الربط؟')"><input type="hidden" name="_csrf" value="<%= csrf %>"><button class="button danger small">حذف</button></form></div><% if (row.group_type === 'provider') { %><form method="post" action="/groups/<%= encodeURIComponent(row.jid) %>/aliases" class="mini-form"><input type="hidden" name="_csrf" value="<%= csrf %>"><input name="alias" placeholder="اسم مزود بديل"><button class="button small">إضافة Alias</button></form><% } %></td></tr><% }) %>
  <% if (!groups.length) { %><tr><td colspan="6">لا توجد جروبات مربوطة.</td></tr><% } %>
  </tbody></table></div>
</section>
<section class="card">
  <h2>أسماء المزودين البديلة</h2>
  <div class="table-wrap"><table><thead><tr><th>الجروب</th><th>Alias</th><th></th></tr></thead><tbody>
  <% aliases.forEach(row => { %><tr><td><%= row.group_name %></td><td><%= row.alias_key %></td><td><form method="post" action="/aliases/<%= row.id %>/delete"><input type="hidden" name="_csrf" value="<%= csrf %>"><button class="button danger small">حذف</button></form></td></tr><% }) %>
  </tbody></table></div>
</section>
<%- include('partials/footer') %>
