theseus/app/views/batches/_batch.html.erb
2025-05-31 23:25:41 -04:00

79 lines
3.8 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div id="<%= dom_id batch %>" class="grid md:grid-cols-12 gap-4">
<div class="md:col-span-8">
<article>
<header class="flex items-center justify-between">
<h1><%= batch.type.split('::').first.titleize %> Batch #<%= batch.id %><sup><%= batch_status_badge(batch.aasm.current_state) %></sup></h1>
</header>
<div class="p-3">
<%= render 'shared/tags', tags: batch.tags %>
<div class="grid md:grid-cols-2 gap-4 mb-4">
<div class="batch-info-panel">
<h3>Batch Information</h3>
<div class="p-2 border rounded">
<p><span class="field-label">Created:</span> <%= batch.created_at.strftime("%B %d, %Y at %I:%M %p") %></p>
<p><span class="field-label">CSV File:</span> <%= batch.csv.filename if batch.csv.attached? %></p>
<p><span class="field-label">Address Count:</span> <%= batch.addresses.count %></p>
<% if batch.is_a?(Letter::Batch) %>
<p><span class="field-label">Letter Dimensions:</span> <%= "#{batch.letter_width}\" × #{batch.letter_height}\"" %></p>
<p><span class="field-label">Letter Weight:</span> <%= batch.letter_weight %> oz</p>
<% end %>
<% if batch.is_a?(Warehouse::Batch) && batch.warehouse_template.present? %>
<p><span class="field-label">Warehouse Template:</span> <%= batch.warehouse_template.name %></p>
<% end %>
</div>
</div>
<div class="batch-info-panel">
<h3>Cost Information</h3>
<div class="p-2 border rounded">
<% if batch.is_a?(Warehouse::Batch) %>
<p><span class="field-label">Contents Cost:</span> $<%= sprintf('%.2f', batch.contents_cost) %></p>
<p><span class="field-label">Labor Cost:</span> $<%= sprintf('%.2f', batch.labor_cost) %></p>
<p><span class="field-label">Shipping Cost:</span> $<%= sprintf('%.2f', batch.postage_cost) %></p>
<% end %>
<p><span class="field-label">Total Cost:</span> $<%= sprintf('%.2f', batch.total_cost) %></p>
</div>
</div>
</div>
<% if batch.is_a?(Letter::Batch) && batch.labels_pdf.attached? %>
<div class="batch-labels-section mb-4">
<h3>Letter Labels</h3>
<div class="p-2 border rounded">
<p>PDF labels are available for this batch.</p>
<%= primary_outline_link_to "Download Labels PDF", rails_blob_path(batch.labels_pdf, disposition: "attachment"), target: "_blank", class: "mt-2" do %>
<%= download_icon %>Download Labels PDF
<% end %>
</div>
</div>
<% end %>
</div>
</article>
</div>
<div class="md:col-span-4">
<article class="sticky top-4">
<header>
<h2>Actions</h2>
</header>
<div class="p-3">
<% case batch.aasm_state %>
<% when "awaiting_field_mapping" %>
<%= warning_link_to "Map Fields", map_fields_batch_path(batch), class: "w-full mb-2" do %>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
</svg>
Map Fields
<% end %>
<% when "fields_mapped" %>
<%= success_link_to "Process Batch", process_confirm_batch_path(batch), class: "w-full" do %>
<%= check_icon %>Process Batch
<% end %>
<% end %>
</div>
</article>
</div>
</div>