somleng/somleng

View on GitHub
app/views/dashboard/account_memberships/show.html.erb

Summary

Maintainability
Test Coverage
<%= page_title(title: "Team Member") do %>
  <% if policy(@resource).edit? %>
    <%= render("shared/edit_resource_page_action", path: edit_dashboard_account_membership_path(@resource)) %>
  <% end %>

  <% if TwoFactorAuthenticationPolicy.new(pundit_user, @resource.user).destroy? %>
    <div class="btn-group">
      <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdown-menu-account-membership-actions" data-bs-toggle="dropdown" aria-expanded="false">
        <i class="fa-solid fa-cog"></i>
      </button>
      <div class="dropdown-menu" aria-labelledby="dropdown-menu-account-membership-actions">
        <%= render("shared/reset_2fa_page_action", user: @resource.user) %>
      </div>
    </div>
  <% end %>

  <% if policy(@resource).destroy? %>
    <%= render("shared/destroy_resource_page_action", path: dashboard_account_membership_path(@resource)) %>
  <% end %>
<% end %>

<div class="card-body">
  <% if UserInvitationPolicy.new(pundit_user, @resource.user).update? %>
    <div class="alert alert-info" role="alert">
      <i class="fa-solid fa-info-circle"></i> The user has not yet accepted their invite.
      <%= button_to("Resend", dashboard_user_invitation_path(@resource.user), class: "btn btn-link p-0", form_class: "d-inline", method: :patch) %>
    </div>
  <% end %>

  <%= show_for(@resource) do |f| %>
    <%= f.attribute :name, value: @resource.user.name %>
    <%= f.attribute :email, value: @resource.user.email %>
    <%= f.attribute :role, value: @resource.role.humanize %>
    <%= f.attribute :otp_required_for_login, label: "OTP required for login" %>
    <%= f.attribute :created_at, value: local_time(@resource.created_at) %>
    <%= f.attribute :updated_at, value: local_time(@resource.updated_at) %>
  <% end %>
</div>