<% last_month_of_previous_year = Date.new(year - 1, 12, 1) %>
<% if Budget.budget_date_valid?(last_month_of_previous_year, family: family) %>
<%= link_to picker_budgets_path(year: year - 1), data: { turbo_frame: "budget_picker" }, class: "p-2 flex items-center justify-center hover:bg-alpha-black-25 rounded-md" do %>
<%= icon "chevron-left" %>
<% end %>
<% else %>
<%= icon "chevron-left", color: "current" %>
<% end %>
<%= year %>
<% first_month_of_next_year = Date.new(year + 1, 1, 1) %>
<% if Budget.budget_date_valid?(first_month_of_next_year, family: family) %>
<%= link_to picker_budgets_path(year: year + 1), data: { turbo_frame: "budget_picker" }, class: "p-2 flex items-center justify-center hover:bg-alpha-black-25 rounded-md" do %>
<%= icon "chevron-right" %>
<% end %>
<% else %>
<%= icon "chevron-right", color: "current" %>
<% end %>
<% Date::ABBR_MONTHNAMES.compact.each do |month_name| %>
<% date = Date.strptime("#{month_name}-#{year}", "%b-%Y") %>
<% param_key = Budget.date_to_param(date) %>
<% if Budget.budget_date_valid?(date, family: family) %>
<%= render DS::Link.new(
variant: "ghost",
text: month_name,
href: budget_path(param_key),
full_width: true,
frame: :_top
) %>
<% else %>
<%= month_name %>
<% end %>
<% end %>
<% end %>