<commit_before>import Component from '@ember/component';
import { computed } from '@ember/object';
import $ from 'jquery';
import FormMixin from 'open-event-frontend/mixins/form';

export default Component.extend(FormMixin, {
  getValidationRules() {
    $.fn.form.settings.rules.checkMaxMin = () => {
      return this.get('data.minQuantity') <= this.get('data.maxQuantity');
    };
    $.fn.form.settings.rules.checkMaxTotal = () => {
      return this.get('data.maxQuantity') <= this.get('data.ticketsNumber');
    };
    return {
      inline : true,
      delay  : false,
      on     : 'blur',

      fields: {
        discountCode: {
          identifier : 'discount_code',
          rules      : [
            {
              type   : 'empty',
              prompt : this.get('l10n').t('Please enter a discount code')
            },
            {
              type  : 'regExp',
              value : '^[a-zA-Z0-9_-]*$'
            }
          ]
        },
        numberOfdiscountTickets: {
          identifier : 'number_of_discount_tickets',
          rules      : [
            {
              type   : 'empty',
              prompt : this.get('l10n').t('Please enter the number of tickets')
            }
          ]
        },
        discountAmount: {
          identifier : 'discount_amount',
          rules      : [
            {
              type   : 'empty',
              prompt : this.get('l10n').t('Please enter the discount amount')
            }
          ]
        },
        discountPercent: {
          identifier : 'discount_percent',
          rules      : [
            {
              type   : 'empty',
              prompt : this.get('l10n').t('Please enter the discount percentage')
            }
          ]
        },
        minOrder: {
          identifier : 'min_order',
          optional   : true,
          rules      : [
            {
              type   : 'integer',
              prompt : this.get('l10n').t('Please enter a valid integer')
            },
            {
              type   : 'checkMaxMin',
              prompt : this.get('l10n').t('Minimum value should not be greater than maximum')
            }
          ]
        },
        maxOrder: {
          identifier : 'max_order',
          optional   : true,
          rules      : [
            {
              type   : 'integer',
              prompt : this.get('l10n').t('Please enter a valid integer')
            },
            {
              type   : 'checkMaxMin',
              prompt : this.get('l10n').t('Maximum value should not be less than minimum')
            },
            {
              type   : 'checkMaxTotal',
              prompt : this.get('l10n').t('Maximum value should not be greater than number of tickets')
            }
          ]
        }
      }
    };
  },
  discountLink: computed('data.code', function() {
    const params = this.get('router._router.currentState.routerJsState.params');
    const origin = this.get('fastboot.isFastBoot') ? `${this.get('fastboot.request.protocol')}//${this.get('fastboot.request.host')}` : location.origin;
    let link = origin + this.get('router').urlFor('public', params['events.view'].event_id, { queryParams: { discount_code: this.get('data.code') } });
    this.set('data.discountUrl', link);
    return link;
  }),
  eventTickets: computed.filterBy('tickets', 'type', 'paid'),

  allTicketTypesChecked: computed('tickets', function() {
    if (this.eventTickets.length && this.get('data.tickets').length === this.eventTickets.length) {
      return true;
    }
    return false;
  }),<commit_msg>Modify discount code query Param<commit_after>import Component from '@ember/component';
import { computed } from '@ember/object';
import $ from 'jquery';
import FormMixin from 'open-event-frontend/mixins/form';

export default Component.extend(FormMixin, {
  getValidationRules() {
    $.fn.form.settings.rules.checkMaxMin = () => {
      return this.get('data.minQuantity') <= this.get('data.maxQuantity');
    };
    $.fn.form.settings.rules.checkMaxTotal = () => {
      return this.get('data.maxQuantity') <= this.get('data.ticketsNumber');
    };
    return {
      inline : true,
      delay  : false,
      on     : 'blur',

      fields: {
        discountCode: {
          identifier : 'discount_code',
          rules      : [
            {
              type   : 'empty',
              prompt : this.get('l10n').t('Please enter a discount code')
            },
            {
              type  : 'regExp',
              value : '^[a-zA-Z0-9_-]*$'
            }
          ]
        },
        numberOfdiscountTickets: {
          identifier : 'number_of_discount_tickets',
          rules      : [
            {
              type   : 'empty',
              prompt : this.get('l10n').t('Please enter the number of tickets')
            }
          ]
        },
        discountAmount: {
          identifier : 'discount_amount',
          rules      : [
            {
              type   : 'empty',
              prompt : this.get('l10n').t('Please enter the discount amount')
            }
          ]
        },
        discountPercent: {
          identifier : 'discount_percent',
          rules      : [
            {
              type   : 'empty',
              prompt : this.get('l10n').t('Please enter the discount percentage')
            }
          ]
        },
        minOrder: {
          identifier : 'min_order',
          optional   : true,
          rules      : [
            {
              type   : 'integer',
              prompt : this.get('l10n').t('Please enter a valid integer')
            },
            {
              type   : 'checkMaxMin',
              prompt : this.get('l10n').t('Minimum value should not be greater than maximum')
            }
          ]
        },
        maxOrder: {
          identifier : 'max_order',
          optional   : true,
          rules      : [
            {
              type   : 'integer',
              prompt : this.get('l10n').t('Please enter a valid integer')
            },
            {
              type   : 'checkMaxMin',
              prompt : this.get('l10n').t('Maximum value should not be less than minimum')
            },
            {
              type   : 'checkMaxTotal',
              prompt : this.get('l10n').t('Maximum value should not be greater than number of tickets')
            }
          ]
        }
      }
    };
  },
  discountLink: computed('data.code', function() {
    const params = this.get('router._router.currentState.routerJsState.params');
    const origin = this.get('fastboot.isFastBoot') ? `${this.get('fastboot.request.protocol')}//${this.get('fastboot.request.host')}` : location.origin;
    let link = origin + this.get('router').urlFor('public', params['events.view'].event_id, { queryParams: { code: this.get('data.code') } });
    this.set('data.discountUrl', link);
    return link;
  }),
  eventTickets: computed.filterBy('tickets', 'type', 'paid'),

  allTicketTypesChecked: computed('tickets', function() {
    if (this.eventTickets.length && this.get('data.tickets').length === this.eventTickets.length) {
      return true;
    }
    return false;
  }),
{'fraction_non_alphanumeric': 0.13844011142061283, 'fraction_numerical': 0.005571030640668524, 'mean_word_length': 1.589614136314461, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5932976', 'n_tokens_mistral': 2010, 'n_tokens_neox': 1982, 'n_words': 382}