Files
aperonight/app/views/promoter/payouts/index.html.erb

206 lines
10 KiB
Plaintext

<% content_for(:title, "Payouts") %>
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Header -->
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4 mb-6">
<div>
<h1 class="text-2xl sm:text-3xl font-bold text-gray-900">Payout History</h1>
<p class="mt-1 text-sm text-gray-500">View and track all your payout requests</p>
</div>
</div>
<!-- Summary Cards -->
<% if @payouts.any? %>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<!-- Total Payouts -->
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<div class="flex items-center">
<div class="p-2 bg-blue-100 rounded-lg">
<i data-lucide="dollar-sign" class="w-6 h-6 text-blue-600"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500">Total Payouts</p>
<p class="text-2xl font-bold text-gray-900"><%= @payouts.count %></p>
</div>
</div>
</div>
<!-- Total Amount -->
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<div class="flex items-center">
<div class="p-2 bg-green-100 rounded-lg">
<i data-lucide="trending-up" class="w-6 h-6 text-green-600"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500">Total Earned</p>
<p class="text-2xl font-bold text-gray-900">€<%= @payouts.sum(&:net_amount_cents) / 100.0 %></p>
</div>
</div>
</div>
<!-- Pending Payouts -->
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<div class="flex items-center">
<div class="p-2 bg-yellow-100 rounded-lg">
<i data-lucide="clock" class="w-6 h-6 text-yellow-600"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500">Pending</p>
<p class="text-2xl font-bold text-gray-900"><%= @payouts.pending.count %></p>
</div>
</div>
</div>
</div>
<% end %>
<!-- Pending Earnings Section -->
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6 mb-8">
<h2 class="text-lg font-medium text-gray-900 mb-4">Pending Earnings</h2>
<% if @total_pending_net && @total_pending_net > 0 %>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<div class="flex items-center">
<div class="p-2 bg-yellow-100 rounded-lg">
<i data-lucide="dollar-sign" class="w-6 h-6 text-yellow-600"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-500">Total Pending Net</p>
<p class="text-2xl font-bold text-gray-900">
<%= number_to_currency(@total_pending_net / 100.0, unit: '€', separator: ',', delimiter: '.') %>
</p>
</div>
</div>
</div>
</div>
<% end %>
<% if @eligible_events.present? && @eligible_events.any? %>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<% @eligible_events.limit(5).each do |event| %>
<div class="bg-white p-6 rounded-lg shadow border border-gray-200">
<div class="flex items-center mb-3">
<div class="flex-shrink-0 h-10 w-10 bg-gradient-to-br from-purple-500 to-pink-500 rounded-lg flex items-center justify-center">
<i data-lucide="calendar" class="h-5 w-5 text-white"></i>
</div>
<div class="ml-4">
<h3 class="text-lg font-bold text-gray-900"><%= event.name %></h3>
<p class="text-sm text-gray-500"><%= event.start_time.strftime("%d %b %Y") %></p>
</div>
</div>
<div class="space-y-2 text-sm">
<p><span class="font-medium">Gross:</span> <%= number_to_currency(event.total_earnings_cents / 100.0, unit: '€', separator: ',', delimiter: '.') %></p>
<p><span class="font-medium">Net:</span> <%= number_to_currency(event.net_earnings_cents / 100.0, unit: '€', separator: ',', delimiter: '.') %></p>
</div>
<%= link_to "Request Payout", promoter_event_path(event),
class: "mt-4 w-full inline-flex justify-center items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
</div>
<% end %>
</div>
<% if @eligible_events.size > 5 %>
<div class="text-center mt-4">
<%= link_to "View All Eligible Events", promoter_events_path, class: "text-indigo-600 hover:text-indigo-500 text-sm font-medium" %>
</div>
<% end %>
<% else %>
<div class="text-center py-12">
<i data-lucide="inbox" class="mx-auto h-12 w-12 text-gray-400 mb-4"></i>
<h3 class="text-lg font-medium text-gray-900 mb-2">No pending earnings</h3>
<p class="text-gray-500">Check your events to see if any are eligible for payout requests.</p>
<%= link_to "View My Events", promoter_events_path, class: "mt-4 inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md shadow-sm text-gray-700 bg-white hover:bg-gray-50" %>
</div>
<% end %>
</div>
<!-- Payouts Table -->
<% if @payouts.any? %>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Event</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Amount</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200 payout-table-row">
<% @payouts.each do |payout| %>
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="flex-shrink-0 h-10 w-10 bg-gradient-to-br from-purple-500 to-pink-500 rounded-lg flex items-center justify-center">
<i data-lucide="calendar" class="h-5 w-5 text-white"></i>
</div>
<div class="ml-4">
<div class="text-sm font-medium text-gray-900"><%= payout.event&.name || "Event not found" %></div>
<div class="text-sm text-gray-500">#<%= payout.id %></div>
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">€<%= payout.net_amount_euros %></div>
<div class="text-sm text-gray-500">Gross: €<%= payout.amount_euros %></div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<% case payout.status %>
<% when 'pending' %>
<span class="payout-status-badge pending">
<i data-lucide="clock" class="w-3 h-3 mr-1"></i>
Pending
</span>
<% when 'processing' %>
<span class="payout-status-badge processing">
<i data-lucide="refresh-cw" class="w-3 h-3 mr-1"></i>
Processing
</span>
<% when 'completed' %>
<span class="payout-status-badge completed">
<i data-lucide="check-circle" class="w-3 h-3 mr-1"></i>
<% if payout.manual_payout? %>
Manually Processed
<% else %>
Completed
<% end %>
</span>
<% when 'failed' %>
<span class="payout-status-badge failed">
<i data-lucide="x-circle" class="w-3 h-3 mr-1"></i>
Failed
</span>
<% end %>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<%= payout.created_at.strftime("%b %d, %Y") %>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<%= link_to "View Details", promoter_payout_path(payout), class: "text-indigo-600 hover:text-indigo-900 font-medium" %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<!-- Pagination -->
<% if @payouts.respond_to?(:total_pages) %>
<div class="bg-white px-4 py-3 flex items-center justify-between border-t border-gray-200 sm:px-6">
<%= paginate @payouts %>
</div>
<% end %>
</div>
<% else %>
<!-- Empty State -->
<div class="payout-empty-state bg-white rounded-xl shadow-sm border border-gray-200">
<div class="payout-empty-state-icon">
<i data-lucide="dollar-sign" class="h-8 w-8 text-gray-400"></i>
</div>
<h3 class="payout-empty-state-title">No payouts yet</h3>
<p class="payout-empty-state-description">You haven't requested any payouts yet. When your events end, you'll be able to request payouts here.</p>
<%= link_to "View My Events", promoter_events_path, class: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
</div>
<% end %>
</div>