@model MemberCenter.Web.Models.Profile.SubscriptionsPageViewModel
@{
    ViewData["Title"] = L["Newsletter Subscriptions"];
}

<div class="data-table-shell">
  <table class="data-table">
    <thead>
      <tr>
        <th class="data-table-index">#</th>
        <th>@L["Tenant"]</th>
        <th>@L["List"]</th>
        <th>@L["Email"]</th>
        <th>@L["Status"]</th>
        <th>@L["Action"]</th>
      </tr>
    </thead>
    <tbody>
    @if (!Model.Subscriptions.Any())
    {
      <tr>
        <td colspan="6" class="data-table-empty">@L["No newsletter subscriptions."]</td>
      </tr>
    }
    else
    {
      var index = 1;
      foreach (var subscription in Model.Subscriptions)
      {
        <tr>
          <td class="data-table-index">@index.ToString("000")</td>
          <td>@subscription.TenantName</td>
          <td>@subscription.ListName</td>
          <td>@subscription.Email</td>
          <td>@subscription.Status</td>
          <td>
            @if (!string.Equals(subscription.Status, "unsubscribed", StringComparison.OrdinalIgnoreCase))
            {
              <form asp-action="Unsubscribe" asp-route-id="@subscription.Id" method="post" class="data-table-action-form">
                @Html.AntiForgeryToken()
                <button type="submit" class="data-table-icon-button" aria-label="@L["Unsubscribe"]">−</button>
              </form>
            }
            else
            {
              <span class="data-table-muted">-</span>
            }
          </td>
        </tr>
        index++;
      }
    }
    </tbody>
  </table>
</div>
