<% # Auto-refresh if user just started a sync or has games being processed has_unmatched = @unmatched_games > 0 && @pending_review_count == 0 just_synced = current_user.igdb_last_synced_at && current_user.igdb_last_synced_at > 5.minutes.ago should_auto_refresh = has_unmatched && just_synced %> <% if should_auto_refresh %>
Processing games... Page will auto-refresh every 30 seconds.
<% end %>

IGDB Game Matching

<%= button_to "Sync Now", sync_now_igdb_matches_path, method: :post, class: "px-4 py-2 bg-indigo-600 text-white rounded hover:bg-indigo-700" %>
Matched Games
<%= @matched_games %>
Unmatched Games
<%= @unmatched_games %>
Pending Review
<%= @pending_review_count %>
<% if current_user.igdb_last_synced_at %>

Last synced: <%= time_ago_in_words(current_user.igdb_last_synced_at) %> ago

<% end %> <% if @pending_suggestions.empty? %>
<% if @unmatched_games > 0 %>

No pending matches to review. Click "Sync Now" to search IGDB for your games!

<%= button_to "Sync Now", sync_now_igdb_matches_path, method: :post, class: "px-6 py-3 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700" %> <% else %>

All your games are matched with IGDB! 🎉

<% end %>
<% else %>
<% @pending_suggestions.each do |game, suggestions| %>

<%= game.title %>

<%= game.platform.name %> · <%= game.format.titleize %> <% if game.date_added %> · Added <%= game.date_added.strftime("%b %Y") %> <% end %>

<%= game.igdb_match_status&.titleize || 'Needs Review' %>

Suggested Matches from IGDB:

<% suggestions.each do |suggestion| %>
<% if suggestion.igdb_cover_url.present? %> <%= image_tag suggestion.cover_image_url("cover_big"), alt: suggestion.igdb_name, class: "w-24 h-32 object-cover rounded shadow" %> <% else %>
No Cover
<% end %>

<%= suggestion.igdb_name %>

<%= suggestion.igdb_platform_name %> <% if suggestion.igdb_release_date %> · <%= suggestion.igdb_release_date.year %> <% end %>
<% if suggestion.igdb_summary.present? %>

<%= suggestion.igdb_summary %>

<% end %> <% if suggestion.igdb_genres.present? && suggestion.igdb_genres.any? %>
<% suggestion.igdb_genres.first(5).each do |genre| %> <%= genre %> <% end %>
<% end %>
<%= suggestion.confidence_score.to_i %>%
match
<%= button_to "✓ Approve This Match", approve_igdb_match_path(suggestion), method: :post, class: "px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700 text-sm font-medium", data: { turbo_confirm: "Link '#{suggestion.game.title}' to '#{suggestion.igdb_name}'? This will import cover art, genres, and metadata." } %> <%= button_to "✗ Not This One", reject_igdb_match_path(suggestion), method: :post, class: "px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300 text-sm font-medium", data: { turbo_confirm: "Reject this match for '#{suggestion.game.title}'?" } %>
<% end %>

None of these match?

<%= button_to "Reject All Suggestions", reject_igdb_match_path(suggestions.first), method: :post, class: "px-4 py-2 bg-red-100 text-red-700 rounded hover:bg-red-200 text-sm font-medium", data: { turbo_confirm: "Reject all #{suggestions.count} suggestions for '#{game.title}'? You can manually match it later if needed." } %>
<% end %>
<% end %>