<.header> {t("Sites Map")} {t("Geographic")} <:subtitle>{t("Geographic locations of your sites")} <:actions> <.button phx-click="refresh_map"> <.icon name="hero-arrow-path" class="h-5 w-5" /> Refresh <.button navigate={~p"/sites/new"} variant="primary"> <.icon name="hero-plus" class="h-5 w-5" /> Add Site

{t("Geographic Site Locations")}

{t("Click markers to view site details")}

Showing {length(@sites)} sites with coordinates
<.icon name="hero-arrow-path" class="h-8 w-8 text-gray-400 animate-spin mx-auto" />

Loading map...

{t("Statistics")}

Total Sites
{Sites.count_organization_sites(@organization.id)}
Geocoded Sites
{length(@sites)}
Coverage
<%= if Sites.count_organization_sites(@organization.id) > 0 do %> {round(length(@sites) / Sites.count_organization_sites(@organization.id) * 100)}% <% else %> 0% <% end %>

{t("Sites with Geographic Data")}

<%= if length(@sites) > 0 do %>
<%= for site <- @sites do %>

{site.name}

<%= if site.device_count > 0 do %> {site.device_count} devices <% end %>
<%= if site.address do %>

{site.address}

<% end %> <%= if site.description do %>

{site.description}

<% end %>

{Float.round(site.latitude, 4)}, {Float.round(site.longitude, 4)}

<.link navigate={~p"/sites/#{site.id}"} class="text-blue-600 hover:text-blue-500 dark:text-blue-400 dark:hover:text-blue-300 text-sm font-medium" > View →
<% end %>
<% else %>
<.icon name="hero-map-pin" class="mx-auto h-12 w-12 text-gray-400" />

{t("No geocoded sites")}

{t("Add addresses and coordinates to your sites to see them on the map.")}

<.button navigate={~p"/sites"}> {t("Manage Sites")}
<% end %>