<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
// @codingStandardsIgnoreFile
?>
<div class="block discount" id="block-discount">
    <div class="title" data-role="title">
        <strong id="block-discount-heading" role="heading" aria-level="2"><?= /* @escapeNotVerified */
            __('Apply Discount Code') ?></strong>
    </div>
    <div class="content" data-role="content" aria-labelledby="block-discount-heading">
        <form id="discount-coupon-form"
              action="<?= /* @escapeNotVerified */
              $block->getUrl('checkout/cart/couponPost') ?>"
              method="post"
              data-mage-init='{"discountCode":{"couponCodeSelector": "#coupon_code",
              "removeCouponSelector": "#remove-coupon",
              "applyButton": "button.action.apply",
              "cancelButton": "button.action.cancel"}}'>
            <div class="fieldset coupon<?= strlen($block->getCouponCode()) ? ' applied' : '' ?>">
                <input type="hidden" name="remove" id="remove-coupon" value="0"/>
                <div class="form-group">
                    <div class="input-group input-group-sm">

                        <input type="text" class="input-text form-control" id="coupon_code" name="coupon_code"
                               value="<?= $block->escapeHtml($block->getCouponCode()) ?>" placeholder="<?= $block->escapeHtml(__('Enter discount code')) ?>"/>

                        <div class="input-group-append">
                            <?php if (!strlen($block->getCouponCode())): ?>
                                <button class="action apply btn btn-secondary" type="button" value="<?= /* @escapeNotVerified */
                                __('Apply Discount') ?>">
                                    <span><?= /* @escapeNotVerified */
                                        __('Apply Discount') ?></span>
                                </button>
                            <?php else: ?>
                                <div class="primary">
                                    <button type="button" class="action cancel btn btn-danger" value="<?= /* @escapeNotVerified */
                                    __('Cancel Coupon') ?>"><span><?= /* @escapeNotVerified */
                                            __('Cancel Coupon') ?></span></button>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
