summaryrefslogtreecommitdiff
path: root/app/helpers/terms_helper.rb
blob: 5f321551413be92603708bb58cae4a490b48e7e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module TermsHelper
  def terms_data(terms, redirect)
    redirect_params = { redirect: redirect } if redirect

    {
      terms: markdown_field(terms, :terms),
      permissions: {
        can_accept: can?(current_user, :accept_terms, terms),
        can_decline: can?(current_user, :decline_terms, terms)
      },
      paths: {
        accept: accept_term_path(terms, redirect_params),
        decline: decline_term_path(terms, redirect_params),
        root: root_path
      }
    }.to_json
  end
end