- @page_title = t('workarea.admin.pricing_discounts.message.page_title', name: @discount.name)

.discount.view
  .view__header
    .grid
      .grid__cell.grid__cell--25
        = render 'workarea/admin/releases/select'
      .grid__cell.grid__cell--50
        .view__heading
          = link_to_index_for(@discount)
          %h1= link_to @discount.name, url_for(@discount)
      .grid__cell.grid__cell--25
        = render_aux_navigation_for(@discount)

  .view__container
    = render_cards_for(@discount, :message)

    - @discount.errors.full_messages.each do |message|
      = render_message 'error', message

    - unless @discount.discount_message_valid?
      = render_message 'error', t('workarea.admin.pricing_discounts.message.invalid_discount_rules')

    = form_tag pricing_discount_path(@discount), method: :patch, id: 'discount_form', data: { unsaved_changes: '' } do
      = hidden_field_tag :template, :message
      .section
        .property
          = label_tag 'discount[message]', t('workarea.admin.pricing_discounts.fields.message'), class: 'property__name'
          = text_field_tag  'discount[message]', @discount.message, class: 'text-box'
          %span.property__note= t('workarea.admin.pricing_discounts.message.message_amount_note')

      .section
        .property
          = label_tag 'discount[message_applied]', t('workarea.admin.pricing_discounts.fields.message_applied'), class: 'property__name'
          = text_field_tag  'discount[message_applied]', @discount.message_applied, class: 'text-box'

      .section
        .property
          %span.property__name= t('workarea.admin.pricing_discounts.fields.message_active')
          = toggle_button_for 'discount[message_active]', @discount.message_active? do
            .toggle-button__more.toggle-button__more--below{ data: { toggle_button_positive_element: '' } }
              %span.toggle-button__note= t('workarea.admin.pricing_discounts.message.enabled')
            .toggle-button__more.toggle-button__more--below{ data: { toggle_button_negative_element: '' } }
              %span.toggle-button__note= t('workarea.admin.pricing_discounts.message.disabled')

      .workflow-bar
        .grid.grid--auto.grid--right.grid--middle
          .grid__cell= render 'workarea/admin/shared/publishing_select'
          .grid__cell= button_tag t('workarea.admin.form.save_changes'), value: 'save_discount_message', class: 'workflow-bar__button workflow-bar__button--update'