%= form_with(model: [:account, (@team unless invitation.persisted?), invitation], class: 'form', local: true) do |form| %>
<%= render "shared/limits/form", form: form, model: invitation.membership, cancel_path: @cancel_path || [:account, invitation] do %>
<%= render 'account/shared/forms/errors', form: form %>
<%= render 'shared/fields/email_field', form: form, method: :email, options: {autofocus: true} %>
<%= form.fields_for :membership do |membership_form| %>
<%= render 'shared/fields/text_field', form: membership_form, method: :user_first_name %>
<%= render 'shared/fields/text_field', form: membership_form, method: :user_last_name %>
<% end %>
<% if can? :manage, @team %>
<%= form.fields_for :membership do |fields| %>
<%= fields.hidden_field :team_id, value: @team.id %>
<% Membership.assignable_roles.each do |role| %>
<% if current_membership.can_manage_role?(role) %>
<%= fields.check_box :role_ids, {multiple: true, class: "h-4 w-4 text-blue focus:ring-blue-dark border-gray-300 rounded mt-0.5"}, role.id, nil %>
<% end %>
<% end %>
<% end %>
<% end %>
<%# 🚅 super scaffolding will insert new fields above this line. %>
<%= form.submit (form.object.persisted? ? t('.buttons.update') : t('.buttons.create')), class: "button" %>
<% if form.object.persisted? %>
<%= link_to t('global.buttons.cancel'), account_invitation_path(invitation), class: "button-secondary" %>
<% else %>
<%= link_to t('global.buttons.cancel'), @cancel_path || account_team_invitations_path(@team), class: "button-secondary" %>
<% end %>
<% end %>
<% end %>