<%- # License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE -%>
<% content_for(:dont_track_ga) {'true'} %>
<% content_for(:hide_nav_beacon) {'true'} %>

<%= content_for :stylesheets do %>
	<%= stylesheet_link_tag 'nonprofits/supporter_form/page' %>
<% end %>

<% content_for :javascripts do %>
	<%= javascript_pack_tag 'i18n', 'page__nonprofits__supporter_form' %>
<% end %>

<div class='u-centered'>

  <div class='u-width--400 u-margin--auto'>


    <br>
    <% if @nonprofit.logo.attached? %>
      <%= image_tag rails_storage_proxy_url(@nonprofit.logo_by_size(:normal)) %>
    <% end %>
    <% if params[:title] %>
      <h4><%= params[:title] %></h4>
    <% else %>
      <h4>Register your info with <%= @nonprofit.name %></h4>
    <% end %>

    <% if params[:tags] %>
      <p> <%= params[:tags].split(',').map(&:titleize).join(", ") %> </p>
    <% end %>

    <% if params[:message] %>
      <p> <%= params[:message] %></p>
    <% end %>
    <hr>
    
    <p class='finishedMessage hide'>
      <% if params[:thankyou] %>
        <%= params[:thankyou] %>
      <% else %>
        Thank you! Your information was successfully saved
      <% end %>
    </p>

    <form class='js-submit'>

      <% required = (params[:required] || '').split(',') %>
    <%= render 'supporters/fields', show_anon: false, required: {name: required.include?('name'), email: required.include?('email')}, profile: current_user ? current_user.profile : nil %>

    <% (params[:tags] || '').split(',').each do |t| %>
      <input type='hidden' name='tag_<%=t%>' value=1>
    <% end %>

    <% (params[:fields] || '').split(',').each do |f| %>
      <label><%= f.titleize %></label>
      <% if params['desc_' + f] %>
        <p class='u-small u-textAlign--left'><%= params['desc_' + f] %></p>
      <% end %>
      <input type='text' name='field_<%= f %>' placeholder='<%= f.titleize %>'>
    <% end %>

    <div class='u-centered u-marginTop--10'>
      <p class='error'>
        <!--= show_if info_step_error -->
        <!--= put info_step.error -->
      </p>
      <%= render 'components/forms/submit_button' %>
    </form>
    </div>
  </div>
</div>