<% team = local_assigns[:team] %> <% club = local_assigns[:club] %> <% can_manage = local_assigns[:can_manage] %> <% staff_memberships = local_assigns[:staff_memberships] %> <% pending_invitations = local_assigns[:pending_invitations] %> <% recordings = local_assigns[:recordings] %> <% entitlements = local_assigns[:entitlements] %> <% club_owner = club.owner %> <% extra_staff = staff_memberships.reject { |ut| ut.user_id == club_owner&.id } %>
<% if club_owner %>

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

<%= raw t("team.streaming_staff.principal_body_html", email: club_owner.email) %>

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

<% end %> <% if extra_staff.any? %>

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

<% if can_manage %><% end %> <% extra_staff.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.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 %>
<% 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 %>