<% team = local_assigns[:team] %> <% can_manage = local_assigns[:can_manage] %> <% owner_membership = local_assigns[:owner_membership] %> <% staff_memberships = local_assigns[:staff_memberships] %> <% pending_invitations = local_assigns[:pending_invitations] %> <% recordings = local_assigns[:recordings] %> <% entitlements = local_assigns[:entitlements] %>
<% if can_manage %> <% if owner_membership&.staff_kind.blank? %>

<%= t("team.streaming_staff.self_account_heading", email: current_user.email) %>

<%= raw t("team.streaming_staff.self_account_hint") %>

<%= button_to t("team.streaming_staff.self_assign_submit"), public_team_assign_self_staff_path(team), method: :post, params: { staff_kind: "transmission" }, class: "btn btn-primary" %>
<% end %> <% end %>

<%= t("team.streaming_staff.staff_heading") %>

<% if staff_memberships.any? %> <% if can_manage %><% end %> <% staff_memberships.each do |ut| %> <% if can_manage %> <% end %> <% end %>
<%= t("team.streaming_staff.col_name") %><%= t("team.streaming_staff.col_email") %><%= t("team.streaming_staff.col_role") %>
<%= ut.user.name %> <% if ut.user_id == current_user.id %> <%= t("team.streaming_staff.you_suffix") %><% end %> <%= ut.user.email %> <%= t("team.streaming_staff.role_transmission") %> <% if ut.user_id == current_user.id && team.club.owned_by?(current_user) %> <%= button_to t("team.streaming_staff.clear_self_staff"), public_team_clear_self_staff_path(team), method: :delete, class: "btn btn-secondary", style: "padding:4px 10px;font-size:0.8rem", form: { data: { turbo_confirm: t("team.streaming_staff.clear_self_staff_confirm"), confirm_kind: "delete" } } %> <% elsif ut.role == "member" %> <%= button_to t("team.streaming_staff.revoke"), public_team_remove_member_path(team, ut.user), method: :delete, class: "btn btn-secondary", style: "padding:4px 10px;font-size:0.8rem", form: { data: { turbo_confirm: t("team.streaming_staff.revoke_confirm", name: ut.user.name), confirm_kind: "delete" } } %> <% end %>
<% else %>

<%= t("team.streaming_staff.no_staff") %> <% if can_manage %><%= link_to t("team.streaming_staff.invite_someone"), "#invita-trasmissione" %>.<% end %>

<% end %>
<% if can_manage %>

<%= t("team.streaming_staff.invite_form_heading") %>

<%= t("team.streaming_staff.invite_form_hint") %>

<%= form_with url: public_team_invite_path(team), method: :post, class: "team-invite-form__fields" do %> <%= hidden_field_tag :staff_kind, "transmission" %> <%= label_tag :email, t("team.invite.email_label") %> <%= email_field_tag :email, params[:email], required: true, autocomplete: "email", placeholder: "nome@email.it" %> <%= submit_tag t("team.invite.submit"), class: "btn btn-primary" %> <% end %> <% if flash[:invite_url].present? %> <% end %>

<%= t("team.streaming_staff.pending_invitations_heading") %>

<% if pending_invitations.any? %> <% pending_invitations.each do |inv| %> <% end %>
<%= t("team.streaming_staff.col_email_short") %><%= t("team.streaming_staff.col_expires") %>
<%= inv.email %> <%= l inv.expires_at, format: :short %> <%= button_to t("team.streaming_staff.cancel_invitation"), public_team_destroy_invitation_path(team, inv), method: :delete, class: "btn btn-secondary", style: "padding:4px 10px;font-size:0.8rem", form: { data: { confirm_kind: "delete" } } %>
<% else %>

<%= t("team.streaming_staff.no_pending") %>

<% end %>
<% end %> <% if entitlements.can_access_recordings? %>

<%= t("team.streaming_staff.archive_heading") %>

<% if recordings.any? %> <% recordings.each do |rec| %> <% end %>
<%= t("team.streaming_staff.col_match") %><%= t("team.streaming_staff.col_date") %><%= t("team.streaming_staff.col_duration") %><%= t("team.streaming_staff.col_expiry") %><%= t("team.streaming_staff.col_status") %>
<%= rec.title_or_default %> <%= l_local(rec.recorded_at_or_fallback) %> <%= rec.duration_label %> <%= rec.expires_at ? l_local(rec.expires_at) : "—" %> <%= rec.status_label %> <% if rec.replay_url %> <%= link_to t("team.streaming_staff.watch"), rec.replay_url, target: "_blank", rel: "noopener" %> <% else %> — <% end %>

<%= link_to t("team.streaming_staff.manage_all_replays"), public_club_recordings_path(team.club) %>

<% else %>

<%= t("team.streaming_staff.no_recordings") %>

<% end %>
<% end %>