Plugin Directory

Changeset 2823700


Ignore:
Timestamp:
11/24/2022 03:14:41 PM (3 years ago)
Author:
nappssolutions
Message:

Release 1.0.2

Location:
discount-rules-by-napps/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • discount-rules-by-napps/trunk/app/Api.php

    r2820429 r2823700  
    22namespace App;
    33
     4use App\Api\CategoryController;
    45use WP_REST_Controller;
     6use App\Api\ProductController;
    57use App\Api\DiscountRulesController;
     8use App\Repository\CategoryRepository;
     9use App\Repository\ProductRepository;
    610use App\Repository\DiscountRulesRepository;
    711
     
    2428
    2529        $discountRulesRepo = new DiscountRulesRepository();
     30        $productRepo = new ProductRepository();
     31        $categoryRepo = new CategoryRepository();
     32
    2633        (new DiscountRulesController($discountRulesRepo))->register_routes();
     34        (new ProductController($productRepo))->register_routes();
     35        (new CategoryController($categoryRepo))->register_routes();
    2736    }
    2837
  • discount-rules-by-napps/trunk/app/Api/DiscountRulesController.php

    r2820429 r2823700  
    33
    44use WP_Error;
    5 use WP_Term_Query;
    65use WP_REST_Server;
    76use WP_REST_Response;
     
    1110use App\Models\DiscountStatus;
    1211use App\Adapter\DiscountRuleAdapter;
     12use App\Repository\ProductRepository;
     13use App\Repository\CategoryRepository;
    1314use App\Repository\DiscountRulesRepository;
    14 use Automattic\WooCommerce\StoreApi\StoreApi;
    15 use Automattic\WooCommerce\StoreApi\SchemaController;
    16 use Automattic\WooCommerce\StoreApi\Schemas\V1\ProductSchema;
    17 use Automattic\WooCommerce\StoreApi\Schemas\V1\ProductCategorySchema;
    1815
    1916/**
     
    155152     */
    156153    public function get_items( $request ) {
     154        //TODO: Implement args filter items, see get_collection_params
     155
    157156        $items = $this->discountRulesRepo->getAll();
    158157        if($items === null) {
     
    187186        // Get collection ids for discount rule
    188187        $collections = $this->discountRulesRepo->getCollections($id);
    189         if(!empty($collections)) {
    190 
    191             // Query collections term object
    192             $term_query = new WP_Term_Query();
    193             $collections    = $term_query->query( array(
    194                 'taxonomy'   => 'product_cat',
    195                 'include'    => implode(",", $collections),
    196                 'number'     => 100,
    197             ) );
    198         }
    199188
    200189        // Get products ids for discount rule
    201         $products = $this->discountRulesRepo->getProducts($id);
    202         if(!empty($products)) {
    203 
    204             // Retrieve products information
    205             $products = wc_get_products( array(
    206                 'include' => $products,
    207                 'number'     => 100,
    208             ) );
    209         }
    210 
    211         // Use storeapi schema to parse object to response
    212         $productSchema = StoreApi::container()
    213             ->get( SchemaController::class )
    214             ->get( ProductSchema::IDENTIFIER );
    215 
    216         $parsedProducts = array();
    217         foreach($products as $product) {
    218             $parsedProducts[] = $productSchema->get_item_response($product);
    219         }
    220 
    221         $collectionSchema = StoreApi::container()
    222             ->get( SchemaController::class )
    223             ->get( ProductCategorySchema::IDENTIFIER );
    224 
    225         $parsedCollections = array();
    226         foreach($collections as $collection) {
    227             $parsedCollections[] = $collectionSchema->get_item_response($collection);
    228         }
     190        $productIds = $this->discountRulesRepo->getProducts($id);
     191
     192        $productRepo = new ProductRepository();
     193        $parsedProducts = $productRepo->getProducts($productIds);
     194
     195        $categoryRepo = new CategoryRepository();
     196        $parsedCollections = $categoryRepo->getCategories($collections);
    229197
    230198        $response = rest_ensure_response( [
  • discount-rules-by-napps/trunk/app/Loader.php

    r2822201 r2823700  
    1919     * @var string
    2020     */
    21     public $version = '1.0.1';
     21    public $version = '1.0.2';
    2222
    2323    /**
  • discount-rules-by-napps/trunk/app/Models/DiscountRule.php

    r2820429 r2823700  
    55use App\Events\Jobs;
    66use App\Events\UpdatePrice;
     7use App\Repository\ProductRepository;
    78use WP_Term_Query;
    89use WC_Product_Query;
     
    198199        $productIds = $this->productIds;
    199200        if(!empty($this->collectionIds)) {
    200 
    201             // Get all collections for this discount rule
    202             $term_query = new WP_Term_Query();
    203             $collections    = $term_query->query( array(
    204                 'taxonomy'   => 'product_cat',
    205                 'include'    => implode(",", $this->collectionIds),
    206                 'number'     => 100,
    207             ) );
    208 
    209             // Get an array of collection slugs for this discount rule
    210             $collectionSlugs = array();
    211             foreach($collections as $collection) {
    212                 $collectionSlugs[] = $collection->slug;
    213             }
    214 
    215             // Get all products that has one of collection slugs present in array
    216             $query = new WC_Product_Query( array(
    217                 'category' => $collectionSlugs,
    218                 'limit' => -1,
    219                 'return' => 'ids'
    220             ) );
    221             $productIds = $query->get_products();
     201            $productRepo = new ProductRepository();
     202            $productIds = $productRepo->getProductIdsFromCollections($this->collectionIds);
    222203        }
    223204
     
    228209
    229210        // If we have less then 50 products dont run it on a job
    230         // Takes longer and is not necessary
     211        // Takes longer (background tasks can take up to 60 seconds) and is not necessary
    231212        if(count($productIds) <= 50) {
    232213            $job = new UpdatePrice();
  • discount-rules-by-napps/trunk/app/Repository/DiscountRulesRepository.php

    r2820429 r2823700  
    121121     *
    122122     * @param  integer $discountRuleId
    123      * @return array<int, object>
     123     * @return array<int, int>
    124124     */
    125125    public function getProducts($discountRuleId)
     
    143143     *
    144144     * @param  int $discountRuleId
    145      * @return array<int, object>
     145     * @return array<int, int>
    146146     */
    147147    public function getCollections($discountRuleId)
  • discount-rules-by-napps/trunk/assets/css/admin.css

    r2820429 r2823700  
    979979    margin-right: 1rem;
    980980}
     981.my-8{
     982    margin-top: 2rem;
     983    margin-bottom: 2rem;
     984}
    981985.mx-2{
    982986    margin-left: 0.5rem;
    983987    margin-right: 0.5rem;
    984988}
    985 .my-8{
    986     margin-top: 2rem;
    987     margin-bottom: 2rem;
    988 }
    989989.-mt-2{
    990990    margin-top: -0.5rem;
     
    10161016.mr-4{
    10171017    margin-right: 1rem;
    1018 }
    1019 .mb-4{
    1020     margin-bottom: 1rem;
    1021 }
    1022 .mb-2{
    1023     margin-bottom: 0.5rem;
    1024 }
    1025 .mb-8{
    1026     margin-bottom: 2rem;
    10271018}
    10281019.block{
     
    14491440.text-unselected{
    14501441    color: var(--color-unselected);
     1442}
     1443.text-green{
     1444    color: var(--color-green);
     1445}
     1446.text-schedule{
     1447    color: var(--color-schedule);
    14511448}
    14521449.underline{
  • discount-rules-by-napps/trunk/assets/js/admin.js

    r2820429 r2823700  
    236236
    237237"use strict";
    238 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"render\": () => (/* binding */ render),\n/* harmony export */   \"staticRenderFns\": () => (/* binding */ staticRenderFns)\n/* harmony export */ });\nvar render = function render() {\n  var _vm = this,\n    _c = _vm._self._c,\n    _setup = _vm._self._setupProxy;\n  return _c(\"modal\", {\n    attrs: {\n      name: _vm.name,\n      \"max-width\": _vm.maxWidth,\n      closeable: _vm.closeable,\n      centerY: true,\n      loading: _vm.loading\n    }\n  }, [_c(\"div\", {\n    staticClass: \"items-center flex flex-col\"\n  }, [_c(\"div\", {\n    staticClass: \"flex w-full flex-row items-center px-6 py-8\"\n  }, [_c(\"div\", {\n    staticClass: \"flex-grow\"\n  }, [_c(\"h3\", {\n    staticClass: \"text-primary font-bold text-2xl\"\n  }, [_vm._v(\"Add, Remove & Reorder Collections\")])]), _vm._v(\" \"), _c(\"a\", {\n    staticClass: \"inline-block rounded cursor-pointer text-md px-4 py-2 leading-none border bg-primary text-white border-white dark:border-black500 mt-4 lg:mt-0\",\n    on: {\n      click: _vm.confirm\n    }\n  }, [_vm._v(\"\\n        Confirm\\n      \")]), _vm._v(\" \"), _c(\"a\", {\n    staticClass: \"inline-block rounded cursor-pointer text-md px-4 py-2 leading-none border bg-white dark:bg-black800 text-primary border-primary hover:bg-primary hover:text-white mt-4 lg:mt-0 ml-4\",\n    on: {\n      click: _vm.close\n    }\n  }, [_vm._v(\"\\n        Close\\n      \")])]), _vm._v(\" \"), _c(\"div\", {\n    staticClass: \"flex w-full flex-row border-t border-gray800 dark:border-black500 px-6 pb-4\"\n  }, [_c(\"div\", {\n    staticClass: \"w-1/2 pr-6 pt-4 flex flex-col h-98 xl:h-[31rem] 2xl:h-100\"\n  }, [_c(\"Input\", {\n    staticClass: \"w-full flex-shrink-0\",\n    attrs: {\n      type: \"text\",\n      removeIcon: true,\n      searchIcon: true,\n      placeholder: \"Search\"\n    },\n    model: {\n      value: _vm.search,\n      callback: function ($$v) {\n        _vm.search = $$v;\n      },\n      expression: \"search\"\n    }\n  }), _vm._v(\" \"), _vm.CollectionsFilter.length === 0 && !_vm.loading ? _c(\"div\", {\n    staticClass: \"flex flex-col h-full items-center justify-center\"\n  }, [_c(\"p\", {\n    staticClass: \"text-xl text-primary font-gotmedium\"\n  }, [_vm._v(\"\\n            No collections found!\\n          \")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"text-sm text-gray900 mt-2 text-center\"\n  }, [_vm._v(\"\\n            Your search didn't return any valid collection\\n          \")])]) : _vm._e(), _vm._v(\" \"), _c(\"draggable\", {\n    staticClass: \"max-h-100 overflow-y-auto overflow-x-hidden grid grid-cols-2 lg:grid-cols-3 gap-6 mt-3\",\n    attrs: {\n      fallbackTolerance: 5,\n      list: _vm.CollectionsFilter,\n      group: \"collections\"\n    }\n  }, _vm._l(_vm.CollectionsFilter.filter(e => e != null), function (obj, index) {\n    return _c(\"div\", {\n      key: index,\n      staticClass: \"bg-white dark:bg-black800 rounded w-40 shadow hover:shadow-md duration-300\"\n    }, [_c(\"div\", {\n      staticClass: \"px-4 pt-2 dashed-border dark:border-black500 flex flex-col\",\n      on: {\n        click: function ($event) {\n          return _vm.addElement(obj);\n        }\n      }\n    }, [_c(\"img\", {\n      staticClass: \"w-64 self-center object-cover h-40\",\n      attrs: {\n        alt: \"collection thumbnail\",\n        src: obj.thumbnail || __webpack_require__(/*! @/images/placeholder-images.png */ \"./src/images/placeholder-images.png\")\n      },\n      on: {\n        error: _vm.replaceByDefault\n      }\n    }), _vm._v(\" \"), _c(\"p\", {\n      staticClass: \"text-primary font-bold text-xs overflow-hidden whitespace-nowrap text-ellipsis\",\n      attrs: {\n        title: obj.name\n      }\n    }, [_vm._v(\"\\n                \" + _vm._s(obj.name) + \"\\n              \")])])]);\n  }), 0)], 1), _vm._v(\" \"), _c(\"div\", {\n    staticClass: \"w-1/2 pl-6 pt-4 border-l border-gray800 dark:border-black500 h-98 2xl:h-100 flex flex-col\"\n  }, [_c(\"div\", {\n    staticClass: \"flex flex-row items-center\"\n  }, [_c(\"h3\", {\n    staticClass: \"text-primary flex-grow font-bold text-2xl\"\n  }, [_vm._v(\"\\n            Selected Collections\\n          \")]), _vm._v(\" \"), _c(\"a\", {\n    staticClass: \"inline-block rounded cursor-pointer text-md px-4 py-2 leading-none border bg-white dark:bg-black800 text-primary border-primary hover:bg-primary hover:text-white lg:mt-0\",\n    on: {\n      click: _vm.clearAll\n    }\n  }, [_vm._v(\"\\n            Delete all\\n          \")])]), _vm._v(\" \"), _c(\"draggable\", {\n    staticClass: \"flex-grow overflow-y-auto overflow-x-hidden flex flex-row flex-wrap content-start gap-6 mt-3\",\n    attrs: {\n      fallbackTolerance: 5,\n      list: _vm.collectionsSelected,\n      group: \"collections\"\n    },\n    on: {\n      change: _vm.onChange\n    }\n  }, _vm._l(this.collectionsSelected, function (obj, index) {\n    return _c(\"div\", {\n      key: index,\n      staticClass: \"bg-white dark:bg-black800 rounded w-40 shadow hover:shadow-md duration-300\"\n    }, [_c(\"div\", {\n      staticClass: \"justify-center items-center px-4 pt-2 dashed-border dark:border-black500 flex flex-col\",\n      on: {\n        click: function ($event) {\n          return _vm.toogleDelete($event, index);\n        }\n      }\n    }, [_c(\"img\", {\n      staticClass: \"w-64 self-center object-cover h-40\",\n      attrs: {\n        alt: \"collection thumbnail\",\n        src: obj.thumbnail || __webpack_require__(/*! @/images/placeholder-images.png */ \"./src/images/placeholder-images.png\")\n      }\n    }), _vm._v(\" \"), _c(\"p\", {\n      staticClass: \"text-primary font-bold text-xs whitespace-nowrap overflow-hidden text-ellipsis self-stretch\",\n      attrs: {\n        title: obj.name\n      }\n    }, [_vm._v(\"\\n                \" + _vm._s(obj.name) + \"\\n              \")])])]);\n  }), 0), _vm._v(\" \"), _c(\"OverlayPanel\", {\n    ref: \"op\",\n    staticClass: \"rounded overlayFilter shadow-none\",\n    attrs: {\n      dismissable: true,\n      appendTo: \"body\"\n    }\n  }, [_c(\"div\", {\n    staticClass: \"flex w-24 cursor-pointer flex-row align-middle\",\n    on: {\n      click: _vm.deleteCollection\n    }\n  }, [_c(\"remove-content-icon\", {\n    staticClass: \"flex-shrink-0\"\n  }), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"text-primary ml-3\"\n  }, [_vm._v(\"Remove\")])], 1)])], 1)])])]);\n};\nvar staticRenderFns = [];\nrender._withStripped = true;\n\n\n//# sourceURL=webpack://napps.discountrules/./src/Components/ModalCollections.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet%5B1%5D.rules%5B3%5D!./node_modules/vue-loader/lib/index.js??vue-loader-options");
     238eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"render\": () => (/* binding */ render),\n/* harmony export */   \"staticRenderFns\": () => (/* binding */ staticRenderFns)\n/* harmony export */ });\nvar render = function render() {\n  var _vm = this,\n    _c = _vm._self._c,\n    _setup = _vm._self._setupProxy;\n  return _c(\"modal\", {\n    attrs: {\n      name: _vm.name,\n      \"max-width\": _vm.maxWidth,\n      closeable: _vm.closeable,\n      centerY: true,\n      loading: _vm.loading\n    }\n  }, [_c(\"div\", {\n    staticClass: \"items-center flex flex-col\"\n  }, [_c(\"div\", {\n    staticClass: \"flex w-full flex-row items-center px-6 py-8\"\n  }, [_c(\"div\", {\n    staticClass: \"flex-grow\"\n  }, [_c(\"h3\", {\n    staticClass: \"text-primary font-bold text-2xl\"\n  }, [_vm._v(\"\\n          Add, Remove & Reorder Collections\\n        \")])]), _vm._v(\" \"), _c(\"a\", {\n    staticClass: \"inline-block rounded cursor-pointer text-md px-4 py-2 leading-none border bg-primary text-white border-white dark:border-black500 mt-4 lg:mt-0\",\n    on: {\n      click: _vm.confirm\n    }\n  }, [_vm._v(\"\\n        Confirm\\n      \")]), _vm._v(\" \"), _c(\"a\", {\n    staticClass: \"inline-block rounded cursor-pointer text-md px-4 py-2 leading-none border bg-white dark:bg-black800 text-primary border-primary hover:bg-primary hover:text-white mt-4 lg:mt-0 ml-4\",\n    on: {\n      click: _vm.close\n    }\n  }, [_vm._v(\"\\n        Close\\n      \")])]), _vm._v(\" \"), _c(\"div\", {\n    staticClass: \"flex w-full flex-row border-t border-gray800 dark:border-black500 px-6 pb-4\"\n  }, [_c(\"div\", {\n    staticClass: \"w-1/2 pr-6 pt-4 flex flex-col h-98 xl:h-[31rem] 2xl:h-100\"\n  }, [_c(\"Input\", {\n    staticClass: \"w-full flex-shrink-0\",\n    attrs: {\n      type: \"text\",\n      removeIcon: true,\n      searchIcon: true,\n      placeholder: \"Search\"\n    },\n    on: {\n      input: _vm.onSearch,\n      blur: _vm.searchCollections\n    },\n    model: {\n      value: _vm.search,\n      callback: function ($$v) {\n        _vm.search = $$v;\n      },\n      expression: \"search\"\n    }\n  }), _vm._v(\" \"), _vm.CollectionsFilter.length === 0 && !_vm.loading ? _c(\"div\", {\n    staticClass: \"flex flex-col h-full items-center justify-center\"\n  }, [_c(\"p\", {\n    staticClass: \"text-xl text-primary font-gotmedium\"\n  }, [_vm._v(\"\\n            No collections found!\\n          \")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"text-sm text-gray900 mt-2 text-center\"\n  }, [_vm._v(\"\\n            Your search didn't return any valid collection\\n          \")])]) : _vm._e(), _vm._v(\" \"), _c(\"draggable\", {\n    staticClass: \"max-h-100 overflow-y-auto overflow-x-hidden grid grid-cols-2 lg:grid-cols-3 gap-6 mt-3\",\n    attrs: {\n      fallbackTolerance: 5,\n      list: _vm.CollectionsFilter,\n      group: \"collections\"\n    },\n    nativeOn: {\n      scroll: function ($event) {\n        return _vm.onScroll.apply(null, arguments);\n      }\n    }\n  }, _vm._l(_vm.CollectionsFilter.filter(e => e != null), function (obj, index) {\n    return _c(\"div\", {\n      key: index,\n      staticClass: \"bg-white dark:bg-black800 rounded w-40 shadow hover:shadow-md duration-300\"\n    }, [_c(\"div\", {\n      staticClass: \"px-4 pt-2 dashed-border dark:border-black500 flex flex-col\",\n      on: {\n        click: function ($event) {\n          return _vm.addElement(obj);\n        }\n      }\n    }, [_c(\"img\", {\n      staticClass: \"w-64 self-center object-cover h-40\",\n      attrs: {\n        alt: \"collection thumbnail\",\n        src: obj.thumbnail || __webpack_require__(/*! @/images/placeholder-images.png */ \"./src/images/placeholder-images.png\")\n      },\n      on: {\n        error: _vm.replaceByDefault\n      }\n    }), _vm._v(\" \"), _c(\"p\", {\n      staticClass: \"text-primary font-bold text-xs overflow-hidden whitespace-nowrap text-ellipsis\",\n      attrs: {\n        title: obj.name\n      }\n    }, [_vm._v(\"\\n                \" + _vm._s(obj.name) + \"\\n              \")])])]);\n  }), 0)], 1), _vm._v(\" \"), _c(\"div\", {\n    staticClass: \"w-1/2 pl-6 pt-4 border-l border-gray800 dark:border-black500 h-98 2xl:h-100 flex flex-col\"\n  }, [_c(\"div\", {\n    staticClass: \"flex flex-row items-center\"\n  }, [_c(\"h3\", {\n    staticClass: \"text-primary flex-grow font-bold text-2xl\"\n  }, [_vm._v(\"\\n            Selected Collections\\n          \")]), _vm._v(\" \"), _c(\"a\", {\n    staticClass: \"inline-block rounded cursor-pointer text-md px-4 py-2 leading-none border bg-white dark:bg-black800 text-primary border-primary hover:bg-primary hover:text-white lg:mt-0\",\n    on: {\n      click: _vm.clearAll\n    }\n  }, [_vm._v(\"\\n            Delete all\\n          \")])]), _vm._v(\" \"), _c(\"draggable\", {\n    staticClass: \"flex-grow overflow-y-auto overflow-x-hidden flex flex-row flex-wrap content-start gap-6 mt-3\",\n    attrs: {\n      fallbackTolerance: 5,\n      list: _vm.collectionsSelected,\n      group: \"collections\"\n    },\n    on: {\n      change: _vm.onChange\n    }\n  }, _vm._l(this.collectionsSelected, function (obj, index) {\n    return _c(\"div\", {\n      key: index,\n      staticClass: \"bg-white dark:bg-black800 rounded w-40 shadow hover:shadow-md duration-300\"\n    }, [_c(\"div\", {\n      staticClass: \"justify-center items-center px-4 pt-2 dashed-border dark:border-black500 flex flex-col\",\n      on: {\n        click: function ($event) {\n          return _vm.toogleDelete($event, index);\n        }\n      }\n    }, [_c(\"img\", {\n      staticClass: \"w-64 self-center object-cover h-40\",\n      attrs: {\n        alt: \"collection thumbnail\",\n        src: obj.thumbnail || __webpack_require__(/*! @/images/placeholder-images.png */ \"./src/images/placeholder-images.png\")\n      }\n    }), _vm._v(\" \"), _c(\"p\", {\n      staticClass: \"text-primary font-bold text-xs whitespace-nowrap overflow-hidden text-ellipsis self-stretch\",\n      attrs: {\n        title: obj.name\n      }\n    }, [_vm._v(\"\\n                \" + _vm._s(obj.name) + \"\\n              \")])])]);\n  }), 0), _vm._v(\" \"), _c(\"OverlayPanel\", {\n    ref: \"op\",\n    staticClass: \"rounded overlayFilter shadow-none\",\n    attrs: {\n      dismissable: true,\n      appendTo: \"body\"\n    }\n  }, [_c(\"div\", {\n    staticClass: \"flex w-24 cursor-pointer flex-row align-middle\",\n    on: {\n      click: _vm.deleteCollection\n    }\n  }, [_c(\"remove-content-icon\", {\n    staticClass: \"flex-shrink-0\"\n  }), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"text-primary ml-3\"\n  }, [_vm._v(\"Remove\")])], 1)])], 1)])])]);\n};\nvar staticRenderFns = [];\nrender._withStripped = true;\n\n\n//# sourceURL=webpack://napps.discountrules/./src/Components/ModalCollections.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet%5B1%5D.rules%5B3%5D!./node_modules/vue-loader/lib/index.js??vue-loader-options");
    239239
    240240/***/ }),
     
    412412
    413413"use strict";
    414 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"render\": () => (/* binding */ render),\n/* harmony export */   \"staticRenderFns\": () => (/* binding */ staticRenderFns)\n/* harmony export */ });\nvar render = function render() {\n  var _vm = this,\n    _c = _vm._self._c,\n    _setup = _vm._self._setupProxy;\n  return _c(\"div\", {\n    staticClass: \"flex flex-col w-full mt-4 p-4 relative\"\n  }, [_setup.discountList.length == 0 ? _c(\"div\", {\n    staticClass: \"text-center w-full flex flex-col my-8\"\n  }, [_c(\"p\", {\n    staticClass: \"text-primary font-gotmedium text-lg\"\n  }, [_vm._v(\"No discount rules available\")])]) : _c(\"div\", {\n    staticClass: \"flex flex-row text-black400 font-gotmedium border-b border-primaryborder px-4 text-center\"\n  }, [_c(\"p\", {\n    staticClass: \"w-4/12 text-left flex-grow\"\n  }, [_vm._v(\"Name\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-2/12\"\n  }, [_vm._v(\"Status\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-2/12\"\n  }, [_vm._v(\"Discount Type\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-2/12\"\n  }, [_vm._v(\"Amount\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-2/12\"\n  }, [_vm._v(\"Created At\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-8\"\n  })]), _vm._v(\" \"), _setup.dataLoading ? _c(\"div\", {\n    staticClass: \"absolute w-full h-full bg-white opacity-80\"\n  }, [_c(_setup.Loading, {\n    staticClass: \"absolute h-10 w-10 text-primary\"\n  })], 1) : _vm._e(), _vm._v(\" \"), _vm._l(_setup.discountList, function (discount, index) {\n    return _c(\"div\", {\n      key: index,\n      staticClass: \"flex flex-row font-gotmedium p-4 transition-all border-b border-primaryborder border-t-0\"\n    }, [_c(\"div\", {\n      staticClass: \"w-4/12 flex flex-col flex-grow cursor-pointer\"\n    }, [_c(\"p\", {\n      staticClass: \"text-primarytext text-base\"\n    }, [_vm._v(_vm._s(discount.name))]), _vm._v(\" \"), _c(\"p\", {\n      staticClass: \"text-primary opacity-[80] underline text-sm\",\n      on: {\n        click: function ($event) {\n          return _setup.onEditClick(discount);\n        }\n      }\n    }, [_vm._v(\"Edit\")])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-2/12 flex items-center justify-center\"\n    }, [_c(\"p\", {\n      staticClass: \"w-40 border rounded text-center py-1 text-base leading-6\"\n    }, [_vm._v(\"\\n          \" + _vm._s(_setup.discountStatusToJSON(discount.status)) + \"\\n        \")])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-2/12 flex items-center justify-center\"\n    }, [_c(\"p\", {\n      staticClass: \"w-40 border rounded text-center py-1 text-base leading-6\"\n    }, [_vm._v(\"\\n         \" + _vm._s(_setup.discountTypeToJSON(discount.discountType)) + \"\\n        \")])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-2/12 flex items-center justify-center\"\n    }, [_c(\"p\", {\n      staticClass: \"text-primarytext text-base\"\n    }, [_vm._v(_vm._s(discount.amount))])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-2/12 flex items-center justify-center\"\n    }, [_c(\"p\", {\n      staticClass: \"text-center text-unselected font-sans\"\n    }, [_vm._v(\"\\n          \" + _vm._s(_setup.formatData(discount.createdAt)) + \"\\n        \")])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-8 flex items-center justify-center cursor-pointer relative\"\n    }, [_c(\"div\", {\n      staticClass: \"flex h-full w-full items-center justify-center\",\n      on: {\n        click: function ($event) {\n          return _setup.openTooltip(discount.id, $event);\n        }\n      }\n    }, [_c(_setup.MenuHorizontalIcon, {\n      staticClass: \"transform rotate-180 z-0\"\n    })], 1), _vm._v(\" \"), _c(_setup.MenuTooltip, {\n      staticClass: \"absolute right-0\",\n      class: _setup.openTooltipToTop ? \"bottom-[2.5rem]\" : \"top-[2.5rem]\",\n      attrs: {\n        data: _setup.tooltipOptions(discount),\n        show: _setup.tooltipForLayout === discount.id\n      },\n      on: {\n        close: _setup.closeTooltip\n      },\n      model: {\n        value: _setup.tooltipValue,\n        callback: function ($$v) {\n          _setup.tooltipValue = $$v;\n        },\n        expression: \"tooltipValue\"\n      }\n    })], 1)]);\n  }), _vm._v(\" \"), _c(_setup.ModalCollections), _vm._v(\" \"), _c(_setup.ModalProducts), _vm._v(\" \"), _c(_setup.EditDiscountRule)], 2);\n};\nvar staticRenderFns = [];\nrender._withStripped = true;\n\n\n//# sourceURL=webpack://napps.discountrules/./src/admin/pages/Home/DiscountRulesList.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet%5B1%5D.rules%5B3%5D!./node_modules/vue-loader/lib/index.js??vue-loader-options");
     414eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"render\": () => (/* binding */ render),\n/* harmony export */   \"staticRenderFns\": () => (/* binding */ staticRenderFns)\n/* harmony export */ });\nvar render = function render() {\n  var _vm = this,\n    _c = _vm._self._c,\n    _setup = _vm._self._setupProxy;\n  return _c(\"div\", {\n    staticClass: \"flex flex-col w-full mt-4 p-4 relative\"\n  }, [_setup.discountList.length == 0 ? _c(\"div\", {\n    staticClass: \"text-center w-full flex flex-col my-8\"\n  }, [_c(\"p\", {\n    staticClass: \"text-primary font-gotmedium text-lg\"\n  }, [_vm._v(\"No discount rules available\")])]) : _c(\"div\", {\n    staticClass: \"flex flex-row text-black400 font-gotmedium border-b border-primaryborder px-4 text-center\"\n  }, [_c(\"p\", {\n    staticClass: \"w-4/12 text-left flex-grow\"\n  }, [_vm._v(\"Name\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-2/12\"\n  }, [_vm._v(\"Status\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-2/12\"\n  }, [_vm._v(\"Discount Type\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-2/12\"\n  }, [_vm._v(\"Amount\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-2/12\"\n  }, [_vm._v(\"Created At\")]), _vm._v(\" \"), _c(\"p\", {\n    staticClass: \"w-8\"\n  })]), _vm._v(\" \"), _setup.dataLoading ? _c(\"div\", {\n    staticClass: \"absolute w-full h-full bg-white opacity-80\"\n  }, [_c(_setup.Loading, {\n    staticClass: \"absolute h-10 w-10 text-primary\"\n  })], 1) : _vm._e(), _vm._v(\" \"), _vm._l(_setup.discountList, function (discount, index) {\n    return _c(\"div\", {\n      key: index,\n      staticClass: \"flex flex-row font-gotmedium p-4 transition-all border-b border-primaryborder border-t-0\"\n    }, [_c(\"div\", {\n      staticClass: \"w-4/12 flex flex-col flex-grow cursor-pointer\"\n    }, [_c(\"p\", {\n      staticClass: \"text-primarytext text-base\"\n    }, [_vm._v(_vm._s(discount.name))]), _vm._v(\" \"), _c(\"p\", {\n      staticClass: \"text-primary opacity-[80] underline text-sm\",\n      on: {\n        click: function ($event) {\n          return _setup.onEditClick(discount);\n        }\n      }\n    }, [_vm._v(\"Edit\")])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-2/12 flex items-center justify-center\"\n    }, [_c(\"p\", {\n      staticClass: \"w-40 border rounded text-center py-1 text-base leading-6\",\n      class: discount.status === _setup.DiscountStatus.Active ? \"text-green\" : \"text-unselected\"\n    }, [_vm._v(\"\\n          \" + _vm._s(_setup.discountStatusToJSON(discount.status)) + \"\\n        \")])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-2/12 flex items-center justify-center\"\n    }, [_c(\"p\", {\n      staticClass: \"w-40 border rounded text-center py-1 text-base leading-6\"\n    }, [_vm._v(\"\\n         \" + _vm._s(_setup.discountTypeToJSON(discount.discountType)) + \"\\n        \")])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-2/12 flex items-center justify-center\"\n    }, [_c(\"p\", {\n      staticClass: \"text-primarytext text-base\"\n    }, [_vm._v(_vm._s(discount.amount))])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-2/12 flex items-center justify-center\"\n    }, [_c(\"p\", {\n      staticClass: \"text-center text-unselected font-sans\"\n    }, [_vm._v(\"\\n          \" + _vm._s(_setup.formatData(discount.createdAt)) + \"\\n        \")])]), _vm._v(\" \"), _c(\"div\", {\n      staticClass: \"w-8 flex items-center justify-center cursor-pointer relative\"\n    }, [_c(\"div\", {\n      staticClass: \"flex h-full w-full items-center justify-center\",\n      on: {\n        click: function ($event) {\n          return _setup.openTooltip(discount.id, $event);\n        }\n      }\n    }, [_c(_setup.MenuHorizontalIcon, {\n      staticClass: \"transform rotate-180 z-0\"\n    })], 1), _vm._v(\" \"), _c(_setup.MenuTooltip, {\n      staticClass: \"absolute right-0\",\n      class: _setup.openTooltipToTop ? \"bottom-[2.5rem]\" : \"top-[2.5rem]\",\n      attrs: {\n        data: _setup.tooltipOptions(discount),\n        show: _setup.tooltipForLayout === discount.id\n      },\n      on: {\n        close: _setup.closeTooltip\n      },\n      model: {\n        value: _setup.tooltipValue,\n        callback: function ($$v) {\n          _setup.tooltipValue = $$v;\n        },\n        expression: \"tooltipValue\"\n      }\n    })], 1)]);\n  }), _vm._v(\" \"), _c(_setup.ModalCollections), _vm._v(\" \"), _c(_setup.ModalProducts), _vm._v(\" \"), _c(_setup.EditDiscountRule)], 2);\n};\nvar staticRenderFns = [];\nrender._withStripped = true;\n\n\n//# sourceURL=webpack://napps.discountrules/./src/admin/pages/Home/DiscountRulesList.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet%5B1%5D.rules%5B3%5D!./node_modules/vue-loader/lib/index.js??vue-loader-options");
    415415
    416416/***/ }),
     
    665665
    666666"use strict";
    667 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _Components_Input_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/Components/Input.vue */ \"./src/Components/Input.vue\");\n/* harmony import */ var primevue_overlaypanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! primevue/overlaypanel */ \"./node_modules/primevue/overlaypanel/index.js\");\n/* harmony import */ var _Modal_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Modal.vue */ \"./src/Components/Modal.vue\");\n/* harmony import */ var _Icons_CollectionIcon_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/Icons/CollectionIcon.vue */ \"./src/Icons/CollectionIcon.vue\");\n/* harmony import */ var _Icons_RemoveContentIcon_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/Icons/RemoveContentIcon.vue */ \"./src/Icons/RemoveContentIcon.vue\");\n/* harmony import */ var primevue_autocomplete__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! primevue/autocomplete */ \"./node_modules/primevue/autocomplete/index.js\");\n/* harmony import */ var _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/Models/ModalCloseRequest */ \"./src/Models/ModalCloseRequest.ts\");\n/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! lodash-es */ \"./node_modules/lodash-es/cloneDeep.js\");\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/ShopOnline/ShopOnline */ \"./src/ShopOnline/ShopOnline.ts\");\n/* harmony import */ var _Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/Plugins/toasted */ \"./src/Plugins/toasted/index.js\");\n/* harmony import */ var _Plugins_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/Plugins/utils */ \"./src/Plugins/utils/index.ts\");\n/* harmony import */ var _Models_Modals__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/Models/Modals */ \"./src/Models/Modals.ts\");\n\n\n\n\n\n\n\n// @ts-ignore\n\n\n\n\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (vue__WEBPACK_IMPORTED_MODULE_11__[\"default\"].extend({\n    name: _Models_Modals__WEBPACK_IMPORTED_MODULE_10__.Modals.CollectionsList,\n    props: {\n        maxWidth: {\n            default: \"7xl\",\n        },\n        closeable: {\n            default: true,\n        },\n    },\n    data() {\n        return {\n            collectionsList: [],\n            collectionsSelected: [],\n            search: undefined,\n            deletingIndex: -1,\n            maxElements: null,\n            loading: false,\n            name: _Models_Modals__WEBPACK_IMPORTED_MODULE_10__.Modals.CollectionsList,\n        };\n    },\n    components: {\n        Modal: _Modal_vue__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n        AutoComplete: primevue_autocomplete__WEBPACK_IMPORTED_MODULE_5__[\"default\"],\n        OverlayPanel: primevue_overlaypanel__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n        CollectionIcon: _Icons_CollectionIcon_vue__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n        RemoveContentIcon: _Icons_RemoveContentIcon_vue__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n        Input: _Components_Input_vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n    },\n    methods: {\n        replaceByDefault(e) {\n            // @ts-ignore\n            e.target.src = __webpack_require__(/*! @/images/placeholder-images.png */ \"./src/images/placeholder-images.png\");\n        },\n        addElement(item) {\n            if (this.maxElements &&\n                this.collectionsSelected.length + 1 > this.maxElements) {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.useToast)().open({\n                    type: \"error\",\n                    title: \"Max elements\",\n                    message: \"You reach the maximum elements of \" + this.maxElements,\n                    duration: 3000,\n                });\n                return false;\n            }\n            this.collectionsSelected.push(item);\n            return true;\n        },\n        clearAll() {\n            this.collectionsSelected = [];\n        },\n        onChange: function (e) {\n            if (e.removed || e.moved || e.added) {\n                //@ts-ignore\n                this.$refs.op.hide();\n                if (e.added) {\n                    if (this.maxElements &&\n                        this.collectionsSelected.length > this.maxElements) {\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.useToast)().open({\n                            type: \"error\",\n                            title: \"Max elements\",\n                            message: \"You reach the maximum elements of \" + this.maxElements,\n                            duration: 3000,\n                        });\n                        this.collectionsSelected.splice(e.added.newIndex, 1);\n                    }\n                }\n            }\n        },\n        toogleDelete(event, index) {\n            this.deletingIndex = index;\n            // @ts-ignore\n            this.$refs.op.toggle(event);\n        },\n        confirm() {\n            if (!this.isOpen) {\n                return;\n            }\n            if (!this.collectionsSelected) {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.useToast)().open({\n                    type: \"error\",\n                    message: \"Select one item\",\n                    duration: 3000,\n                });\n                return;\n            }\n            this.$store.dispatch(\"modals/close\", new _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__[\"default\"](\"modalCollections\", this.collectionsSelected));\n            this.collectionsSelected = [];\n        },\n        close() {\n            this.$store.dispatch(\"modals/close\", new _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__[\"default\"](\"modalCollections\"));\n            this.collectionsSelected = [];\n        },\n        deleteCollection(event) {\n            // @ts-ignore\n            this.$refs.op.hide(event);\n            if (this.deletingIndex != -1) {\n                this.collectionsSelected.splice(this.deletingIndex, 1);\n            }\n        },\n        requestCollectionsList() {\n            this.collectionsList = [];\n            this.loading = true;\n            _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_7__[\"default\"].getInstance()\n                .getCollectionService()\n                ?.getAllCollections()\n                .then((collections) => {\n                if (collections === undefined) {\n                    this.loading = false;\n                    return;\n                }\n                this.collectionsList = collections;\n                this.loading = false;\n            })\n                .catch((e) => {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.toastGenericError)();\n                this.collectionsList = [];\n                this.loading = false;\n                throw e;\n            });\n        },\n    },\n    watch: {\n        isOpen(val) {\n            if (val) {\n                let val = this.extraInfo.data;\n                this.collectionsSelected = !val.collections\n                    ? []\n                    : (0,lodash_es__WEBPACK_IMPORTED_MODULE_12__[\"default\"])(val.collections);\n                this.maxElements = this.extraInfo.maxElements\n                    ? this.extraInfo.maxElements\n                    : null;\n                this.requestCollectionsList();\n            }\n        },\n    },\n    computed: {\n        CollectionsFilter() {\n            let collections = this.search\n                ? this.collectionsList.filter((e) => {\n                    const name = (0,_Plugins_utils__WEBPACK_IMPORTED_MODULE_9__.normalize)(e.name);\n                    const searchQuery = (0,_Plugins_utils__WEBPACK_IMPORTED_MODULE_9__.normalize)(this.search);\n                    if (searchQuery === undefined) {\n                        return false;\n                    }\n                    return name?.includes(searchQuery);\n                })\n                : this.collectionsList;\n            collections = collections.filter((p) => !this.collectionsSelected.find((e) => e && e.id == p.id));\n            return collections;\n        },\n        isOpen() {\n            return this.$store.getters[\"modals/allOpen\"].includes(\"modalCollections\");\n        },\n        allOpen() {\n            return this.$store.getters[\"modals/allOpen\"];\n        },\n        extraInfo() {\n            return this.$store.getters[\"modals/extraInfo\"];\n        },\n    },\n}));\n\n\n//# sourceURL=webpack://napps.discountrules/./src/Components/ModalCollections.vue?./node_modules/ts-loader/index.js??clonedRuleSet-1!./node_modules/vue-loader/lib/index.js??vue-loader-options");
     667eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _Components_Input_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/Components/Input.vue */ \"./src/Components/Input.vue\");\n/* harmony import */ var primevue_overlaypanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! primevue/overlaypanel */ \"./node_modules/primevue/overlaypanel/index.js\");\n/* harmony import */ var _Modal_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Modal.vue */ \"./src/Components/Modal.vue\");\n/* harmony import */ var _Icons_CollectionIcon_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/Icons/CollectionIcon.vue */ \"./src/Icons/CollectionIcon.vue\");\n/* harmony import */ var _Icons_RemoveContentIcon_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/Icons/RemoveContentIcon.vue */ \"./src/Icons/RemoveContentIcon.vue\");\n/* harmony import */ var primevue_autocomplete__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! primevue/autocomplete */ \"./node_modules/primevue/autocomplete/index.js\");\n/* harmony import */ var _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/Models/ModalCloseRequest */ \"./src/Models/ModalCloseRequest.ts\");\n/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! lodash-es */ \"./node_modules/lodash-es/cloneDeep.js\");\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/ShopOnline/ShopOnline */ \"./src/ShopOnline/ShopOnline.ts\");\n/* harmony import */ var _Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/Plugins/toasted */ \"./src/Plugins/toasted/index.js\");\n/* harmony import */ var _Models_Modals__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/Models/Modals */ \"./src/Models/Modals.ts\");\n\n\n\n\n\n\n\n// @ts-ignore\n\n\n\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (vue__WEBPACK_IMPORTED_MODULE_10__[\"default\"].extend({\n    name: _Models_Modals__WEBPACK_IMPORTED_MODULE_9__.Modals.CollectionsList,\n    props: {\n        maxWidth: {\n            default: \"7xl\",\n        },\n        closeable: {\n            default: true,\n        },\n    },\n    data() {\n        return {\n            collectionsList: [],\n            collectionsSelected: [],\n            search: undefined,\n            deletingIndex: -1,\n            maxElements: null,\n            loading: false,\n            name: _Models_Modals__WEBPACK_IMPORTED_MODULE_9__.Modals.CollectionsList,\n            searchTimeout: undefined,\n        };\n    },\n    components: {\n        Modal: _Modal_vue__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n        AutoComplete: primevue_autocomplete__WEBPACK_IMPORTED_MODULE_5__[\"default\"],\n        OverlayPanel: primevue_overlaypanel__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n        CollectionIcon: _Icons_CollectionIcon_vue__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n        RemoveContentIcon: _Icons_RemoveContentIcon_vue__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n        Input: _Components_Input_vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n    },\n    methods: {\n        onSearch() {\n            clearTimeout(this.searchTimeout);\n            this.searchTimeout = undefined;\n            if (!this.search) {\n                this.requestCollectionsList();\n                return;\n            }\n            this.searchTimeout = setTimeout(() => {\n                this.searchCollections();\n            }, 2000);\n        },\n        searchCollections() {\n            if (this.searchTimeout === undefined) {\n                return;\n            }\n            clearTimeout(this.searchTimeout);\n            this.searchTimeout = undefined;\n            if (this.loading) {\n                return;\n            }\n            this.requestCollectionsList();\n        },\n        onScroll(e) {\n            const elem = e.target;\n            const progress = (elem.scrollTop / (elem.scrollHeight - elem.clientHeight)) * 100;\n            if (progress > 75 && !this.search) {\n                this.requestNextPage();\n            }\n        },\n        replaceByDefault(e) {\n            // @ts-ignore\n            e.target.src = __webpack_require__(/*! @/images/placeholder-images.png */ \"./src/images/placeholder-images.png\");\n        },\n        addElement(item) {\n            if (this.maxElements &&\n                this.collectionsSelected.length + 1 > this.maxElements) {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.useToast)().open({\n                    type: \"error\",\n                    title: \"Max elements\",\n                    message: \"You reach the maximum elements of \" + this.maxElements,\n                    duration: 3000,\n                });\n                return false;\n            }\n            this.collectionsSelected.push(item);\n            return true;\n        },\n        clearAll() {\n            this.collectionsSelected = [];\n        },\n        onChange: function (e) {\n            if (e.removed || e.moved || e.added) {\n                //@ts-ignore\n                this.$refs.op.hide();\n                if (e.added) {\n                    if (this.maxElements &&\n                        this.collectionsSelected.length > this.maxElements) {\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.useToast)().open({\n                            type: \"error\",\n                            title: \"Max elements\",\n                            message: \"You reach the maximum elements of \" + this.maxElements,\n                            duration: 3000,\n                        });\n                        this.collectionsSelected.splice(e.added.newIndex, 1);\n                    }\n                }\n            }\n        },\n        toogleDelete(event, index) {\n            this.deletingIndex = index;\n            // @ts-ignore\n            this.$refs.op.toggle(event);\n        },\n        confirm() {\n            if (!this.isOpen) {\n                return;\n            }\n            if (!this.collectionsSelected) {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.useToast)().open({\n                    type: \"error\",\n                    message: \"Select one item\",\n                    duration: 3000,\n                });\n                return;\n            }\n            this.$store.dispatch(\"modals/close\", new _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__[\"default\"](\"modalCollections\", this.collectionsSelected));\n            this.collectionsSelected = [];\n        },\n        close() {\n            this.$store.dispatch(\"modals/close\", new _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__[\"default\"](\"modalCollections\"));\n            this.collectionsSelected = [];\n        },\n        deleteCollection(event) {\n            // @ts-ignore\n            this.$refs.op.hide(event);\n            if (this.deletingIndex != -1) {\n                this.collectionsSelected.splice(this.deletingIndex, 1);\n            }\n        },\n        requestNextPage() {\n            if (this.loading) {\n                return;\n            }\n            this.loading = true;\n            _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_7__[\"default\"].getInstance()\n                .getCollectionService()\n                ?.fetchNext()\n                .then((collections) => {\n                if (collections === undefined) {\n                    this.loading = false;\n                    return;\n                }\n                this.collectionsList.push(...collections);\n                this.loading = false;\n            })\n                .catch(() => {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.toastGenericError)();\n                this.loading = false;\n            });\n        },\n        requestCollectionsList() {\n            if (this.loading) {\n                return;\n            }\n            this.loading = true;\n            this.collectionsList = [];\n            if (this.search) {\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_7__[\"default\"].getInstance()\n                    .getCollectionService()\n                    ?.searchCollections(this.search)\n                    .then((collections) => {\n                    if (collections === undefined) {\n                        this.loading = false;\n                        return;\n                    }\n                    this.collectionsList.push(...collections);\n                    this.loading = false;\n                })\n                    .catch(() => {\n                    (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.toastGenericError)();\n                    this.loading = false;\n                });\n                return;\n            }\n            _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_7__[\"default\"].getInstance()\n                .getCollectionService()\n                ?.getCollections()\n                .then((collections) => {\n                if (collections === undefined) {\n                    this.loading = false;\n                    return;\n                }\n                this.collectionsList.push(...collections);\n                if (this.CollectionsFilter.length == 0 &&\n                    this.collectionsList.length > 0) {\n                    this.requestNextPage();\n                    return;\n                }\n                this.loading = false;\n            })\n                .catch(() => {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_8__.toastGenericError)();\n                this.loading = false;\n            });\n        },\n    },\n    watch: {\n        isOpen(val) {\n            if (val) {\n                let val = this.extraInfo.data;\n                this.collectionsSelected = !val.collections\n                    ? []\n                    : (0,lodash_es__WEBPACK_IMPORTED_MODULE_11__[\"default\"])(val.collections);\n                this.maxElements = this.extraInfo.maxElements\n                    ? this.extraInfo.maxElements\n                    : null;\n                this.requestCollectionsList();\n            }\n        },\n    },\n    computed: {\n        CollectionsFilter() {\n            let collections = this.collectionsList;\n            collections = collections.filter((p) => !this.collectionsSelected.find((e) => e && e.id == p.id));\n            return collections;\n        },\n        isOpen() {\n            return this.$store.getters[\"modals/allOpen\"].includes(\"modalCollections\");\n        },\n        allOpen() {\n            return this.$store.getters[\"modals/allOpen\"];\n        },\n        extraInfo() {\n            return this.$store.getters[\"modals/extraInfo\"];\n        },\n    },\n}));\n\n\n//# sourceURL=webpack://napps.discountrules/./src/Components/ModalCollections.vue?./node_modules/ts-loader/index.js??clonedRuleSet-1!./node_modules/vue-loader/lib/index.js??vue-loader-options");
    668668
    669669/***/ }),
     
    676676
    677677"use strict";
    678 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _Components_Input_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/Components/Input.vue */ \"./src/Components/Input.vue\");\n/* harmony import */ var primevue_overlaypanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! primevue/overlaypanel */ \"./node_modules/primevue/overlaypanel/index.js\");\n/* harmony import */ var _Modal_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Modal.vue */ \"./src/Components/Modal.vue\");\n/* harmony import */ var _Icons_CollectionIcon_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/Icons/CollectionIcon.vue */ \"./src/Icons/CollectionIcon.vue\");\n/* harmony import */ var _Icons_RemoveContentIcon_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/Icons/RemoveContentIcon.vue */ \"./src/Icons/RemoveContentIcon.vue\");\n/* harmony import */ var primevue_autocomplete__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! primevue/autocomplete */ \"./node_modules/primevue/autocomplete/index.js\");\n/* harmony import */ var _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/Models/ModalCloseRequest */ \"./src/Models/ModalCloseRequest.ts\");\n/* harmony import */ var _Icons_RemoveIcon_vue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/Icons/RemoveIcon.vue */ \"./src/Icons/RemoveIcon.vue\");\n/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! lodash-es */ \"./node_modules/lodash-es/cloneDeep.js\");\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/ShopOnline/ShopOnline */ \"./src/ShopOnline/ShopOnline.ts\");\n/* harmony import */ var _Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/Plugins/toasted */ \"./src/Plugins/toasted/index.js\");\n/* harmony import */ var _Plugins_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/Plugins/utils */ \"./src/Plugins/utils/index.ts\");\n/* harmony import */ var _Models_Modals__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @/Models/Modals */ \"./src/Models/Modals.ts\");\n\n\n\n\n\n\n\n\n// @ts-ignore\n\n\n\n\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (vue__WEBPACK_IMPORTED_MODULE_12__[\"default\"].extend({\n    name: 'ModalProducts',\n    props: {\n        maxWidth: {\n            default: '7xl',\n        },\n        closeable: {\n            default: true,\n        },\n        canSelectPrivateProducts: {\n            default: false,\n        },\n        showProductsOutOfStock: {\n            type: Boolean,\n            default: null,\n        },\n    },\n    data() {\n        return {\n            filteredCollections: [],\n            productsList: [],\n            collectionsList: [],\n            // Selected collections\n            selectedCollection: null,\n            selectedCollectionProducts: [],\n            // Final products list\n            productsSelected: [],\n            collectionToFilter: null,\n            maxElements: null,\n            search: null,\n            deletingIndex: -1,\n            //Loading\n            loading: false,\n            searchLoading: false,\n            time: null,\n            noMorePages: false,\n            currentPage: 1,\n            lastOpenId: null,\n            name: _Models_Modals__WEBPACK_IMPORTED_MODULE_11__.Modals.ProductsList\n        };\n    },\n    components: {\n        Modal: _Modal_vue__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n        AutoComplete: primevue_autocomplete__WEBPACK_IMPORTED_MODULE_5__[\"default\"],\n        OverlayPanel: primevue_overlaypanel__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n        CollectionIcon: _Icons_CollectionIcon_vue__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n        RemoveContentIcon: _Icons_RemoveContentIcon_vue__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n        Input: _Components_Input_vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n        RemoveIcon: _Icons_RemoveIcon_vue__WEBPACK_IMPORTED_MODULE_7__[\"default\"],\n    },\n    methods: {\n        onScroll(e) {\n            const elem = e.target;\n            const progress = (elem.scrollTop / (elem.scrollHeight - elem.clientHeight)) * 100;\n            if (progress > 75) {\n                if (this.selectedCollection) {\n                    this.requestCollectionProducts(false);\n                    return;\n                }\n                if (!this.search) {\n                    this.requestProductsList(false);\n                    return;\n                }\n            }\n        },\n        replaceByDefault(e) {\n            e.target.src = __webpack_require__(/*! @/images/placeholder-images.png */ \"./src/images/placeholder-images.png\");\n        },\n        itemExtraClass(obj) {\n            let css = '';\n            if (!this.canSelectPrivateProducts) {\n                css +=\n                    obj.status != 'publish'\n                        ? ' filter grayscale blur-sd dark:blur-sd contrast-75'\n                        : '';\n            }\n            return css;\n        },\n        addElement(item) {\n            // If we dont want to show all products, avoid select a product that is not publish\n            if (!this.canSelectPrivateProducts && item.status != 'publish') {\n                return false;\n            }\n            if (this.maxElements && this.productsSelected.length + 1 > this.maxElements) {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.useToast)().open({\n                    type: 'error',\n                    title: \"Max elements\",\n                    message: \"You reach the maximum elements of \" + this.maxElements,\n                    duration: 3000,\n                });\n                return false;\n            }\n            this.productsSelected.push(item);\n            return true;\n        },\n        clearAll() {\n            this.productsSelected = [];\n        },\n        onClear() {\n            this.selectedCollection = null;\n            this.selectedCollectionProducts = [];\n            this.noMorePages = false;\n            this.currentPage = 1;\n            this.requestProductsList(true);\n        },\n        selected(item) {\n            //Mark collection as selected\n            this.search = '';\n            this.selectedCollection = item.value.id;\n            this.noMorePages = false;\n            this.currentPage = 1;\n            this.requestCollectionProducts(true);\n        },\n        requestCollectionProducts(clearList) {\n            if (clearList) {\n                this.selectedCollectionProducts = [];\n            }\n            if (!this.selectedCollection || this.noMorePages || this.loading) {\n                return;\n            }\n            this.loading = true;\n            if (this.currentPage <= 1) {\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                    .getProductService()\n                    ?.getProductsFromCollection(this.selectedCollection.toString())\n                    .then((products) => {\n                    this.currentPage += 1;\n                    this.loading = false;\n                    this.selectedCollectionProducts.push(...products);\n                    if (products.length == 0) {\n                        this.noMorePages = true;\n                    }\n                })\n                    .catch((e) => {\n                    this.loading = false;\n                    throw e;\n                });\n            }\n            else {\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                    .getProductService()\n                    ?.fetchNext()\n                    .then((products) => {\n                    this.currentPage += 1;\n                    this.loading = false;\n                    this.selectedCollectionProducts.push(...products);\n                    if (products.length == 0) {\n                        this.noMorePages = true;\n                    }\n                })\n                    .catch((e) => {\n                    this.loading = false;\n                    throw e;\n                });\n            }\n        },\n        onSearchChange() {\n            if (this.time) {\n                clearTimeout(this.time);\n            }\n            if (this.selectedCollection) {\n                this.searchLoading = false;\n                return;\n            }\n            this.currentPage = 1;\n            this.noMorePages = false;\n            if (!this.search) {\n                this.searchLoading = false;\n                this.requestProductsList(true);\n                return;\n            }\n            this.time = setTimeout(() => {\n                this.requestProductsList(true);\n            }, 1000);\n        },\n        onChange: function (e) {\n            if (e.removed || e.moved || e.added) {\n                //@ts-ignore\n                this.$refs.op.hide();\n                if (e.added) {\n                    const removeNotAllowedProduct = !this.canSelectPrivateProducts && e.added.element.status != 'publish';\n                    if (removeNotAllowedProduct) {\n                        this.productsSelected.splice(e.added.newIndex, 1);\n                        return;\n                    }\n                    if (this.maxElements && this.productsSelected.length > this.maxElements) {\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.useToast)().open({\n                            type: 'error',\n                            title: \"Max elements\",\n                            message: \"You reach the maximum elements of \" + this.maxElements,\n                            duration: 3000,\n                        });\n                        this.productsSelected.splice(e.added.newIndex, 1);\n                    }\n                }\n            }\n        },\n        onInput(event) {\n            this.filteredCollections = this.collections.filter((collection) => {\n                const name = (0,_Plugins_utils__WEBPACK_IMPORTED_MODULE_10__.normalize)(collection.name);\n                const searchQuery = (0,_Plugins_utils__WEBPACK_IMPORTED_MODULE_10__.normalize)(event.query);\n                if (searchQuery === undefined) {\n                    return;\n                }\n                return name?.startsWith(searchQuery);\n            });\n        },\n        toogleDelete(event, index) {\n            this.deletingIndex = index;\n            // @ts-ignore\n            this.$refs.op.toggle(event);\n        },\n        confirm() {\n            if (!this.isOpen) {\n                return;\n            }\n            if (!this.productsSelected) {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.useToast)().open({\n                    type: 'error',\n                    message: \"Select at least one item\",\n                    duration: 3000,\n                });\n                return;\n            }\n            this.$store.dispatch('modals/close', new _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__[\"default\"]('modalProducts', this.productsSelected));\n            this.filteredCollections = [];\n            this.selectedCollection = null;\n            this.productsSelected = [];\n        },\n        close() {\n            this.$store.dispatch('modals/close', new _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__[\"default\"]('modalProducts'));\n            this.filteredCollections = [];\n            this.selectedCollection = null;\n            this.productsSelected = [];\n        },\n        deleteCollection(event) {\n            // @ts-ignore\n            this.$refs.op.hide(event);\n            if (this.deletingIndex != -1) {\n                this.productsSelected.splice(this.deletingIndex, 1);\n            }\n        },\n        clear() {\n            this.collectionToFilter = null;\n            this.selectedCollection = null;\n            this.selectedCollectionProducts = [];\n            this.loading = false;\n            this.searchLoading = false;\n            this.currentPage = 1;\n            this.noMorePages = false;\n            this.requestProductsList(true);\n        },\n        requestProductsList(clearProductList) {\n            if (clearProductList) {\n                this.productsList = [];\n            }\n            if (this.searchLoading || this.noMorePages) {\n                return;\n            }\n            this.searchLoading = true;\n            if (this.loading) {\n                this.loading = false;\n            }\n            if (this.currentPage <= 1) {\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance().getProductService()?.setSettingsQuery(this.settingsQuery);\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                    .getProductService()\n                    ?.getProducts()\n                    .then((products) => {\n                    this.currentPage += 1;\n                    this.productsList.push(...products);\n                    if (products.length == 0) {\n                        this.noMorePages = true;\n                    }\n                    this.searchLoading = false;\n                })\n                    .catch((e) => {\n                    (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.toastGenericError)();\n                    this.productsList = [];\n                    this.searchLoading = false;\n                    throw e;\n                });\n            }\n            else {\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                    .getProductService()\n                    ?.fetchNext()\n                    .then((products) => {\n                    this.currentPage += 1;\n                    this.productsList.push(...products);\n                    if (products.length == 0) {\n                        this.noMorePages = true;\n                    }\n                    this.searchLoading = false;\n                })\n                    .catch((e) => {\n                    console.log(\"OLA\", e);\n                    (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.toastGenericError)();\n                    this.productsList = [];\n                    this.searchLoading = false;\n                    throw e;\n                });\n            }\n        },\n        requestCollectionsList() {\n            this.collectionsList = [];\n            _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                .getCollectionService()\n                ?.getAllCollections()\n                .then((collections) => {\n                this.collectionsList = collections;\n            })\n                .catch((e) => {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.toastGenericError)();\n                this.collectionsList = [];\n                throw e;\n            });\n        },\n    },\n    watch: {\n        isOpen(val) {\n            if (val) {\n                if (this.extraInfo.data) {\n                    this.productsSelected = (0,lodash_es__WEBPACK_IMPORTED_MODULE_13__[\"default\"])(this.extraInfo.data);\n                }\n                this.maxElements = this.extraInfo.maxElements ? this.extraInfo.maxElements : null;\n                this.requestCollectionsList();\n                if (!(this.search && this.productsList.length > 0) ||\n                    this.lastOpenId != this.whoisOpening) {\n                    this.search = '';\n                    this.clear();\n                }\n                this.lastOpenId = this.whoisOpening;\n            }\n        },\n    },\n    computed: {\n        settingsQuery() {\n            return {\n                showProductsOutOfStock: this.showProductsOutOfStock !== undefined ? this.showProductsOutOfStock : undefined,\n                showAllProducts: true,\n                searchName: this.search != null ? this.search : undefined,\n            };\n        },\n        showEmpty() {\n            if (this.ProductsFilter.length > 0) {\n                return false;\n            }\n            if (this.search && !this.searchLoading) {\n                return true;\n            }\n            return !!(this.selectedCollection && !this.loading);\n        },\n        ProductsFilter() {\n            let filteredProducts = this.products;\n            //Get only products that are not selected\n            filteredProducts = filteredProducts.filter((p) => !this.productsSelected.find((e) => e && e.id == p.id));\n            return filteredProducts;\n        },\n        collections() {\n            return this.collectionsList;\n        },\n        products() {\n            if (!this.selectedCollection) {\n                return this.productsList;\n            }\n            else {\n                return this.selectedCollectionProducts;\n            }\n        },\n        isOpen() {\n            return this.$store.getters['modals/allOpen'].includes('modalProducts');\n        },\n        extraInfo() {\n            return this.$store.getters['modals/extraInfo'];\n        },\n        whoisOpening() {\n            return this.$store.getters['modals/whoisOpening'];\n        },\n    },\n}));\n\n\n//# sourceURL=webpack://napps.discountrules/./src/Components/ModalProducts.vue?./node_modules/ts-loader/index.js??clonedRuleSet-1!./node_modules/vue-loader/lib/index.js??vue-loader-options");
     678eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _Components_Input_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/Components/Input.vue */ \"./src/Components/Input.vue\");\n/* harmony import */ var primevue_overlaypanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! primevue/overlaypanel */ \"./node_modules/primevue/overlaypanel/index.js\");\n/* harmony import */ var _Modal_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Modal.vue */ \"./src/Components/Modal.vue\");\n/* harmony import */ var _Icons_CollectionIcon_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/Icons/CollectionIcon.vue */ \"./src/Icons/CollectionIcon.vue\");\n/* harmony import */ var _Icons_RemoveContentIcon_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/Icons/RemoveContentIcon.vue */ \"./src/Icons/RemoveContentIcon.vue\");\n/* harmony import */ var primevue_autocomplete__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! primevue/autocomplete */ \"./node_modules/primevue/autocomplete/index.js\");\n/* harmony import */ var _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/Models/ModalCloseRequest */ \"./src/Models/ModalCloseRequest.ts\");\n/* harmony import */ var _Icons_RemoveIcon_vue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/Icons/RemoveIcon.vue */ \"./src/Icons/RemoveIcon.vue\");\n/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! lodash-es */ \"./node_modules/lodash-es/cloneDeep.js\");\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/ShopOnline/ShopOnline */ \"./src/ShopOnline/ShopOnline.ts\");\n/* harmony import */ var _Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/Plugins/toasted */ \"./src/Plugins/toasted/index.js\");\n/* harmony import */ var _Models_Modals__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/Models/Modals */ \"./src/Models/Modals.ts\");\n\n\n\n\n\n\n\n\n// @ts-ignore\n\n\n\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (vue__WEBPACK_IMPORTED_MODULE_11__[\"default\"].extend({\n    name: 'ModalProducts',\n    props: {\n        maxWidth: {\n            default: '7xl',\n        },\n        closeable: {\n            default: true,\n        },\n        canSelectPrivateProducts: {\n            default: false,\n        },\n        showProductsOutOfStock: {\n            type: Boolean,\n            default: null,\n        },\n    },\n    data() {\n        return {\n            filteredCollections: [],\n            productsList: [],\n            collectionsList: [],\n            // Selected collections\n            selectedCollection: null,\n            selectedCollectionProducts: [],\n            // Final products list\n            productsSelected: [],\n            collectionToFilter: null,\n            maxElements: null,\n            search: null,\n            deletingIndex: -1,\n            //Loading\n            loading: false,\n            searchLoading: false,\n            time: null,\n            noMorePages: false,\n            currentPage: 1,\n            lastOpenId: null,\n            name: _Models_Modals__WEBPACK_IMPORTED_MODULE_10__.Modals.ProductsList\n        };\n    },\n    components: {\n        Modal: _Modal_vue__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n        AutoComplete: primevue_autocomplete__WEBPACK_IMPORTED_MODULE_5__[\"default\"],\n        OverlayPanel: primevue_overlaypanel__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n        CollectionIcon: _Icons_CollectionIcon_vue__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n        RemoveContentIcon: _Icons_RemoveContentIcon_vue__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n        Input: _Components_Input_vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n        RemoveIcon: _Icons_RemoveIcon_vue__WEBPACK_IMPORTED_MODULE_7__[\"default\"],\n    },\n    methods: {\n        onScroll(e) {\n            const elem = e.target;\n            const progress = (elem.scrollTop / (elem.scrollHeight - elem.clientHeight)) * 100;\n            if (progress > 75) {\n                if (this.selectedCollection) {\n                    this.requestCollectionProducts(false);\n                    return;\n                }\n                if (!this.search) {\n                    this.requestProductsList(false);\n                    return;\n                }\n            }\n        },\n        replaceByDefault(e) {\n            // @ts-ignore\n            e.target.src = __webpack_require__(/*! @/images/placeholder-images.png */ \"./src/images/placeholder-images.png\");\n        },\n        itemExtraClass(obj) {\n            let css = '';\n            if (!this.canSelectPrivateProducts) {\n                css +=\n                    obj.status != 'publish'\n                        ? ' filter grayscale blur-sd dark:blur-sd contrast-75'\n                        : '';\n            }\n            return css;\n        },\n        addElement(item) {\n            // If we dont want to show all products, avoid select a product that is not publish\n            if (!this.canSelectPrivateProducts && item.status != 'publish') {\n                return false;\n            }\n            if (this.maxElements && this.productsSelected.length + 1 > this.maxElements) {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.useToast)().open({\n                    type: 'error',\n                    title: \"Max elements\",\n                    message: \"You reach the maximum elements of \" + this.maxElements,\n                    duration: 3000,\n                });\n                return false;\n            }\n            this.productsSelected.push(item);\n            return true;\n        },\n        clearAll() {\n            this.productsSelected = [];\n        },\n        onClear() {\n            this.selectedCollection = null;\n            this.selectedCollectionProducts = [];\n            this.noMorePages = false;\n            this.currentPage = 1;\n            this.requestProductsList(true);\n        },\n        selected(item) {\n            //Mark collection as selected\n            this.search = '';\n            this.selectedCollection = item.value.id;\n            this.noMorePages = false;\n            this.currentPage = 1;\n            this.requestCollectionProducts(true);\n        },\n        requestCollectionProducts(clearList) {\n            if (clearList) {\n                this.selectedCollectionProducts = [];\n            }\n            if (!this.selectedCollection || this.noMorePages || this.loading) {\n                return;\n            }\n            this.loading = true;\n            if (this.currentPage <= 1) {\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                    .getProductService()\n                    ?.getProductsFromCollection(this.selectedCollection.toString())\n                    .then((products) => {\n                    this.currentPage += 1;\n                    this.loading = false;\n                    this.selectedCollectionProducts.push(...products);\n                    if (products.length == 0) {\n                        this.noMorePages = true;\n                    }\n                })\n                    .catch((e) => {\n                    this.loading = false;\n                    console.error(e);\n                });\n            }\n            else {\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                    .getProductService()\n                    ?.fetchNext()\n                    .then((products) => {\n                    this.currentPage += 1;\n                    this.loading = false;\n                    this.selectedCollectionProducts.push(...products);\n                    if (products.length == 0) {\n                        this.noMorePages = true;\n                    }\n                })\n                    .catch((e) => {\n                    this.loading = false;\n                    console.error(e);\n                });\n            }\n        },\n        onSearchChange() {\n            if (this.time) {\n                clearTimeout(this.time);\n            }\n            if (this.selectedCollection) {\n                this.searchLoading = false;\n                return;\n            }\n            this.currentPage = 1;\n            this.noMorePages = false;\n            if (!this.search) {\n                this.searchLoading = false;\n                this.requestProductsList(true);\n                return;\n            }\n            this.time = setTimeout(() => {\n                this.requestProductsList(true);\n            }, 1000);\n        },\n        onChange: function (e) {\n            if (e.removed || e.moved || e.added) {\n                //@ts-ignore\n                this.$refs.op.hide();\n                if (e.added) {\n                    const removeNotAllowedProduct = !this.canSelectPrivateProducts && e.added.element.status != 'publish';\n                    if (removeNotAllowedProduct) {\n                        this.productsSelected.splice(e.added.newIndex, 1);\n                        return;\n                    }\n                    if (this.maxElements && this.productsSelected.length > this.maxElements) {\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.useToast)().open({\n                            type: 'error',\n                            title: \"Max elements\",\n                            message: \"You reach the maximum elements of \" + this.maxElements,\n                            duration: 3000,\n                        });\n                        this.productsSelected.splice(e.added.newIndex, 1);\n                    }\n                }\n            }\n        },\n        async onInput(event) {\n            const searchValue = event.query;\n            if (!searchValue) {\n                this.filteredCollections = this.collections;\n                return;\n            }\n            _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                .getCollectionService()?.\n                searchCollections(searchValue).\n                then((collections) => {\n                if (collections === undefined) {\n                    this.filteredCollections = [];\n                    return;\n                }\n                this.filteredCollections = collections;\n            });\n        },\n        toogleDelete(event, index) {\n            this.deletingIndex = index;\n            // @ts-ignore\n            this.$refs.op.toggle(event);\n        },\n        confirm() {\n            if (!this.isOpen) {\n                return;\n            }\n            if (!this.productsSelected) {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.useToast)().open({\n                    type: 'error',\n                    message: \"Select at least one item\",\n                    duration: 3000,\n                });\n                return;\n            }\n            this.$store.dispatch('modals/close', new _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__[\"default\"]('modalProducts', this.productsSelected));\n            this.filteredCollections = [];\n            this.selectedCollection = null;\n            this.productsSelected = [];\n        },\n        close() {\n            this.$store.dispatch('modals/close', new _Models_ModalCloseRequest__WEBPACK_IMPORTED_MODULE_6__[\"default\"]('modalProducts'));\n            this.filteredCollections = [];\n            this.selectedCollection = null;\n            this.productsSelected = [];\n        },\n        deleteCollection(event) {\n            // @ts-ignore\n            this.$refs.op.hide(event);\n            if (this.deletingIndex != -1) {\n                this.productsSelected.splice(this.deletingIndex, 1);\n            }\n        },\n        clear() {\n            this.collectionToFilter = null;\n            this.selectedCollection = null;\n            this.selectedCollectionProducts = [];\n            this.loading = false;\n            this.searchLoading = false;\n            this.currentPage = 1;\n            this.noMorePages = false;\n            this.requestProductsList(true);\n        },\n        requestProductsList(clearProductList) {\n            if (clearProductList) {\n                this.productsList = [];\n            }\n            if (this.searchLoading || this.noMorePages) {\n                return;\n            }\n            this.searchLoading = true;\n            if (this.loading) {\n                this.loading = false;\n            }\n            if (this.currentPage <= 1) {\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance().getProductService()?.setSettingsQuery(this.settingsQuery);\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                    .getProductService()\n                    ?.getProducts()\n                    .then((products) => {\n                    this.currentPage += 1;\n                    this.productsList.push(...products);\n                    if (products.length == 0) {\n                        this.noMorePages = true;\n                    }\n                    this.searchLoading = false;\n                })\n                    .catch((e) => {\n                    (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.toastGenericError)();\n                    this.productsList = [];\n                    this.searchLoading = false;\n                    throw e;\n                });\n            }\n            else {\n                _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                    .getProductService()\n                    ?.fetchNext()\n                    .then((products) => {\n                    this.currentPage += 1;\n                    this.productsList.push(...products);\n                    if (products.length == 0) {\n                        this.noMorePages = true;\n                    }\n                    this.searchLoading = false;\n                })\n                    .catch((e) => {\n                    console.log(\"OLA\", e);\n                    (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.toastGenericError)();\n                    this.productsList = [];\n                    this.searchLoading = false;\n                    throw e;\n                });\n            }\n        },\n        requestCollectionsList() {\n            this.collectionsList = [];\n            _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getInstance()\n                .getCollectionService()\n                ?.getCollections()\n                .then((collections) => {\n                this.collectionsList = collections;\n            })\n                .catch(() => {\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_9__.toastGenericError)();\n                this.collectionsList = [];\n            });\n        },\n    },\n    watch: {\n        isOpen(val) {\n            if (val) {\n                if (this.extraInfo.data) {\n                    this.productsSelected = (0,lodash_es__WEBPACK_IMPORTED_MODULE_12__[\"default\"])(this.extraInfo.data);\n                }\n                this.maxElements = this.extraInfo.maxElements ? this.extraInfo.maxElements : null;\n                this.requestCollectionsList();\n                if (!(this.search && this.productsList.length > 0) ||\n                    this.lastOpenId != this.whoisOpening) {\n                    this.search = '';\n                    this.clear();\n                }\n                this.lastOpenId = this.whoisOpening;\n            }\n        },\n    },\n    computed: {\n        settingsQuery() {\n            return {\n                showProductsOutOfStock: this.showProductsOutOfStock !== undefined ? this.showProductsOutOfStock : undefined,\n                showAllProducts: true,\n                searchName: this.search != null ? this.search : undefined,\n            };\n        },\n        showEmpty() {\n            if (this.ProductsFilter.length > 0) {\n                return false;\n            }\n            if (this.search && !this.searchLoading) {\n                return true;\n            }\n            return !!(this.selectedCollection && !this.loading);\n        },\n        ProductsFilter() {\n            let filteredProducts = this.products;\n            //Get only products that are not selected\n            filteredProducts = filteredProducts.filter((p) => !this.productsSelected.find((e) => e && e.id == p.id));\n            return filteredProducts;\n        },\n        collections() {\n            return this.collectionsList;\n        },\n        products() {\n            if (!this.selectedCollection) {\n                return this.productsList;\n            }\n            else {\n                return this.selectedCollectionProducts;\n            }\n        },\n        isOpen() {\n            return this.$store.getters['modals/allOpen'].includes(_Models_Modals__WEBPACK_IMPORTED_MODULE_10__.Modals.ProductsList);\n        },\n        extraInfo() {\n            return this.$store.getters['modals/extraInfo'];\n        },\n        whoisOpening() {\n            return this.$store.getters['modals/whoisOpening'];\n        },\n    },\n}));\n\n\n//# sourceURL=webpack://napps.discountrules/./src/Components/ModalProducts.vue?./node_modules/ts-loader/index.js??clonedRuleSet-1!./node_modules/vue-loader/lib/index.js??vue-loader-options");
    679679
    680680/***/ }),
     
    687687
    688688"use strict";
    689 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _Models_discount__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/Models/discount */ \"./src/Models/discount.ts\");\n/* harmony import */ var _Icons_Loading_vue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/Icons/Loading.vue */ \"./src/Icons/Loading.vue\");\n/* harmony import */ var _Icons_MenuHorizontalIcon_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/Icons/MenuHorizontalIcon.vue */ \"./src/Icons/MenuHorizontalIcon.vue\");\n/* harmony import */ var _Components_MenuTooltip_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/Components/MenuTooltip.vue */ \"./src/Components/MenuTooltip.vue\");\n/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/store */ \"./src/store/index.ts\");\n/* harmony import */ var _Models_ModalOpenRequest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/Models/ModalOpenRequest */ \"./src/Models/ModalOpenRequest.ts\");\n/* harmony import */ var _Models_Modals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/Models/Modals */ \"./src/Models/Modals.ts\");\n/* harmony import */ var _Components_ModalProducts_vue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/Components/ModalProducts.vue */ \"./src/Components/ModalProducts.vue\");\n/* harmony import */ var _Components_ModalCollections_vue__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/Components/ModalCollections.vue */ \"./src/Components/ModalCollections.vue\");\n/* harmony import */ var _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/ShopOnline/ShopOnline */ \"./src/ShopOnline/ShopOnline.ts\");\n/* harmony import */ var _Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/Plugins/toasted */ \"./src/Plugins/toasted/index.js\");\n/* harmony import */ var _EditDiscountRule_vue__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./EditDiscountRule.vue */ \"./src/admin/pages/Home/EditDiscountRule.vue\");\n/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! lodash-es */ \"./node_modules/lodash-es/cloneDeep.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n// @ts-ignore\n\n// @ts-ignore\n\nvar DiscountTooltipOptions;\n(function (DiscountTooltipOptions) {\n    DiscountTooltipOptions[DiscountTooltipOptions[\"ChooseProduct\"] = 0] = \"ChooseProduct\";\n    DiscountTooltipOptions[DiscountTooltipOptions[\"ChooseCollections\"] = 1] = \"ChooseCollections\";\n    DiscountTooltipOptions[DiscountTooltipOptions[\"SetActive\"] = 2] = \"SetActive\";\n    DiscountTooltipOptions[DiscountTooltipOptions[\"SetInactive\"] = 3] = \"SetInactive\";\n    DiscountTooltipOptions[DiscountTooltipOptions[\"Delete\"] = 4] = \"Delete\";\n})(DiscountTooltipOptions || (DiscountTooltipOptions = {}));\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_12__.defineComponent)({\n    __name: 'DiscountRulesList',\n    props: {\n        value: Array,\n        loading: Boolean,\n    },\n    emits: ['delete'],\n    setup(__props, { emit }) {\n        const props = __props;\n        // Tooltip selected option, and tooltip layout to trigger actions on\n        const tooltipValue = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(undefined);\n        const tooltipForLayout = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(undefined);\n        const modalDiscountLayout = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(undefined);\n        const modalDiscountName = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(undefined);\n        const openTooltipToTop = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(false);\n        const store = (0,_store__WEBPACK_IMPORTED_MODULE_4__.useStore)();\n        const id = \"discountRulesList\";\n        const discountList = (0,vue__WEBPACK_IMPORTED_MODULE_12__.computed)(() => {\n            if (props.value === undefined) {\n                return [];\n            }\n            return props.value;\n        });\n        const dataLoading = (0,vue__WEBPACK_IMPORTED_MODULE_12__.computed)(() => {\n            return props.loading;\n        });\n        const extraInfo = (0,vue__WEBPACK_IMPORTED_MODULE_12__.computed)(() => {\n            return store.getters['modals/closeExtra'](id);\n        });\n        (0,vue__WEBPACK_IMPORTED_MODULE_12__.watch)(extraInfo, (val) => {\n            const data = val?.data;\n            if (!data || modalDiscountLayout.value === undefined || modalDiscountName.value === undefined) {\n                return;\n            }\n            const layoutActiveIndex = discountList.value.findIndex((e) => e.id == modalDiscountLayout.value);\n            if (layoutActiveIndex == -1) {\n                modalDiscountLayout.value = undefined;\n                return;\n            }\n            const discountRule = discountList.value[layoutActiveIndex];\n            switch (modalDiscountName.value) {\n                case _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.ProductsList:\n                    discountRule.products = data;\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"collections\", undefined);\n                    break;\n                case _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.CollectionsList:\n                    discountRule.collections = data;\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"products\", undefined);\n                    break;\n                case _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.EditDiscountRule:\n                    discountRule.name = data.name;\n                    discountRule.amount = data.amount;\n                    discountRule.discountType = data.discountType;\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"products\", undefined);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"collections\", undefined);\n                    break;\n                default:\n                    modalDiscountName.value = undefined;\n                    modalDiscountLayout.value = undefined;\n                    return;\n            }\n            updateDiscountRule(discountRule);\n            modalDiscountName.value = undefined;\n            modalDiscountLayout.value = undefined;\n        });\n        const onEditClick = (discountRule) => {\n            modalDiscountLayout.value = discountRule.id;\n            modalDiscountName.value = _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.EditDiscountRule;\n            store.dispatch(\"modals/open\", new _Models_ModalOpenRequest__WEBPACK_IMPORTED_MODULE_5__[\"default\"](id, _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.EditDiscountRule, (0,lodash_es__WEBPACK_IMPORTED_MODULE_13__[\"default\"])(discountRule)));\n        };\n        const updateDiscountRule = (discountRule) => {\n            _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_9__[\"default\"].getInstance().\n                getDiscountRuleService()?.\n                update(discountRule).\n                then((response) => {\n                if (!response) {\n                    (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                    return;\n                }\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.useToast)().open({\n                    type: 'success',\n                    message: \"Discount rule updated\",\n                    duration: 5000,\n                });\n            });\n        };\n        const getTooltipText = (option) => {\n            switch (option) {\n                case DiscountTooltipOptions.ChooseProduct:\n                    return \"Select products\";\n                case DiscountTooltipOptions.ChooseCollections:\n                    return \"Select collections\";\n                case DiscountTooltipOptions.SetActive:\n                    return \"Set as active\";\n                case DiscountTooltipOptions.SetInactive:\n                    return \"Set as inactive\";\n                case DiscountTooltipOptions.Delete:\n                    return \"Delete\";\n                default:\n                    return \"\";\n            }\n        };\n        const getAutomationTollipFromText = (text) => {\n            switch (text) {\n                case \"Select products\":\n                    return DiscountTooltipOptions.ChooseProduct;\n                case \"Select collections\":\n                    return DiscountTooltipOptions.ChooseCollections;\n                case \"Set as inactive\":\n                    return DiscountTooltipOptions.SetInactive;\n                case \"Set as active\":\n                    return DiscountTooltipOptions.SetActive;\n                case \"Delete\":\n                    return DiscountTooltipOptions.Delete;\n                default:\n                    return undefined;\n            }\n        };\n        const formatData = (created) => {\n            const date = new Date(created.seconds * 1000);\n            return date.toDateString();\n        };\n        /** Tooltip methods */\n        const tooltipOptions = (discount) => {\n            let defaultOptions = [\n                getTooltipText(DiscountTooltipOptions.ChooseProduct),\n                getTooltipText(DiscountTooltipOptions.ChooseCollections),\n            ];\n            if (discount.status == _Models_discount__WEBPACK_IMPORTED_MODULE_0__.DiscountStatus.Active) {\n                defaultOptions.push(getTooltipText(DiscountTooltipOptions.SetInactive));\n            }\n            else {\n                defaultOptions.push(getTooltipText(DiscountTooltipOptions.SetActive));\n            }\n            defaultOptions.push(getTooltipText(DiscountTooltipOptions.Delete));\n            return defaultOptions;\n        };\n        const openTooltip = (id, event) => {\n            if (tooltipForLayout.value == id) {\n                return;\n            }\n            tooltipForLayout.value = id;\n            openTooltipToTop.value = event.y + 190 + 40 > screen.height;\n        };\n        const resetTooltip = () => {\n            tooltipForLayout.value = undefined;\n            tooltipValue.value = undefined;\n        };\n        const getTargetForDiscount = async (discountRule) => {\n            const result = await _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_9__[\"default\"].getInstance()\n                .getDiscountRuleService()\n                ?.getTargetForDiscount(discountRule);\n            return result !== undefined;\n        };\n        const closeTooltip = async () => {\n            if (tooltipForLayout.value == undefined) {\n                return;\n            }\n            const layoutActiveIndex = discountList.value.findIndex((e) => e.id == tooltipForLayout.value);\n            if (layoutActiveIndex == -1) {\n                resetTooltip();\n                return;\n            }\n            const discountRule = discountList.value[layoutActiveIndex];\n            switch (getAutomationTollipFromText(tooltipValue.value)) {\n                case DiscountTooltipOptions.ChooseProduct:\n                    const gotTarget = await getTargetForDiscount(discountRule);\n                    if (!gotTarget) {\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                        break;\n                    }\n                    modalDiscountLayout.value = tooltipForLayout.value;\n                    modalDiscountName.value = _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.ProductsList;\n                    store.dispatch(\"modals/open\", new _Models_ModalOpenRequest__WEBPACK_IMPORTED_MODULE_5__[\"default\"](id, _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.ProductsList, {\n                        data: discountRule.products,\n                    }));\n                    break;\n                case DiscountTooltipOptions.ChooseCollections:\n                    const gotTargetCollections = await getTargetForDiscount(discountRule);\n                    if (!gotTargetCollections) {\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                        break;\n                    }\n                    modalDiscountLayout.value = tooltipForLayout.value;\n                    modalDiscountName.value = _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.CollectionsList;\n                    store.dispatch(\"modals/open\", new _Models_ModalOpenRequest__WEBPACK_IMPORTED_MODULE_5__[\"default\"](id, _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.CollectionsList, {\n                        data: discountRule,\n                    }));\n                    break;\n                case DiscountTooltipOptions.SetInactive:\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"status\", _Models_discount__WEBPACK_IMPORTED_MODULE_0__.DiscountStatus.Inactive);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"products\", undefined);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"collections\", undefined);\n                    updateDiscountRule(discountRule);\n                    break;\n                case DiscountTooltipOptions.SetActive:\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"status\", _Models_discount__WEBPACK_IMPORTED_MODULE_0__.DiscountStatus.Active);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"products\", undefined);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"collections\", undefined);\n                    updateDiscountRule(discountRule);\n                    break;\n                case DiscountTooltipOptions.Delete:\n                    _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_9__[\"default\"].getInstance().\n                        getDiscountRuleService()?.\n                        delete(discountRule).\n                        then((response) => {\n                        if (!response) {\n                            (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                            return;\n                        }\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.useToast)().open({\n                            type: 'success',\n                            message: \"Discount rule deleted\",\n                            duration: 5000,\n                        });\n                        emit(\"delete\", discountRule);\n                    }).catch(() => {\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                    });\n            }\n            resetTooltip();\n        };\n        return { __sfc: true, DiscountTooltipOptions, props, tooltipValue, tooltipForLayout, modalDiscountLayout, modalDiscountName, openTooltipToTop, store, id, emit, discountList, dataLoading, extraInfo, onEditClick, updateDiscountRule, getTooltipText, getAutomationTollipFromText, formatData, tooltipOptions, openTooltip, resetTooltip, getTargetForDiscount, closeTooltip, discountStatusToJSON: _Models_discount__WEBPACK_IMPORTED_MODULE_0__.discountStatusToJSON, discountTypeToJSON: _Models_discount__WEBPACK_IMPORTED_MODULE_0__.discountTypeToJSON, Loading: _Icons_Loading_vue__WEBPACK_IMPORTED_MODULE_1__[\"default\"], MenuHorizontalIcon: _Icons_MenuHorizontalIcon_vue__WEBPACK_IMPORTED_MODULE_2__[\"default\"], MenuTooltip: _Components_MenuTooltip_vue__WEBPACK_IMPORTED_MODULE_3__[\"default\"], ModalProducts: _Components_ModalProducts_vue__WEBPACK_IMPORTED_MODULE_7__[\"default\"], ModalCollections: _Components_ModalCollections_vue__WEBPACK_IMPORTED_MODULE_8__[\"default\"], EditDiscountRule: _EditDiscountRule_vue__WEBPACK_IMPORTED_MODULE_11__[\"default\"] };\n    }\n}));\n\n\n//# sourceURL=webpack://napps.discountrules/./src/admin/pages/Home/DiscountRulesList.vue?./node_modules/ts-loader/index.js??clonedRuleSet-1!./node_modules/vue-loader/lib/index.js??vue-loader-options");
     689eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _Models_discount__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/Models/discount */ \"./src/Models/discount.ts\");\n/* harmony import */ var _Icons_Loading_vue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/Icons/Loading.vue */ \"./src/Icons/Loading.vue\");\n/* harmony import */ var _Icons_MenuHorizontalIcon_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/Icons/MenuHorizontalIcon.vue */ \"./src/Icons/MenuHorizontalIcon.vue\");\n/* harmony import */ var _Components_MenuTooltip_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/Components/MenuTooltip.vue */ \"./src/Components/MenuTooltip.vue\");\n/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/store */ \"./src/store/index.ts\");\n/* harmony import */ var _Models_ModalOpenRequest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/Models/ModalOpenRequest */ \"./src/Models/ModalOpenRequest.ts\");\n/* harmony import */ var _Models_Modals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/Models/Modals */ \"./src/Models/Modals.ts\");\n/* harmony import */ var _Components_ModalProducts_vue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/Components/ModalProducts.vue */ \"./src/Components/ModalProducts.vue\");\n/* harmony import */ var _Components_ModalCollections_vue__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/Components/ModalCollections.vue */ \"./src/Components/ModalCollections.vue\");\n/* harmony import */ var _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/ShopOnline/ShopOnline */ \"./src/ShopOnline/ShopOnline.ts\");\n/* harmony import */ var _Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/Plugins/toasted */ \"./src/Plugins/toasted/index.js\");\n/* harmony import */ var _EditDiscountRule_vue__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./EditDiscountRule.vue */ \"./src/admin/pages/Home/EditDiscountRule.vue\");\n/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! lodash-es */ \"./node_modules/lodash-es/cloneDeep.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n// @ts-ignore\n\n// @ts-ignore\n\nvar DiscountTooltipOptions;\n(function (DiscountTooltipOptions) {\n    DiscountTooltipOptions[DiscountTooltipOptions[\"ChooseProduct\"] = 0] = \"ChooseProduct\";\n    DiscountTooltipOptions[DiscountTooltipOptions[\"ChooseCollections\"] = 1] = \"ChooseCollections\";\n    DiscountTooltipOptions[DiscountTooltipOptions[\"SetActive\"] = 2] = \"SetActive\";\n    DiscountTooltipOptions[DiscountTooltipOptions[\"SetInactive\"] = 3] = \"SetInactive\";\n    DiscountTooltipOptions[DiscountTooltipOptions[\"Delete\"] = 4] = \"Delete\";\n})(DiscountTooltipOptions || (DiscountTooltipOptions = {}));\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (/*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_12__.defineComponent)({\n    __name: 'DiscountRulesList',\n    props: {\n        value: Array,\n        loading: Boolean,\n    },\n    emits: ['delete'],\n    setup(__props, { emit }) {\n        const props = __props;\n        // Tooltip selected option, and tooltip layout to trigger actions on\n        const tooltipValue = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(undefined);\n        const tooltipForLayout = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(undefined);\n        const modalDiscountLayout = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(undefined);\n        const modalDiscountName = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(undefined);\n        const openTooltipToTop = (0,vue__WEBPACK_IMPORTED_MODULE_12__.ref)(false);\n        const store = (0,_store__WEBPACK_IMPORTED_MODULE_4__.useStore)();\n        const id = \"discountRulesList\";\n        const discountList = (0,vue__WEBPACK_IMPORTED_MODULE_12__.computed)(() => {\n            if (props.value === undefined) {\n                return [];\n            }\n            return props.value;\n        });\n        const dataLoading = (0,vue__WEBPACK_IMPORTED_MODULE_12__.computed)(() => {\n            return props.loading;\n        });\n        const extraInfo = (0,vue__WEBPACK_IMPORTED_MODULE_12__.computed)(() => {\n            return store.getters['modals/closeExtra'](id);\n        });\n        (0,vue__WEBPACK_IMPORTED_MODULE_12__.watch)(extraInfo, (val) => {\n            const data = val?.data;\n            console.log(data, modalDiscountLayout.value, modalDiscountName.value);\n            if (!data || modalDiscountLayout.value === undefined || modalDiscountName.value === undefined) {\n                return;\n            }\n            const layoutActiveIndex = discountList.value.findIndex((e) => e.id == modalDiscountLayout.value);\n            if (layoutActiveIndex == -1) {\n                modalDiscountLayout.value = undefined;\n                return;\n            }\n            const discountRule = discountList.value[layoutActiveIndex];\n            switch (modalDiscountName.value) {\n                case _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.ProductsList:\n                    discountRule.products = data;\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"collections\", undefined);\n                    break;\n                case _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.CollectionsList:\n                    discountRule.collections = data;\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"products\", undefined);\n                    break;\n                case _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.EditDiscountRule:\n                    discountRule.name = data.name;\n                    discountRule.amount = data.amount;\n                    discountRule.discountType = data.discountType;\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"products\", undefined);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"collections\", undefined);\n                    break;\n                default:\n                    modalDiscountName.value = undefined;\n                    modalDiscountLayout.value = undefined;\n                    return;\n            }\n            updateDiscountRule(discountRule);\n            modalDiscountName.value = undefined;\n            modalDiscountLayout.value = undefined;\n        });\n        const onEditClick = (discountRule) => {\n            modalDiscountLayout.value = discountRule.id;\n            modalDiscountName.value = _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.EditDiscountRule;\n            store.dispatch(\"modals/open\", new _Models_ModalOpenRequest__WEBPACK_IMPORTED_MODULE_5__[\"default\"](id, _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.EditDiscountRule, (0,lodash_es__WEBPACK_IMPORTED_MODULE_13__[\"default\"])(discountRule)));\n        };\n        const updateDiscountRule = (discountRule) => {\n            _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_9__[\"default\"].getInstance().\n                getDiscountRuleService()?.\n                update(discountRule).\n                then((response) => {\n                if (!response) {\n                    (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                    return;\n                }\n                (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.useToast)().open({\n                    type: 'success',\n                    message: \"Discount rule updated\",\n                    duration: 5000,\n                });\n            });\n        };\n        const getTooltipText = (option) => {\n            switch (option) {\n                case DiscountTooltipOptions.ChooseProduct:\n                    return \"Select products\";\n                case DiscountTooltipOptions.ChooseCollections:\n                    return \"Select collections\";\n                case DiscountTooltipOptions.SetActive:\n                    return \"Set as active\";\n                case DiscountTooltipOptions.SetInactive:\n                    return \"Set as inactive\";\n                case DiscountTooltipOptions.Delete:\n                    return \"Delete\";\n                default:\n                    return \"\";\n            }\n        };\n        const getAutomationTollipFromText = (text) => {\n            switch (text) {\n                case \"Select products\":\n                    return DiscountTooltipOptions.ChooseProduct;\n                case \"Select collections\":\n                    return DiscountTooltipOptions.ChooseCollections;\n                case \"Set as inactive\":\n                    return DiscountTooltipOptions.SetInactive;\n                case \"Set as active\":\n                    return DiscountTooltipOptions.SetActive;\n                case \"Delete\":\n                    return DiscountTooltipOptions.Delete;\n                default:\n                    return undefined;\n            }\n        };\n        const formatData = (created) => {\n            const date = new Date(created.seconds * 1000);\n            return date.toDateString();\n        };\n        /** Tooltip methods */\n        const tooltipOptions = (discount) => {\n            let defaultOptions = [\n                getTooltipText(DiscountTooltipOptions.ChooseProduct),\n                getTooltipText(DiscountTooltipOptions.ChooseCollections),\n            ];\n            if (discount.status == _Models_discount__WEBPACK_IMPORTED_MODULE_0__.DiscountStatus.Active) {\n                defaultOptions.push(getTooltipText(DiscountTooltipOptions.SetInactive));\n            }\n            else {\n                defaultOptions.push(getTooltipText(DiscountTooltipOptions.SetActive));\n            }\n            defaultOptions.push(getTooltipText(DiscountTooltipOptions.Delete));\n            return defaultOptions;\n        };\n        const openTooltip = (id, event) => {\n            if (tooltipForLayout.value == id) {\n                return;\n            }\n            tooltipForLayout.value = id;\n            openTooltipToTop.value = event.y + 190 + 40 > screen.height;\n        };\n        const resetTooltip = () => {\n            tooltipForLayout.value = undefined;\n            tooltipValue.value = undefined;\n        };\n        const getTargetForDiscount = async (discountRule) => {\n            const result = await _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_9__[\"default\"].getInstance()\n                .getDiscountRuleService()\n                ?.getTargetForDiscount(discountRule);\n            return result !== undefined;\n        };\n        const closeTooltip = async () => {\n            if (tooltipForLayout.value == undefined) {\n                return;\n            }\n            const layoutActiveIndex = discountList.value.findIndex((e) => e.id == tooltipForLayout.value);\n            if (layoutActiveIndex == -1) {\n                resetTooltip();\n                return;\n            }\n            const discountRule = discountList.value[layoutActiveIndex];\n            switch (getAutomationTollipFromText(tooltipValue.value)) {\n                case DiscountTooltipOptions.ChooseProduct:\n                    getTargetForDiscount(discountRule).\n                        then((gotTarget) => {\n                        if (!gotTarget) {\n                            (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                            resetTooltip();\n                            return;\n                        }\n                        console.log((0,lodash_es__WEBPACK_IMPORTED_MODULE_13__[\"default\"])(tooltipForLayout.value));\n                        modalDiscountLayout.value = tooltipForLayout.value;\n                        modalDiscountName.value = _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.ProductsList;\n                        store.dispatch(\"modals/open\", new _Models_ModalOpenRequest__WEBPACK_IMPORTED_MODULE_5__[\"default\"](id, _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.ProductsList, {\n                            data: discountRule.products,\n                        }));\n                        resetTooltip();\n                    });\n                    return;\n                case DiscountTooltipOptions.ChooseCollections:\n                    getTargetForDiscount(discountRule).\n                        then((gotTargetCollections) => {\n                        if (!gotTargetCollections) {\n                            (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                            resetTooltip();\n                            return;\n                        }\n                        modalDiscountLayout.value = tooltipForLayout.value;\n                        modalDiscountName.value = _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.CollectionsList;\n                        store.dispatch(\"modals/open\", new _Models_ModalOpenRequest__WEBPACK_IMPORTED_MODULE_5__[\"default\"](id, _Models_Modals__WEBPACK_IMPORTED_MODULE_6__.Modals.CollectionsList, {\n                            data: discountRule,\n                        }));\n                        resetTooltip();\n                    });\n                    return;\n                case DiscountTooltipOptions.SetInactive:\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"status\", _Models_discount__WEBPACK_IMPORTED_MODULE_0__.DiscountStatus.Inactive);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"products\", undefined);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"collections\", undefined);\n                    updateDiscountRule(discountRule);\n                    break;\n                case DiscountTooltipOptions.SetActive:\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"status\", _Models_discount__WEBPACK_IMPORTED_MODULE_0__.DiscountStatus.Active);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"products\", undefined);\n                    (0,vue__WEBPACK_IMPORTED_MODULE_12__.set)(discountRule, \"collections\", undefined);\n                    updateDiscountRule(discountRule);\n                    break;\n                case DiscountTooltipOptions.Delete:\n                    _ShopOnline_ShopOnline__WEBPACK_IMPORTED_MODULE_9__[\"default\"].getInstance().\n                        getDiscountRuleService()?.\n                        delete(discountRule).\n                        then((response) => {\n                        if (!response) {\n                            (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                            return;\n                        }\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.useToast)().open({\n                            type: 'success',\n                            message: \"Discount rule deleted\",\n                            duration: 5000,\n                        });\n                        emit(\"delete\", discountRule);\n                    }).catch(() => {\n                        (0,_Plugins_toasted__WEBPACK_IMPORTED_MODULE_10__.toastGenericError)();\n                    });\n                    break;\n            }\n            resetTooltip();\n        };\n        return { __sfc: true, DiscountTooltipOptions, props, tooltipValue, tooltipForLayout, modalDiscountLayout, modalDiscountName, openTooltipToTop, store, id, emit, discountList, dataLoading, extraInfo, onEditClick, updateDiscountRule, getTooltipText, getAutomationTollipFromText, formatData, tooltipOptions, openTooltip, resetTooltip, getTargetForDiscount, closeTooltip, DiscountStatus: _Models_discount__WEBPACK_IMPORTED_MODULE_0__.DiscountStatus, discountStatusToJSON: _Models_discount__WEBPACK_IMPORTED_MODULE_0__.discountStatusToJSON, discountTypeToJSON: _Models_discount__WEBPACK_IMPORTED_MODULE_0__.discountTypeToJSON, Loading: _Icons_Loading_vue__WEBPACK_IMPORTED_MODULE_1__[\"default\"], MenuHorizontalIcon: _Icons_MenuHorizontalIcon_vue__WEBPACK_IMPORTED_MODULE_2__[\"default\"], MenuTooltip: _Components_MenuTooltip_vue__WEBPACK_IMPORTED_MODULE_3__[\"default\"], ModalProducts: _Components_ModalProducts_vue__WEBPACK_IMPORTED_MODULE_7__[\"default\"], ModalCollections: _Components_ModalCollections_vue__WEBPACK_IMPORTED_MODULE_8__[\"default\"], EditDiscountRule: _EditDiscountRule_vue__WEBPACK_IMPORTED_MODULE_11__[\"default\"] };\n    }\n}));\n\n\n//# sourceURL=webpack://napps.discountrules/./src/admin/pages/Home/DiscountRulesList.vue?./node_modules/ts-loader/index.js??clonedRuleSet-1!./node_modules/vue-loader/lib/index.js??vue-loader-options");
    690690
    691691/***/ }),
     
    812812/***/ }),
    813813
    814 /***/ "./src/Plugins/utils/index.ts":
    815 /*!************************************!*\
    816   !*** ./src/Plugins/utils/index.ts ***!
    817   \************************************/
    818 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
    819 
    820 "use strict";
    821 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"capitalize\": () => (/* binding */ capitalize),\n/* harmony export */   \"isDarkMode\": () => (/* binding */ isDarkMode),\n/* harmony export */   \"isUrlValid\": () => (/* binding */ isUrlValid),\n/* harmony export */   \"normalize\": () => (/* binding */ normalize),\n/* harmony export */   \"roundNearPare\": () => (/* binding */ roundNearPare)\n/* harmony export */ });\nfunction isUrlValid(str) {\n    if (str === undefined || str == \"\") {\n        return false;\n    }\n    var pattern = new RegExp(\"^(https:\\\\/\\\\/)\" + // protocol\n        \"((([a-z\\\\d]([a-z\\\\d-]*[a-z\\\\d])*)\\\\.)+[a-z]{2,}|\" + // domain name\n        \"((\\\\d{1,3}\\\\.){3}\\\\d{1,3}))\" + // OR ip (v4) address\n        \"(\\\\:\\\\d+)?(\\\\/[-a-z\\\\d%_.~+]*)*\" + // port and path\n        \"(\\\\?[;&a-z\\\\d%_.~+=-]*)?\" + // query string\n        \"(\\\\#[-a-z\\\\d_]*)?$\", \"i\"); // fragment locator\n    return !!pattern.test(str);\n}\nfunction isDarkMode() {\n    return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && false;\n}\nfunction normalize(string) {\n    if (string === undefined) {\n        return undefined;\n    }\n    return (string\n        .normalize(\"NFD\")\n        .replace(/[\\u0300-\\u036f]/g, \"\")\n        .toLowerCase()).trim();\n}\nfunction capitalize(string) {\n    return string.charAt(0).toUpperCase() + string.slice(1);\n}\nfunction roundNearPare(number) {\n    let rounded = 2 * Math.round(number / 2);\n    if (rounded < 2)\n        rounded = 2;\n    return rounded;\n}\n\n\n//# sourceURL=webpack://napps.discountrules/./src/Plugins/utils/index.ts?");
    822 
    823 /***/ }),
    824 
    825814/***/ "./src/ShopOnline/Adapters/CollectionAdapter.ts":
    826815/*!******************************************************!*\
     
    841830
    842831"use strict";
    843 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (/* binding */ ProductAdapter)\n/* harmony export */ });\n/* harmony import */ var _Models_product__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/Models/product */ \"./src/Models/product.ts\");\n\nclass ProductAdapter {\n    static _instance;\n    constructor() { }\n    static getInstance() {\n        if (this._instance) {\n            return this._instance;\n        }\n        this._instance = new this();\n        return this._instance;\n    }\n    parse(element) {\n        if (element === null || element === undefined) {\n            return undefined;\n        }\n        let thumbnail = \"\";\n        const images = element.images;\n        if (images.length > 0) {\n            const image = images[0];\n            thumbnail = image.src ? image.src : image.thumbnail;\n        }\n        return _Models_product__WEBPACK_IMPORTED_MODULE_0__.Product.fromPartial({\n            id: Number(element.id),\n            name: element.name,\n            vendor: \"\",\n            thumbnail: thumbnail ? thumbnail : \"\",\n            description: element.description,\n            shortDescription: element.short_description,\n            status: 'publish',\n            price: Number(element.prices.price),\n            tags: '',\n            link: element.permalink,\n            createdAt: undefined,\n            updatedAt: undefined,\n            compareAtPrice: Number(element.prices.sale_price),\n            images: [],\n            collections: []\n        });\n    }\n}\n\n\n//# sourceURL=webpack://napps.discountrules/./src/ShopOnline/Adapters/ProductAdapter.ts?");
     832eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (/* binding */ ProductAdapter)\n/* harmony export */ });\n/* harmony import */ var _Models_product__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/Models/product */ \"./src/Models/product.ts\");\n\nclass ProductAdapter {\n    static _instance;\n    constructor() { }\n    static getInstance() {\n        if (this._instance) {\n            return this._instance;\n        }\n        this._instance = new this();\n        return this._instance;\n    }\n    parse(element) {\n        if (element === null || element === undefined) {\n            return undefined;\n        }\n        let thumbnail = \"\";\n        const images = element.images;\n        if (images.length > 0) {\n            const image = images[0];\n            thumbnail = image.src ? image.src : image.thumbnail;\n        }\n        return _Models_product__WEBPACK_IMPORTED_MODULE_0__.Product.fromPartial({\n            id: Number(element.id),\n            name: element.name,\n            vendor: \"\",\n            thumbnail: thumbnail ? thumbnail : \"\",\n            description: element.description,\n            shortDescription: element.short_description,\n            status: 'publish',\n            price: Number(element.prices ? element.prices.price : element.price),\n            tags: '',\n            link: element.permalink,\n            createdAt: undefined,\n            updatedAt: undefined,\n            compareAtPrice: Number(element.prices ? element.prices.sale_price : element.sale_price),\n            images: [],\n            collections: []\n        });\n    }\n}\n\n\n//# sourceURL=webpack://napps.discountrules/./src/ShopOnline/Adapters/ProductAdapter.ts?");
    844833
    845834/***/ }),
     
    852841
    853842"use strict";
    854 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"WPCollectionService\": () => (/* binding */ WPCollectionService)\n/* harmony export */ });\n/* harmony import */ var _ShopOnline_Adapters_CollectionAdapter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/ShopOnline/Adapters/CollectionAdapter */ \"./src/ShopOnline/Adapters/CollectionAdapter.ts\");\n/* harmony import */ var _ShopOnline_ShopOnlineBaseService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/ShopOnline/ShopOnlineBaseService */ \"./src/ShopOnline/ShopOnlineBaseService.ts\");\n\n\nclass WPCollectionService extends _ShopOnline_ShopOnlineBaseService__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n    lastFetch;\n    ITEMS_PER_PAGE = 100;\n    /*\n    *   Get collections\n    *\n    *   Get collections list from shopkeeper, we dont have pagination here\n    */\n    async getCollections() {\n        let response = await fetch(`${this.getStoreV1()}products/categories?per_page=${this.ITEMS_PER_PAGE}`);\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products/categories?per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    /*\n    *   Get custom collections (created on dashboard)\n    *\n    *   Get collections list from shopkeeper that were created on dashboard (fromDasboard prop)\n    */\n    async getCustomCollections() {\n        throw new Error('Not implemented');\n    }\n    /*\n    *   Get all collections\n    *\n    *   Same as getCollections method\n    */\n    async getAllCollections() {\n        let collections = await this.getCollections();\n        while (true) {\n            let nextPage = await this.fetchNext();\n            if (nextPage?.length === 0 || nextPage === undefined) {\n                return collections;\n            }\n            collections?.push(...nextPage);\n        }\n    }\n    /*\n    *   Get collection by id\n    *\n    *   Retrieve collection by id\n    */\n    async getCollection(id) {\n        let response = await fetch(`${this.getStoreV1()}products/categories/${id}`);\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = undefined;\n        const json = await response.json();\n        return this.parseToModel([json])[0];\n    }\n    /*\n    *   Fetch next page\n    *\n    *   Fetch next page based on last request\n    */\n    async fetchNext() {\n        if (!this.lastFetch) {\n            return undefined;\n        }\n        const param = this.lastFetch.config;\n        param.page = param.page + 1;\n        let response = await fetch(`${this.getStoreV1()}${this.lastFetch.resource}&page=${param.page}`);\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch.config = param;\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    parseToModel(models) {\n        let collections = [];\n        // @ts-ignore\n        models.forEach(element => {\n            const parsed = _ShopOnline_Adapters_CollectionAdapter__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getInstance().parse(element);\n            if (parsed !== undefined) {\n                collections.push(parsed);\n            }\n        });\n        return collections;\n    }\n}\n\n\n//# sourceURL=webpack://napps.discountrules/./src/ShopOnline/Modules/Wordpress/WPCollectionService.ts?");
     843eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"WPCollectionService\": () => (/* binding */ WPCollectionService)\n/* harmony export */ });\n/* harmony import */ var _ShopOnline_Adapters_CollectionAdapter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/ShopOnline/Adapters/CollectionAdapter */ \"./src/ShopOnline/Adapters/CollectionAdapter.ts\");\n/* harmony import */ var _ShopOnline_ShopOnlineBaseService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/ShopOnline/ShopOnlineBaseService */ \"./src/ShopOnline/ShopOnlineBaseService.ts\");\n\n\nclass WPCollectionService extends _ShopOnline_ShopOnlineBaseService__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n    lastFetch;\n    ITEMS_PER_PAGE = 100;\n    /*\n    *   Get collections\n    *\n    *   Get collections list from shopkeeper, we dont have pagination here\n    */\n    async getCollections() {\n        let response = await fetch(`${this.getStoreV1()}products/categories?per_page=${this.ITEMS_PER_PAGE}`, {\n            headers: {\n                'X-WP-Nonce': this.getNounce()\n            }\n        });\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products/categories?per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    /*\n    *   Get custom collections (created on dashboard)\n    *\n    *   Get collections list from shopkeeper that were created on dashboard (fromDasboard prop)\n    */\n    async getCustomCollections() {\n        throw new Error('Not implemented');\n    }\n    /*\n    *   Get all collections\n    *\n    *   Same as getCollections method\n    */\n    async getAllCollections() {\n        let collections = await this.getCollections();\n        while (true) {\n            let nextPage = await this.fetchNext();\n            if (nextPage?.length === 0 || nextPage === undefined) {\n                return collections;\n            }\n            collections?.push(...nextPage);\n        }\n    }\n    /*\n    *   Get collection by id\n    *\n    *   Retrieve collection by id\n    */\n    async getCollection(id) {\n        let response = await fetch(`${this.getStoreV1()}products/categories/${id}`, {\n            headers: {\n                'X-WP-Nonce': this.getNounce()\n            }\n        });\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = undefined;\n        const json = await response.json();\n        return this.parseToModel([json])[0];\n    }\n    /*\n    *\tSearch collections by name\n     */\n    async searchCollections(name) {\n        let response = await fetch(`${this.getStoreV1()}products/categories?search=${name}&per_page=${this.ITEMS_PER_PAGE}`, {\n            headers: {\n                'X-WP-Nonce': this.getNounce()\n            }\n        });\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products/categories?search=${name}&per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    /*\n    *   Fetch next page\n    *\n    *   Fetch next page based on last request\n    */\n    async fetchNext() {\n        if (!this.lastFetch) {\n            return undefined;\n        }\n        const param = this.lastFetch.config;\n        param.page = param.page + 1;\n        let response = await fetch(`${this.getStoreV1()}${this.lastFetch.resource}&page=${param.page}`, {\n            headers: {\n                'X-WP-Nonce': this.getNounce()\n            }\n        });\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch.config = param;\n        const json = await response.json();\n        const collections = this.parseToModel(json);\n        if (collections.length == 0) {\n            this.lastFetch = undefined;\n        }\n        return collections;\n    }\n    parseToModel(models) {\n        let collections = [];\n        // @ts-ignore\n        models.forEach(element => {\n            const parsed = _ShopOnline_Adapters_CollectionAdapter__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getInstance().parse(element);\n            if (parsed !== undefined) {\n                collections.push(parsed);\n            }\n        });\n        return collections;\n    }\n}\n\n\n//# sourceURL=webpack://napps.discountrules/./src/ShopOnline/Modules/Wordpress/WPCollectionService.ts?");
    855844
    856845/***/ }),
     
    874863
    875864"use strict";
    876 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"WPProductService\": () => (/* binding */ WPProductService)\n/* harmony export */ });\n/* harmony import */ var _ShopOnline_Adapters_ProductAdapter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/ShopOnline/Adapters/ProductAdapter */ \"./src/ShopOnline/Adapters/ProductAdapter.ts\");\n/* harmony import */ var _ShopOnline_ShopOnlineBaseService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/ShopOnline/ShopOnlineBaseService */ \"./src/ShopOnline/ShopOnlineBaseService.ts\");\n\n\nclass WPProductService extends _ShopOnline_ShopOnlineBaseService__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n    filterQuery;\n    lastFetch;\n    ITEMS_PER_PAGE = 50;\n    /*\n    *   Set filter query for all fetchMethods\n    *   Ex: getProducts() when filterQuery.searchName it set for t-shirts\n    *   Will return only products with t-shirts in their names\n    */\n    setSettingsQuery(query) {\n        this.filterQuery = query;\n    }\n    getSettingsQuery() {\n        return this.filterQuery;\n    }\n    /*\n    *   Get All products\n    *\n    *   Get a list of products with a maximum of 50 (see ITEMS_PER_PAGE) per page\n    *   Filter settings query will apply if available\n    */\n    async getProducts(products) {\n        if (this.filterQuery?.searchName) {\n            return this.searchProducts();\n        }\n        let response = await fetch(`${this.getStoreV1()}products?per_page=${this.ITEMS_PER_PAGE}`);\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products?per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    /*\n    *   Get a single product by id\n    *\n    *   Get one product by products id\n    *   Filter settings will apply, ex: stock setting\n    */\n    async getProduct(id = 1) {\n        let response = await fetch(`${this.getStoreV1()}products/${id}?per_page=${this.ITEMS_PER_PAGE}`);\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products/${id}?per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel([json])[0];\n    }\n    /*\n    *   Get products from one collection\n    *\n    *   Get products from a collection id\n    */\n    async getProductsFromCollection(id) {\n        let response = await fetch(`${this.getStoreV1()}products?category=${id}?per_page=${this.ITEMS_PER_PAGE}`);\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products?category=${id}?per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    /*\n    *   Fetch next\n    *\n    *   Fetch next page of the previous request\n    *   Example if your last call has getProducts you can call fetchNext\n    *   to retrieve the next page of products, each call will return the next page\n    */\n    async fetchNext() {\n        if (!this.lastFetch) {\n            return undefined;\n        }\n        const param = this.lastFetch.config;\n        param.page = param.page + 1;\n        let response = await fetch(`${this.getStoreV1()}${this.lastFetch.resource}&page=${param.page}`);\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch.config = param;\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    /*\n    *   SearchProducts\n    *\n    *   Private method helper to search products based on value search\n    */\n    async searchProducts() {\n        let response = await fetch(`${this.getStoreV1()}products?search=${this.filterQuery?.searchName}`);\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products?search=${this.filterQuery?.searchName}?per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    parseToModel(models) {\n        let products = [];\n        // @ts-ignore\n        models.forEach(element => {\n            const parsedProduct = _ShopOnline_Adapters_ProductAdapter__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getInstance().parse(element);\n            if (parsedProduct !== undefined) {\n                products.push(parsedProduct);\n            }\n        });\n        return products;\n    }\n}\n\n\n//# sourceURL=webpack://napps.discountrules/./src/ShopOnline/Modules/Wordpress/WPProductService.ts?");
     865eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"WPProductService\": () => (/* binding */ WPProductService)\n/* harmony export */ });\n/* harmony import */ var _ShopOnline_Adapters_ProductAdapter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/ShopOnline/Adapters/ProductAdapter */ \"./src/ShopOnline/Adapters/ProductAdapter.ts\");\n/* harmony import */ var _ShopOnline_ShopOnlineBaseService__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/ShopOnline/ShopOnlineBaseService */ \"./src/ShopOnline/ShopOnlineBaseService.ts\");\n\n\nclass WPProductService extends _ShopOnline_ShopOnlineBaseService__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n    filterQuery;\n    lastFetch;\n    ITEMS_PER_PAGE = 50;\n    /*\n    *   Set filter query for all fetchMethods\n    *   Ex: getProducts() when filterQuery.searchName it set for t-shirts\n    *   Will return only products with t-shirts in their names\n    */\n    setSettingsQuery(query) {\n        this.filterQuery = query;\n    }\n    getSettingsQuery() {\n        return this.filterQuery;\n    }\n    /*\n    *   Get All products\n    *\n    *   Get a list of products with a maximum of 50 (see ITEMS_PER_PAGE) per page\n    *   Filter settings query will apply if available\n    */\n    async getProducts(products) {\n        if (this.filterQuery?.searchName) {\n            return this.searchProducts();\n        }\n        let response = await fetch(`${this.getStoreV1()}products?per_page=${this.ITEMS_PER_PAGE}`, {\n            headers: {\n                'X-WP-Nonce': this.getNounce()\n            }\n        });\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products?per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    /*\n    *   Get a single product by id\n    *\n    *   Get one product by products id\n    *   Filter settings will apply, ex: stock setting\n    */\n    async getProduct(id = 1) {\n        let response = await fetch(`${this.getStoreV1()}products/${id}?per_page=${this.ITEMS_PER_PAGE}`, {\n            headers: {\n                'X-WP-Nonce': this.getNounce()\n            }\n        });\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products/${id}?per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel([json])[0];\n    }\n    /*\n    *   Get products from one collection\n    *\n    *   Get products from a collection id\n    */\n    async getProductsFromCollection(id) {\n        let response = await fetch(`${this.getStoreV1()}products?category=${id}&per_page=${this.ITEMS_PER_PAGE}`, {\n            headers: {\n                'X-WP-Nonce': this.getNounce()\n            }\n        });\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products?category=${id}&per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    /*\n    *   Fetch next\n    *\n    *   Fetch next page of the previous request\n    *   Example if your last call has getProducts you can call fetchNext\n    *   to retrieve the next page of products, each call will return the next page\n    */\n    async fetchNext() {\n        if (!this.lastFetch) {\n            return undefined;\n        }\n        const param = this.lastFetch.config;\n        param.page = param.page + 1;\n        let response = await fetch(`${this.getStoreV1()}${this.lastFetch.resource}&page=${param.page}`, {\n            headers: {\n                'X-WP-Nonce': this.getNounce()\n            }\n        });\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch.config = param;\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    /*\n    *   SearchProducts\n    *\n    *   Private method helper to search products based on value search\n    */\n    async searchProducts() {\n        let response = await fetch(`${this.getStoreV1()}products?search=${this.filterQuery?.searchName}`, {\n            headers: {\n                'X-WP-Nonce': this.getNounce()\n            }\n        });\n        if (!response.ok) {\n            return undefined;\n        }\n        this.lastFetch = {\n            resource: `products?search=${this.filterQuery?.searchName}?per_page=${this.ITEMS_PER_PAGE}`,\n            config: {\n                page: 1\n            }\n        };\n        const json = await response.json();\n        return this.parseToModel(json);\n    }\n    parseToModel(models) {\n        let products = [];\n        // @ts-ignore\n        models.forEach(element => {\n            const parsedProduct = _ShopOnline_Adapters_ProductAdapter__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getInstance().parse(element);\n            if (parsedProduct !== undefined) {\n                products.push(parsedProduct);\n            }\n        });\n        return products;\n    }\n}\n\n\n//# sourceURL=webpack://napps.discountrules/./src/ShopOnline/Modules/Wordpress/WPProductService.ts?");
    877866
    878867/***/ }),
     
    896885
    897886"use strict";
    898 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (/* binding */ ShopOnlineBaseService)\n/* harmony export */ });\nclass ShopOnlineBaseService {\n    discountV1;\n    storeV1;\n    nounce;\n    constructor(homeUrl) {\n        this.discountV1 = `${homeUrl}napps-dr/v1/`;\n        this.storeV1 = `${homeUrl}wc/store/v1/`;\n        // @ts-ignore\n        this.nounce = wpApiSettings.nonce;\n    }\n    getDiscountV1() {\n        return this.discountV1;\n    }\n    getStoreV1() {\n        return this.storeV1;\n    }\n    getNounce() {\n        return this.nounce;\n    }\n}\n\n\n//# sourceURL=webpack://napps.discountrules/./src/ShopOnline/ShopOnlineBaseService.ts?");
     887eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (/* binding */ ShopOnlineBaseService)\n/* harmony export */ });\nclass ShopOnlineBaseService {\n    discountV1;\n    storeV1;\n    nounce;\n    constructor(homeUrl) {\n        this.discountV1 = `${homeUrl}napps-dr/v1/`;\n        this.storeV1 = `${homeUrl}napps-dr/v1/`;\n        // @ts-ignore\n        this.nounce = wpApiSettings.nonce;\n    }\n    getDiscountV1() {\n        return this.discountV1;\n    }\n    getStoreV1() {\n        return this.storeV1;\n    }\n    getNounce() {\n        return this.nounce;\n    }\n}\n\n\n//# sourceURL=webpack://napps.discountrules/./src/ShopOnline/ShopOnlineBaseService.ts?");
    899888
    900889/***/ }),
  • discount-rules-by-napps/trunk/plugin.php

    r2822201 r2823700  
    44 * Plugin URI: https://napps.io/
    55 * Description: Apply discounts to collections and products
    6  * Version:     1.0.1
     6 * Version:     1.0.2
    77 * Text Domain: napps
    88 * Author:      NAPPS
  • discount-rules-by-napps/trunk/readme.txt

    r2822201 r2823700  
    11=== Discount rules by NAPPS ===
    2 Contributors: napps
     2Contributors: nappssolutions
    33Tags: discounts, discount, discount rules, woocommerce, change prices, collections, products, napps
    44Requires at least: 4.7
     
    4343== Changelog ==
    4444
     45= 1.0.2 =
     46
     47* Fix - Minimum requirements
     48
    4549= 1.0.1 =
    4650
  • discount-rules-by-napps/trunk/vendor/composer/installed.php

    r2822201 r2823700  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '452197a9963e722c8adf5a839d130bebcf1c62a4',
     6        'reference' => '29ae6950e055f41f06eede3dc64b166fcbb1b1e7',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '452197a9963e722c8adf5a839d130bebcf1c62a4',
     16            'reference' => '29ae6950e055f41f06eede3dc64b166fcbb1b1e7',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.