dawarich/app/views/visits/index.html.erb
2025-03-02 21:24:57 +01:00

103 lines
4.8 KiB
Text

<%# content_for :title, "Visits" %>
<div class="w-full h-screen flex flex-col">
<%# Top navigation tabs %>
<div class="w-full">
<div role="tablist" class="tabs tabs-lifted tabs-lg">
<%= link_to 'Visits', visits_path(status: :confirmed), role: 'tab', class: "tab font-bold text-xl #{active_visit_places_tab?('visits')}" %>
<%= link_to 'Places', places_path, role: 'tab', class: "tab font-bold text-xl #{active_visit_places_tab?('places')}" %>
</div>
</div>
<%# Main content area with map and side panel %>
<div class="flex flex-1 overflow-hidden">
<%# Map container %>
<div class="w-2/3 h-full relative" data-controller="visits-map">
<div data-visits-map-target="container" class="w-full h-full"></div>
</div>
<%# Side panel %>
<div class="w-1/3 h-full flex flex-col bg-base-200 p-4">
<%# Visit filters %>
<div class="flex flex-col gap-4 mb-4">
<div role="tablist" class="tabs tabs-boxed">
<%= link_to 'Confirmed', visits_path(status: :confirmed), role: 'tab',
class: "tab #{active_tab?(visits_path(status: :confirmed))}" %>
<%= link_to visits_path(status: :suggested), role: 'tab',
class: "tab #{active_tab?(visits_path(status: :suggested))}" do %>
Suggested
<% if @suggested_visits_count.positive? %>
<span class="badge badge-sm badge-primary mx-1"><%= @suggested_visits_count %></span>
<% end %>
<% end %>
<%= link_to 'Declined', visits_path(status: :declined), role: 'tab',
class: "tab #{active_tab?(visits_path(status: :declined))}" %>
</div>
<div class="flex items-center justify-end">
<span class="mr-2">Order by:</span>
<%= link_to 'Newest', visits_path(order_by: :desc, status: params[:status]), class: 'btn btn-xs btn-primary mx-1' %>
<%= link_to 'Oldest', visits_path(order_by: :asc, status: params[:status]), class: 'btn btn-xs btn-primary mx-1' %>
</div>
</div>
<%# Beta notice %>
<div role="alert" class="alert mb-4">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-info h-6 w-6 shrink-0">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<span>Visits suggestion feature is currently in beta stage. Expect bugs and problems and don't hesitate to report them to <a href='https://github.com/Freika/dawarich/issues' class='link'>Github Issues</a>.</span>
</div>
<%# Visits list %>
<div class="flex-1 overflow-y-auto">
<% if @visits.empty? %>
<div class="text-center py-8">
<h2 class="text-2xl font-bold mb-4">No visits found</h2>
<p class="text-base-content/70">
Here you'll find your <%= params[:status] %> visits, but now there are none. Create some areas on your map and pretty soon you'll see visit suggestions on this page!
</p>
</div>
<% else %>
<div class="space-y-4">
<% @visits.each do |visit| %>
<div class="card bg-base-100 shadow-xl"
data-action="mouseenter->visits-map#highlightVisit mouseleave->visits-map#unhighlightVisit"
data-visit-id="<%= visit.id %>"
data-center-lat="<%= visit.center[0] %>"
data-center-lon="<%= visit.center[1] %>">
<div class="card-body p-4">
<%# Visit name %>
<div class="flex items-center justify-between">
<%= render 'visits/name', visit: visit %>
<div class="badge <%= visit.confirmed? ? 'badge-success' : 'badge-warning' %>">
<%= visit.status %>
</div>
</div>
<%# Visit time and duration %>
<div class="text-sm text-base-content/70">
<div><%= "#{visit.started_at.strftime('%H:%M')} - #{visit.ended_at.strftime('%H:%M')}" %></div>
<div>Duration: <%= (visit.duration / 60.0).round(1) %> hours</div>
</div>
<%# Action buttons %>
<div class="card-actions justify-end mt-2">
<%= render 'visits/buttons', visit: visit %>
<label for="visit_details_popup_<%= visit.id %>" class='btn btn-xs btn-info'>Map</label>
</div>
</div>
</div>
<%= render 'visits/modal', visit: visit %>
<% end %>
</div>
<% end %>
</div>
<%# Pagination %>
<div class="mt-4 flex justify-center">
<%= paginate @visits %>
</div>
</div>
</div>
</div>