Add link to date of city visit to right sidebar

This commit is contained in:
Eugene Burmakin 2024-05-18 11:48:22 +02:00
parent ab4f76b2e6
commit 8c70dd484a
4 changed files with 13 additions and 2 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class PointsController < ApplicationController
before_action :authenticate_user!

View file

@ -1,2 +1,12 @@
# frozen_string_literal: true
module PointsHelper
def link_to_date(timestamp)
datetime = Time.zone.at(timestamp)
link_to points_path(start_at: datetime.beginning_of_day, end_at: datetime.end_of_day), \
class: 'underline hover:no-underline' do
datetime.strftime('%d.%m.%Y')
end
end
end

View file

@ -40,7 +40,7 @@
<ul>
<% country[:cities].each do |city| %>
<li>
<%= city[:city] %> (<%= Time.zone.at(city[:timestamp]).strftime("%d.%m.%Y") %>)
<%= city[:city] %> (<%= link_to_date(city[:timestamp]) %>)
</li>
<% end %>
</ul>