{"version":3,"sources":["webpack:///./Scripts/functions.js","webpack:///./Scripts/Components/Favorites/AddToFavouritesButton.js","webpack:///./Scripts/Services/Favourites.service.js","webpack:///./Scripts/Containers/AddToFavouritesButton.container.js"],"names":["formatZip","value","forceSpace","replace","substring","length","match","join","AddToFavouritesButton","addOrRemove","articleNumber","setList","list","setPrevCount","buttonClass","__litium","constants","isLoggedIn","className","onClick","e","then","resp","json","onMouseLeave","target","blur","width","height","viewBox","fill","stroke","strokeLinecap","strokeLinejoin","strokeWidth","d","post","AddToFavouritesButtonContainer","props","this","Component","connect","state","favourites","prevCount","isFavouritesPage","dispatch"],"mappings":"sIAAaA,EAAY,SAACC,GAA6B,IAAtBC,IAAa,UAAH,+CAOvC,OANAD,EAAQA,EAAME,QAAQ,MAAO,IAAIC,UAAU,EAAG,IAEpCC,QAAU,GAAKH,IACrBD,EAAQA,EAAMK,MAAM,WAAWC,KAAK,MAGjCN,I,yLCuCIO,G,OAzCe,SAAH,GAAoE,IAA9DC,EAAW,EAAXA,YAAaC,EAAa,EAAbA,cAAeC,EAAO,EAAPA,QAASC,EAAI,EAAJA,KAAMC,EAAY,EAAZA,aACpEC,EAAc,oBAGlB,GAFAA,GAAe,IAAAF,GAAI,KAAJA,EAAcF,GAAiB,aAAe,KAEvD,eAAgBK,SAASC,aAAeD,SAASC,UAAUC,WAC7D,OAAO,KAqBX,OACI,oCACI,4BACIC,UAAWJ,EACXK,QAAS,SAACC,GAflBX,EAAYC,GACPW,MAAK,SAAAC,GAAI,OAAIA,EAAKC,UAClBF,MAAK,SAAAE,GAIFV,EAAaD,EAAKP,QAClBM,EAAQY,OASRC,aAAc,SAACJ,GAAC,OAAKA,EAAEK,OAAOC,SAE9B,yBAAKC,MAAM,MAAMC,OAAO,MAAMC,QAAQ,YAAYC,KAAK,OAAOC,OAAO,eAAeC,cAAc,QAAQC,eAAe,QAAQC,YAAY,KACzI,0BAAMC,EAAE,kJ,qXCtC5B,60MACO,IAAM1B,EAAW,+BAAG,WAAOC,GAAa,iFAC9B0B,YAAK,mCAAD,OAAoC1B,IAAgB,mFACxE,gBAFuB,sC,qXCEqC,IAEvD2B,EAA8B,gCAChC,WAAYC,GAAO,+BACTA,GAOT,OANA,2BAED,WACI,OACI,kBAAC,EAA0BC,KAAKD,WAEvC,EAT+B,CAASE,aA4B9BC,uBAhBS,SAACC,GACrB,MAAO,CACH9B,KAAM8B,EAAMC,WAAW/B,KACvBgC,UAAWF,EAAMC,WAAWC,UAC5BC,iBAAkBH,EAAMC,WAAWE,qBAIhB,SAAAC,GACvB,MAAO,CACHrC,YAAa,SAACC,GAAa,OAAKD,EAAYC,IAC5CC,QAAS,SAACD,GAAa,OAAKoC,EAASnC,YAAQD,KAC7CG,aAAc,SAAC+B,GAAS,OAAKE,EAASjC,YAAa+B,QAI5CH,CAA6CJ","file":"7.82a17683d6fee4c752df.js","sourcesContent":["export const formatZip = (value, forceSpace = true) => {\r\n value = value.replace(/\\D/g, '').substring(0, 5);\r\n\r\n if (value.length >= 4 && forceSpace) {\r\n value = value.match(/.{1,3}/g).join(' ');\r\n }\r\n\r\n return value;\r\n}\r\n\r\nexport const iOS = () => {\r\n return [\r\n 'iPad Simulator',\r\n 'iPhone Simulator',\r\n 'iPod Simulator',\r\n 'iPad',\r\n 'iPhone',\r\n 'iPod'\r\n ].includes(navigator.platform)\r\n // iPad on iOS 13 detection\r\n || (navigator.userAgent.includes(\"Mac\") && \"ontouchend\" in document);\r\n}\r\n","/* global __litium */\r\n\r\nimport React from 'react';\r\nimport {iOS} from \"../../functions\";\r\n\r\nconst AddToFavouritesButton = ({ addOrRemove, articleNumber, setList, list, setPrevCount }) => {\r\n let buttonClass = 'c-favourites__add';\r\n buttonClass += list.includes(articleNumber) ? ' is-active' : '';\r\n\r\n if (!('isLoggedIn' in __litium.constants) || !__litium.constants.isLoggedIn) {\r\n return null;\r\n }\r\n\r\n /**\r\n * Add or remove favorite to list\r\n *\r\n * @param {Event} e\r\n * @returns {Promise}\r\n */\r\n const onAddToFavorites = (e) => {\r\n addOrRemove(articleNumber)\r\n .then(resp => resp.json())\r\n .then(json => {\r\n /**\r\n * Update state with fresh list from backend.\r\n */\r\n setPrevCount(list.length);\r\n setList(json);\r\n });\r\n }\r\n\r\n return (\r\n <>\r\n onAddToFavorites(e)}\r\n onMouseLeave={(e) => e.target.blur()}\r\n >\r\n \r\n \r\n \r\n \r\n \r\n )\r\n}\r\n\r\nexport default AddToFavouritesButton;\r\n","import { post } from \"./http\";\r\n\r\nexport const addOrRemove = async (articleNumber) => {\r\n return await post(`/api/UserFavourites/AddOrRemove/${articleNumber}`);\r\n};\r\n","import React, { Component } from 'react';\r\nimport { connect } from 'react-redux';\r\nimport AddToFavouritesButton from '../Components/Favorites/AddToFavouritesButton';\r\nimport { setPrevCount, setList } from '../Actions/Favourites.action';\r\nimport { addOrRemove } from '../Services/Favourites.service';\r\n\r\nclass AddToFavouritesButtonContainer extends Component {\r\n constructor(props) {\r\n super(props);\r\n }\r\n\r\n render() {\r\n return (\r\n \r\n );\r\n }\r\n}\r\n\r\nconst mapStateToProps = (state) => {\r\n return {\r\n list: state.favourites.list,\r\n prevCount: state.favourites.prevCount,\r\n isFavouritesPage: state.favourites.isFavouritesPage,\r\n }\r\n}\r\n\r\nconst mapDispatchToProps = dispatch => {\r\n return {\r\n addOrRemove: (articleNumber) => addOrRemove(articleNumber),\r\n setList: (articleNumber) => dispatch(setList(articleNumber)),\r\n setPrevCount: (prevCount) => dispatch(setPrevCount(prevCount))\r\n }\r\n}\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(AddToFavouritesButtonContainer);\r\n"],"sourceRoot":""}