<% title t('.title') %>

<div class="container">
  <div class="oauth-application-logo">
    <%= image_tag(upload_url(Oauth::Application.find_by(uid: @pre_auth.client.uid), :logo, variant: :thumb, default: 'oauth_app'), size: '64x64') %>
  </div>

  <p style="margin-bottom: 2rem;">
    <%= raw t('.prompt', client_name: content_tag(:strong) { @pre_auth.client.name }) %>
  </p>

  <% if @pre_auth.scopes.count > 0 %>
    <div id="oauth-permissions">
      <div class="well help">
        <p><%= t('.able_to') %>:</p>

        <ul>
          <% @pre_auth.scopes.each do |scope| %>
            <li><%= t scope, scope: [:doorkeeper, :scopes] %></li>
          <% end %>
        </ul>
      </div>
    </div>
  <% end %>

  <div class="actions row">
    <%= form_tag oauth_authorization_path, method: :post, class: 'col-6', data: { turbo: false } do %>
      <%= hidden_field_tag :client_id, @pre_auth.client.uid %>
      <%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri %>
      <%= hidden_field_tag :state, @pre_auth.state %>
      <%= hidden_field_tag :response_type, @pre_auth.response_type %>
      <%= hidden_field_tag :scope, @pre_auth.scope %>
      <%= hidden_field_tag :nonce, @pre_auth.nonce %>
      <%= hidden_field_tag :code_challenge, @pre_auth.code_challenge %>
      <%= hidden_field_tag :code_challenge_method, @pre_auth.code_challenge_method %>
      <%= submit_tag t('doorkeeper.authorizations.buttons.authorize'), class: "btn btn-sm btn-success btn-lg btn-block w-100" %>
    <% end %>
    <%= form_tag oauth_authorization_path, method: :delete, class: 'col-6', data: { turbo: false } do %>
      <%= hidden_field_tag :client_id, @pre_auth.client.uid %>
      <%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri %>
      <%= hidden_field_tag :state, @pre_auth.state %>
      <%= hidden_field_tag :response_type, @pre_auth.response_type %>
      <%= hidden_field_tag :scope, @pre_auth.scope %>
      <%= hidden_field_tag :nonce, @pre_auth.nonce %>
      <%= hidden_field_tag :code_challenge, @pre_auth.code_challenge %>
      <%= hidden_field_tag :code_challenge_method, @pre_auth.code_challenge_method %>
      <%= submit_tag t('doorkeeper.authorizations.buttons.deny'), class: "btn btn-sm btn-danger btn-lg btn-block w-100" %>
    <% end %>
  </div>
</div>
