{"version":3,"file":"ModalCart--eJIWHhr2.js","sources":["../../../../../node_modules/product-inventory-statuses/index.js","../../../../../utils/orderablestatuses.js","../../../../../components/webshop/ModalCart.vue"],"sourcesContent":["/**\n * \n * Util: A rendelések státuszának kalkulálására szolgáló függvény\n * \n *  params:\n *    - publicationdate: a kiadás dátuma (string vagy null)\n *    - inventories: egy tömb, ami az adott termék raktárkészletét mutatja\n * \n *  returns:\n *    - 10: \"In Stock\" és még akciós is a termék (ez nincs implementálva, csak lehetőségként van itt)\n *    - 20: \"In Stock\" (tehát van bolti készlet)\n *    - 30: \"Orderable\" (tehát nincs bolti készlet, de van gardners készlet)\n *    - 40: \"We accept pre-orders\" (tehát ha nincs készlet és ismert a kiadás dátuma és az később van, mint a mai nap)\n *    - 50: \"Out of stock\" (tehát nincs készlet, nincs gardnersnél és a publikáció dátuma korábbi vagy most)\n *    - 60: \"\" azaz a default érték (tehát nincs információ és nem elérhető)\n * \n *  Eredeti visszatérési értékek:\n *    - 1: \"In Stock\"\n *    - 2: \"Orderable\"\n *    - 3: \"Out of stock\"\n *    - 4: \"We accept pre-orders\"\n */\n\nexport function calculateProductStatus(publicationdate, inventories) {\n\n  // DB FIX: hibás string kezelés:\n  if (publicationdate === 'notset' || publicationdate === null) {\n    publicationdate = '1000-01-01';\n  }\n\n  // inventory darabszámok:\n  let shopc = 0; // bolti készlet\n  let gardnersc = 0; // gardners raktárkészlet\n\n  // inventory-k darabszámának számítása\n  for (const inventory of inventories) {\n    if (inventory.warehouseID === '6a7528da-5096-4d0e-b864-08539b66c9fa') {\n      shopc += inventory.inventoryAmount;\n    } else {\n      gardnersc += inventory.inventoryAmount;\n    }\n  }\n\n  // ha van a boltban, akkor \"In Stock\"\n  if (shopc > 0) {\n    // TODO: Ellenőrzés az akcióra, ha van, akkor visszaadjuk a 10-et.\n    // 10: \"In Stock\" + akciós (ez nincs implementálva, csak a lehetőség fennáll)\n    return 20; // 20: \"In Stock\" (eredeti: 1: \"In Stock\")\n  }\n\n  // ha nincs a boltban, de van a gardners-nél, akkor \"Orderable\"\n  if (shopc < 1 && gardnersc > 0) {\n    return 30; // 30: \"Orderable\" (eredeti: 2: \"Orderable\")\n  }\n\n  // ha nincs sehol készlet és ismeretlen a kiadás dátuma\n  if (\n    (publicationdate === '9999-12-31' || publicationdate === '1000-01-01') &&\n    shopc < 1 &&\n    gardnersc < 1\n  ) {\n    return 50; // 50: \"Out of stock\" (eredeti: 3: \"Out of stock\")\n  }\n\n  // ha nincs készlet és ismert a kiadás dátuma és később van, mint a mai nap\n  const pupdate = new Date(publicationdate);\n  const now = new Date();\n  if (!isNaN(pupdate.getTime())) {\n    if (shopc < 1 && gardnersc < 1 && pupdate > now) {\n      console.log('pupdate', pupdate);\n      console.log('now', now);\n      return 40; // 40: \"We accept pre-orders\" (eredeti: 4: \"We accept pre-orders\")\n    }\n  }\n\n  // ha nincs készlet és ismert a kiadás dátuma és korábban van, mint a mai nap\n  if (shopc < 1 && gardnersc < 1 && pupdate <= now) {\n    return 50; // 50: \"Out of stock\" (eredeti: 3: \"Out of stock\")\n  }\n\n  return 60; // 60: Alapértelmezett, nincs információ (eredeti: \"\")\n}\n","/**\n * \n * Util: Globalisan elerheto egyszeru function: a rendelhetőség kalkulációjához\n * \n *  params:\n *    - publicationdate: kiadás dátuma (0000-00-00)\n *    - inventories: egy tömb, ami az adott product raktárkészletét mutatja\n * pl:\n *      const status = calculateProductStatus('2024-10-15', [\n *        { warehouseID: '6a7528da-5096-4d0e-b864-08539b66c9fa', inventoryAmount: 10 },\n *        { warehouseID: 'other-warehouse-id', inventoryAmount: 5 }\n *       ]);\n * \n *  TODO: Fontos!\n *    Ezt a fgv-t sokszor meghívjuk, eleinte sok hibás értékkel, amíg be nem tölt a termék, \n *    de azt követően már a helyes értékeket adja vissza.\n *    Csinálhatnánk egy ellenőrzést erre vonatkozóan (ott, ahol meghívtuk)\n * \n*/\n\nimport { calculateProductStatus } from 'product-inventory-statuses';\n\nexport default function (publicationdate, inventories) {\n  // console.log('publicationdate', publicationdate);\n  // console.log('inventories', inventories);\n  return calculateProductStatus(publicationdate, inventories);\n}\n","<script setup>\n\n  /**\n   * \n   * Modal: kosár kezelése modal ablak\n   * \n   * \n  */\n\n  // nyelvi es routing beallitasok\n  const localePath = useLocalePath();\n  // const { locale } = useI18n();\n  // const route = useRoute();\n\n  // pinia stores\n  import { storeToRefs } from 'pinia';\n  import { useWebshopCartStore } from '@/store/webshopcart';\n  // import { useCurrencyStore } from '@/store/currency';\n  const webshopCartStore = useWebshopCartStore();\n\n  // props\n  // const { productid } = defineProps({\n  //   productid: { type: String, default: null },\n  // });\n\n  // computed\n  const { closeCartModal } = webshopCartStore; // all non-reactive stuff\n  const { getCartModal, cartmodalloading, cartlastaddedproduct } = storeToRefs(webshopCartStore) // have all reactive states\n  // let getCartmodal = computed(() => webshopCartStore.cartmodal); // ez nem az a modal\n  // let cartmodalloading = computed(() => webshopCartStore.cartmodalloading);\n  // let cartlastaddedproduct = computed(() => webshopCartStore.cartlastaddedproduct);\n\n  // get project's image storage (cloudfront) url:\n  const runtimeConfig = useRuntimeConfig();\n  const cloudFrontDomain = runtimeConfig.public.cloudfront.domain;\n  const productImagePath = '/public/images/coverstb/';\n  const size = '85';\n  const productImageUrl = ref(cloudFrontDomain + productImagePath + size)\n\n  const image = computed(() => {\n    // from S3 or cloudfront (see urlconfigs setup for details)\n    if (\n      cartlastaddedproduct.value &&\n      cartlastaddedproduct.value.mainImage &&\n      cartlastaddedproduct.value.mainImage !== 'notset'\n    ) {\n      return `${productImageUrl.value}/${cartlastaddedproduct.value.mainImage}`\n    } else {\n      return '/nopic.jpg'\n    }\n  });\n\n</script>\n\n<template>\n  <div>\n    <Transition>\n    <div\n      v-if=\"getCartModal === true\"\n      class=\"fixed top-0 left-0 w-screen h-screen bg-opacity-50 z-50 xs:px-2 sm:px-1\"\n      style=\"background-color: rgba(0, 0, 0, 0.5)\"\n    >\n      <div\n        class=\"xs:max-w-sm sm:max-w-md md:max-w-lg lg:max-w-2xl xl:max-w-3xl mt-52 mx-auto bg-page-dark p-2 rounded-lg shadow-lg\"\n      >\n        <!-- loader icon -->\n        <div v-show=\"cartmodalloading\" class=\"mx-auto text-center\">\n          <UiLoadSpinner v-show=\"cartmodalloading\" />\n        </div>\n        <!-- added item info -->\n        <div\n          v-if=\"!cartmodalloading && cartlastaddedproduct !== null\"\n          class=\"flex justify-between items-center\"\n        >\n          <!-- modal title -->\n          <WebshopModalCartTitle\n            v-if=\"\n              cartlastaddedproduct &&\n              cartlastaddedproduct.publicationDate &&\n              cartlastaddedproduct.inventories\n            \"\n            :inventories=\"cartlastaddedproduct.inventories.items\"\n            :publicationdate=\"cartlastaddedproduct.publicationDate\"\n          />\n          <div>\n            <!-- close modal -->\n            <button\n              type=\"button\"\n              class=\"w-8 h-8 p-2 bg-primary text-txt-light hover:shadow-sm items-center rounded-md font-sans font-light text-sm disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none\"\n              @click=\"closeCartModal()\"\n            >\n              <font-awesome-icon :icon=\"['fas', 'times']\" />\n            </button>\n          </div>\n        </div>\n        <div class=\"productdetails p-2 my-5\">\n          <div class=\"flex items-center justify-between\">\n            <div class=\"flex items-center\">\n              <div class=\"m-2\">\n                <img\n                  v-if=\"cartlastaddedproduct && cartlastaddedproduct.ean\"\n                  :src=\"image\"\n                  style=\"max-height: 125px; max-width: 85px\"\n                  class=\"bookimg\"\n                  :alt=\"cartlastaddedproduct.name || ''\"\n                  :title=\"cartlastaddedproduct.name || ''\"\n                  @error=\"$event.target.src = require('~/static/nopic.jpg')\"\n                />\n              </div>\n              <div class=\"m-2\">\n                <h3\n                  v-if=\"\n                    cartlastaddedproduct && cartlastaddedproduct.author\n                  \"\n                  class=\"text-xs\"\n                >\n                  <cite>{{ cartlastaddedproduct.author }}</cite>\n                </h3>\n                <h1\n                  v-if=\"cartlastaddedproduct && cartlastaddedproduct.name\"\n                  class=\"text-xl leading-tight text-txt-light\"\n                >\n                  {{ cartlastaddedproduct.name || '' }}\n                </h1>\n                <h2\n                  v-if=\"\n                    cartlastaddedproduct &&\n                    cartlastaddedproduct.subTitle &&\n                    cartlastaddedproduct.subTitle !== ''\n                  \"\n                  class=\"px-2\"\n                >\n                  {{ cartlastaddedproduct.subTitle || '' }}\n                </h2>\n                <div\n                  v-if=\"cartlastaddedproduct && cartlastaddedproduct.ean\"\n                  class=\"pt-3 font-sans font-light text-xs\"\n                >\n                  EAN:\n                  <span class=\"text-txt-light\">{{\n                    cartlastaddedproduct.ean || ''\n                  }}</span>\n                </div>\n              </div>\n            </div>\n            <div>\n              <!-- termék ára -->\n              <MoneyFormat\n                v-if=\"\n                  cartlastaddedproduct &&\n                  cartlastaddedproduct.price\n                \"\n                :icon=\"cartlastaddedproduct.salePercent > 0 ? 'bell' : 'tag'\"\n                :iconclass=\"\n                  cartlastaddedproduct.salePercent > 0 ? 'text-red-dark' : ''\n                \"\n                :price=\"cartlastaddedproduct.price\"\n                :currency=\"'HUF'\"\n                class=\"m-2 p-1\"\n              />\n            </div>\n          </div>\n          <WebshopCartStockAlert\n            v-if=\"\n              cartlastaddedproduct &&\n              cartlastaddedproduct.publicationDate &&\n              cartlastaddedproduct.inventories\n            \"\n            :inventories=\"cartlastaddedproduct.inventories.items\"\n            :publicationdate=\"cartlastaddedproduct.publicationDate\"\n          />\n        </div>\n        <!-- modal actions -->\n        <div class=\"flex justify-between items-center\">\n          <div>\n            <button\n              type=\"button\"\n              class=\"text-sm focus:outline-none\"\n              @click=\"closeCartModal()\"\n            >\n              <span class=\"pr-1\"\n                ><font-awesome-icon :icon=\"['fas', 'arrow-left']\" /></span\n              >{{ $t('Go to products') }}..\n            </button>\n          </div>\n          <div></div>\n          <div>\n            <!-- to the cart -->\n            <nuxt-link\n              :to=\"localePath('my-cart')\"\n              class=\"m-2 p-2 block bg-primary text-txt-light shadow-sm hover:shadow-lg items-center rounded-md font-sans font-light focus:outline-none\"\n              @click=\"closeCartModal()\"\n            >\n              {{ $t('Show my cart') }}\n              <font-awesome-icon :icon=\"['fa', 'arrow-circle-right']\" />\n            </nuxt-link>\n          </div>\n        </div>\n      </div>\n    </div>\n  </Transition>\n</div>\n</template>\n"],"names":["calculateProductStatus","publicationdate","inventories","shopc","gardnersc","inventory","pupdate","now","__unimport_orderablestatuses","productImagePath","size","localePath","useLocalePath","webshopCartStore","useWebshopCartStore","closeCartModal","getCartModal","cartmodalloading","cartlastaddedproduct","storeToRefs","cloudFrontDomain","useRuntimeConfig","productImageUrl","ref","image","computed"],"mappings":"6YAuBO,SAASA,EAAuBC,EAAiBC,EAAa,EAG/DD,IAAoB,UAAYA,IAAoB,QACtDA,EAAkB,cAIpB,IAAIE,EAAQ,EACRC,EAAY,EAGhB,UAAWC,KAAaH,EAClBG,EAAU,cAAgB,uCAC5BF,GAASE,EAAU,gBAEnBD,GAAaC,EAAU,gBAK3B,GAAIF,EAAQ,EAGV,MAAO,IAIT,GAAIA,EAAQ,GAAKC,EAAY,EAC3B,MAAO,IAIT,IACGH,IAAoB,cAAgBA,IAAoB,eACzDE,EAAQ,GACRC,EAAY,EAEZ,MAAO,IAIT,MAAME,EAAU,IAAI,KAAKL,CAAe,EAClCM,EAAM,IAAI,KAChB,MAAI,CAAC,MAAMD,EAAQ,QAAS,CAAA,GACtBH,EAAQ,GAAKC,EAAY,GAAKE,EAAUC,GAC1C,QAAQ,IAAI,UAAWD,CAAO,EAC9B,QAAQ,IAAI,MAAOC,CAAG,EACf,IAKPJ,EAAQ,GAAKC,EAAY,GAAKE,GAAWC,EACpC,GAGF,EACT,CC3De,SAAAC,EAAUP,EAAiBC,EAAa,CAGrD,OAAOF,EAAuBC,EAAiBC,CAAW,CAC5D,ynGCSQO,GAAmB,2BACnBC,GAAO,qCA1Bb,MAAMC,EAAaC,EAAe,EAQ5BC,EAAmBC,EAAqB,EAQxC,CAAE,eAAAC,CAAgB,EAAGF,EACrB,CAAE,aAAAG,EAAc,iBAAAC,EAAkB,qBAAAC,CAAoB,EAAKC,EAAYN,CAAgB,EAOvFO,EADgBC,EAAkB,EACD,OAAO,WAAW,OAGnDC,EAAkBC,EAAIH,EAAmBX,GAAmBC,EAAI,EAEhEc,EAAQC,EAAS,IAGnBP,EAAqB,OACrBA,EAAqB,MAAM,WAC3BA,EAAqB,MAAM,YAAc,SAElC,GAAGI,EAAgB,KAAK,IAAIJ,EAAqB,MAAM,SAAS,GAEhE,YAEV","x_google_ignoreList":[0]}