{"version":3,"sources":["webpack:///./Scripts/Jicon/Components/Modal.js","webpack:///./Scripts/Jicon/Components/ModalSelectShop.js"],"names":["links","defaultStore","stores","find","x","isDefaultStore","isSelectedStore","isSelected","choosenStore","showModal","setShowModal","useState","currentShop","setCurrentShop","handleOpenModal","handleCloseModal","pdpRef","useRef","pinRef","useEffect","current","document","querySelector","addEventListener","removeEventListener","className","onClick","src","logoUrl","translate","map","index","key","storeId","name","address","todayOpenHours","type","disabled","e","async","put","then","res","status","window","location","reload","catch","err","console","log","handleSelectedShop","href","contentLinks","useSelector","state","selectStoreModal"],"mappings":"mJAKA,MA2HA,EA3Hc,EAAEA,QAAQ,OACtB,IAAIC,EAAeD,EAAME,OAAOC,MAAKC,GAAKA,EAAEC,iBACxCC,EAAkBN,EAAME,OAAOC,MAAKC,GAAKA,EAAEG,aAC3CC,EAAeP,GAA8BD,EAAME,OAAO,GAC9DM,EAAeF,GAAoCE,EAEnD,MAAOC,EAAWC,IAAgBC,eAAS,IACpCC,EAAaC,IAAkBF,cAASH,GAEzCM,EAAkB,KACtBJ,GAAa,EAAK,EAGdK,EAAmB,KACvBL,GAAa,EAAM,EAcfM,GAASC,YAAO,MAChBC,GAASD,YAAO,MAkBtB,OAjBAE,gBAAU,KACNH,EAAOI,QAAUC,SAASC,cAAc,cACxCJ,EAAOE,QAAUC,SAASC,cAAc,uBAEpCN,EAAOI,SACPJ,EAAOI,QAAQG,iBAAiB,QAAST,GAE1CI,EAAOE,SACRF,EAAOE,QAAQG,iBAAiB,QAAST,GAEpC,KACLE,EAAOI,QAAQI,oBAAoB,QAASV,GAC5CI,EAAOE,QAAQI,oBAAoB,QAASV,EAAgB,IAG7D,IAGH,gCACGL,GACC,uBAAKgB,UAAU,sBACb,uBACEA,UAAU,6BACVC,QAASX,IAEX,uBAAKU,UAAU,2BACb,uBAAKA,UAAU,iCACb,uBAAKA,UAAU,6BACb,uBAAKE,IAAK3B,EAAM4B,UAChB,2BAAKC,OAAU,wCAEjB,sBAAIJ,UAAU,4BACXzB,EAAME,OAAO4B,KAAI,CAAC1B,EAAG2B,IAElB,sBACEC,IAAKD,EACLN,WACEb,EAAYqB,SAAW7B,EAAE6B,QAAU,SAAW,IADpC,8BAIZ,uBAAKR,UAAU,oCACb,uBAAKA,UAAU,iFACb,sBAAIA,UAAU,wEACXrB,EAAE8B,MAEL,wBAAMT,UAAU,2EACbI,OAAU,6BAA4B,IAAGzB,EAAE+B,SAE9C,wBAAMV,UAAU,6EACbI,OAAU,gCAAiC,IAC3CzB,EAAEgC,iBAGP,uBAAKX,UAAU,kFACb,uBAAKA,UAAU,sCACZrB,EAAEG,WACH,0BAAQ8B,KAAK,SACXC,UAAQ,IAEPT,OAAU,sCAGX,0BAAQQ,KAAK,SACbX,QAAUa,GA5EXC,WACzB3B,EAAeT,IAEfqC,QAAI,0BAA0B,CAACR,QAAQ7B,EAAE6B,UACtCS,MAAMC,IACa,MAAfA,EAAIC,QACLC,OAAOC,SAASC,QAAO,EAAM,IAEhCC,OAAOC,GAAQC,QAAQC,IAAIF,IAAK,EAoEOG,CAAmBhD,KAElCyB,OAAU,4CAW7B,wBACEJ,UAAU,2DACVC,QAASX,MAKjB,uBAAKU,UAAU,oCACb,wBAAMA,UAAU,iBAChB,0BACKI,OAAU,+BAA8B,KAAG,qBAAGwB,KAAK,IAAI3B,QAASZ,GAAgB,IAAGF,EAAYsB,KAAI,MAAIL,OAAU,gCAA+B,IAAGjB,EAAYwB,kBAGrK,E,cCvHP,MAUA,EAVwB,KACpB,MAAMkB,GAAeC,SAAaC,GAAUA,IAC9C,OACE,gCACE,gBAAC,EAAK,CAACxD,MAAOsD,EAAaG,mBAC1B,C","file":"563.0da12e4b158ee0f39ad6.js","sourcesContent":["import React, { useState } from 'react';\r\nimport { useEffect, useRef } from 'react';\r\nimport { translate } from '../Services/translation';\r\nimport { get, post, put, remove as httpRemove } from '../Services/http';\r\n\r\nconst Modal = ({links = []}) => {\r\n  let defaultStore = links.stores.find(x => x.isDefaultStore)\r\n  let isSelectedStore = links.stores.find(x => x.isSelected)\r\n  let choosenStore = defaultStore ? defaultStore : links.stores[0];\r\n  choosenStore = isSelectedStore ? isSelectedStore : choosenStore;\r\n\r\n  const [showModal, setShowModal] = useState(false);\r\n  const [currentShop, setCurrentShop] = useState(choosenStore);\r\n\r\n  const handleOpenModal = () => {\r\n    setShowModal(true);\r\n  };\r\n\r\n  const handleCloseModal = () => {\r\n    setShowModal(false);\r\n  };\r\n\r\n  const handleSelectedShop = async (x) => {\r\n    setCurrentShop(x);\r\n\r\n    put(\"/api/stores/selectStore\",{storeId:x.storeId})\r\n      .then((res) => {\r\n        if(res.status === 200)\r\n          window.location.reload(false);\r\n        })\r\n      .catch((err) => console.log(err));\r\n  };\r\n\r\n  const pdpRef = useRef(null);\r\n  const pinRef = useRef(null);\r\n  useEffect(() => {\r\n      pdpRef.current = document.querySelector(\".your-shop\");\r\n      pinRef.current = document.querySelector(\".pinIcon-open-modal\")\r\n\r\n      if (pdpRef.current) {\r\n          pdpRef.current.addEventListener('click', handleOpenModal)\r\n      }\r\n      if(pinRef.current) {\r\n        pinRef.current.addEventListener('click', handleOpenModal)\r\n      }\r\n      return () => {\r\n        pdpRef.current.removeEventListener('click', handleOpenModal)\r\n        pinRef.current.removeEventListener('click', handleOpenModal)\r\n      }\r\n\r\n    }, []);\r\n\r\n  return (\r\n    <>\r\n      {showModal && (\r\n        <div className=\"select-store-modal\">\r\n          <div\r\n            className=\"select-store-modal__shadow\"\r\n            onClick={handleCloseModal}\r\n          ></div>\r\n          <div className=\"select-store-modal__box\">\r\n            <div className=\"select-store-modal__inner-box\">\r\n              <div className=\"select-store-modal__title\">\r\n                <img src={links.logoUrl}></img>\r\n                <h2>{translate('code.select.store.select.your.shop')}</h2>\r\n              </div>\r\n              <ul className=\"select-store-modal__list\">\r\n                {links.stores.map((x, index) => {\r\n                  return (\r\n                    <li\r\n                      key={index}\r\n                      className={`${\r\n                        currentShop.storeId == x.storeId ? 'active' : ''\r\n                      } select-store-modal__item `}\r\n                    >\r\n                      <div className=\"select-store-modal__item-content\">\r\n                        <div className=\"select-store-modal__item--container select-store-modal__item--container--left\">\r\n                          <h4 className=\"select-store-modal__each-store select-store-modal__each-store--title\">\r\n                            {x.name}\r\n                          </h4>\r\n                          <span className=\"select-store-modal__each-store select-store-modal__each-store--address\">\r\n                            {translate('code.select.store.address')} {x.address}\r\n                          </span>\r\n                          <span className=\"select-store-modal__each-store select-store-modal__each-store--openhours\">\r\n                            {translate('code.select.store.open.hours')}{' '}\r\n                            {x.todayOpenHours}\r\n                          </span>\r\n                        </div>\r\n                        <div className=\"select-store-modal__item--container select-store-modal__item--container--right\">\r\n                          <div className=\"select-store-modal__button-wrapper\">\r\n                            {x.isSelected ? (\r\n                            <button type='button'\r\n                              disabled\r\n                            >\r\n                              {translate('code.select.store.selected.button')}\r\n                            </button>\r\n                            ):(\r\n                              <button type='button'\r\n                              onClick={(e) => handleSelectedShop(x)}\r\n                            >\r\n                              {translate('code.select.store.select.button')}\r\n                            </button>\r\n                            )}\r\n                          </div>\r\n                        </div>\r\n                      </div>\r\n                    </li>\r\n                  );\r\n                })}\r\n              </ul>\r\n            </div>\r\n            <span\r\n              className=\"select-store-modal__icon select-store-modal__icon--close\"\r\n              onClick={handleCloseModal}\r\n            ></span>\r\n          </div>\r\n        </div>\r\n      )}\r\n      <div className=\"select-store-modal__open-desktop\">\r\n        <span className=\"header-house\"></span>\r\n        <p>\r\n            {translate('code.select.store.your.shop')}: <a href=\"#\" onClick={handleOpenModal}> {currentShop.name}, {translate('code.select.store.open.hours')} {currentShop.todayOpenHours}</a>\r\n        </p>\r\n      </div>\r\n    </>\r\n  );\r\n};\r\n\r\nexport default Modal;","import React, { useState } from 'react';\r\nimport Modal from './Modal';\r\nimport { useSelector } from 'react-redux';\r\n\r\n\r\nconst ModalSelectShop = () => {\r\n    const contentLinks = useSelector((state) => state);\r\n  return (\r\n    <>   \r\n      <Modal links={contentLinks.selectStoreModal} />\r\n    </>\r\n\r\n  );\r\n};\r\n\r\nexport default ModalSelectShop;"],"sourceRoot":""}