<%= @organization.name %>
<%= status_badge(@organization.status) %>
<% stage = @organization.primary_pipeline_stage(current_project) %>
<% if stage %><%= stage_badge(stage) %><% end %>
Owner: <%= @organization.assigned_user&.full_name || "—" %>
Fonte: <%= @organization.lead_source_label %>
Progetti: <%= @organization.projects.ordered.map(&:name).join(", ").presence || "—" %>
<%= link_to "Modifica", edit_organization_path(@organization), class: btn_secondary %>
<%= button_to "Elimina", @organization, method: :delete, form: { data: { turbo_confirm: "Eliminare?" } }, class: btn_danger %>
<% [
["Aggiungi nota", "note", "Nota"],
["Registra email", "email_sent", "Email inviata"],
["Registra telefonata", "call", "Telefonata"],
["Registra demo", "demo", "Demo"],
["Segna primo utilizzo", "first_use", "Primo utilizzo"],
["Crea proposta", "proposal_sent", "Proposta inviata"]
].each do |label, type, subject| %>
<%= form_with url: organization_activities_path(@organization), class: "inline" do %>
<%= hidden_field_tag "activity[activity_type]", type %>
<%= hidden_field_tag "activity[subject]", subject %>
<%= hidden_field_tag "activity[happened_at]", Time.current %>
<%= submit_tag label, class: chip_action_class %>
<% end %>
<% end %>
<%= link_to "Crea follow-up", new_task_path(organization_id: @organization.id, task_type: "follow_up"), class: chip_action_class %>
<% opp = @opportunities.open_stage.first || @opportunities.first %>
<% if opp %>
<%= button_to "Segna come vinto", update_stage_opportunity_path(opp), method: :patch, params: { pipeline_stage: "won" }, class: "rounded-md bg-emerald-600 px-3 py-2 text-xs font-medium text-white" %>
<%= form_with url: update_stage_opportunity_path(opp), method: :patch, class: "inline-flex items-center gap-1" do %>
<%= hidden_field_tag :pipeline_stage, "lost" %>
<%= select_tag :lost_reason, options_for_catalog(Catalog::LOST_REASONS), class: "rounded-md border border-zinc-300 bg-white px-2 py-1 text-xs dark:border-zinc-600 dark:bg-zinc-950 dark:text-zinc-100" %>
<%= submit_tag "Segna come perso", class: "rounded-md bg-rose-600 px-3 py-2 text-xs font-medium text-white" %>
<% end %>
<% end %>
<% if @next_task %>
Prossima azione
<%= @next_task.title %>
<%= format_dt(@next_task.due_at) %> · <%= @next_task.task_type_label %> · <%= priority_badge(@next_task.priority) %>
<%= button_to "Completa", complete_task_path(@next_task), method: :patch, class: "rounded-lg bg-emerald-600 px-4 py-2 text-sm font-medium text-white" %>
<%= link_to "Modifica", edit_task_path(@next_task), class: "rounded-lg border border-amber-400 bg-white px-4 py-2 text-sm font-medium text-amber-900 hover:bg-amber-50 dark:bg-transparent dark:text-amber-100 dark:hover:bg-amber-900/30" %>
<% end %>