diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e9045092..c66e3262 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -137,4 +137,17 @@ module ApplicationHelper speed * 3.6 end + + def days_left(active_until) + return unless active_until + + time_words = distance_of_time_in_words(Time.zone.now, active_until) + + content_tag( + :span, + time_words, + class: 'tooltip', + data: { tip: "Expires on #{active_until.iso8601}" } + ) + end end diff --git a/app/views/settings/_navigation.html.erb b/app/views/settings/_navigation.html.erb index 7bddbe9c..40ec1ddb 100644 --- a/app/views/settings/_navigation.html.erb +++ b/app/views/settings/_navigation.html.erb @@ -5,7 +5,7 @@ <%= link_to 'Background Jobs', settings_background_jobs_path, role: 'tab', class: "tab #{active_tab?(settings_background_jobs_path)}" %> <% end %> <%= link_to 'Map', settings_maps_path, role: 'tab', class: "tab #{active_tab?(settings_maps_path)}" %> - <%# if !DawarichSettings.self_hosted? %> + <% if !DawarichSettings.self_hosted? %> <%= link_to 'Subscriptions', settings_subscriptions_path, role: 'tab', class: "tab #{active_tab?(settings_subscriptions_path)}" %> - <%# end %> + <% end %> diff --git a/app/views/settings/subscriptions/index.html.erb b/app/views/settings/subscriptions/index.html.erb index 64080538..093b58a9 100644 --- a/app/views/settings/subscriptions/index.html.erb +++ b/app/views/settings/subscriptions/index.html.erb @@ -7,13 +7,13 @@
You are currently subscribed to Dawarich, hurray!
- Your subscription will be valid for the next <%= 365 %> days and will be <%= current_user.active? ? 'renewed automatically' : 'renewed manually' %>. + Your subscription will be valid for the next <%= days_left(current_user.active_until) %>.
<%= link_to 'Manage subscription', "#{ENV['SUBSCRIPTION_URL']}/auth/dawarich?token=#{current_user.generate_subscription_token}", class: 'btn btn-primary my-4' %>