{"version":3,"sources":["pages/WebProduct/index.tsx"],"names":["WebProduct","_ref","content","pageInfo","propsInfo","state","productPage","actions","setProductPage","setVariantModels","setSelectedVariant","setSelectedVariantAction","useStore","productStore","isMobile","useBreakpoint","selectedVariant","useState","loading","setLoading","useEffect","async","variants","products","getVariants","code","keys","Object","firstVariant","isSellable","window","browserHistory","replace","pathname","toRelativeLink","fetchData","sharedProps","key","concat","_jsxs","_Fragment","children","_jsx","PageSpinner","fetching","ProductDetails","ProductDetailsNew"],"mappings":"mHAAA,qGA8EeA,UA9DqBC,IAAuC,IAAtC,QAAEC,EAAO,SAAEC,EAAQ,UAAEC,GAAWH,EACnE,MACEI,OAAO,YAAEC,GACTC,SAAS,eACPC,EAAc,iBACdC,EACAC,mBAAoBC,IAEpBC,YAASC,KACPC,EAAWC,YAAc,OAExBC,EAAiBN,GAAsBO,sBACvCC,EAASC,GAAcF,oBAAS,GAEvCG,qBAAU,KACUC,WAChBF,GAAW,GAEX,MAAMG,QAAiBC,IAASC,YAAYtB,EAAQuB,MAC9CC,EAAOC,OAAOD,KAAKJ,GACnBM,EAAeN,EAASI,EAAK,IAE/BxB,EAAQ2B,aACVnB,EAAmBkB,SACbnB,EAAiBa,SACjBX,EAAyBiB,UAG3BpB,EAAe,CAAEN,UAASC,WAAUC,cAEtCF,EAAQ2B,aACVC,OAAyB,kBAAI,EACd,MAAXJ,EAAK,IACPK,IAAeC,QAAQ,CACrBC,SAAUC,YAAeR,EAAK,OAKpCP,GAAW,EAAM,EAGnBgB,EAAW,GAEV,CAACjC,GAAWA,EAAQuB,OAEvB,MAAMW,EAAc,CAClBC,IAAI,mBAADC,OAAqBpC,EAAQuB,MAChCT,kBACAV,eAGF,OACEiC,eAAAC,WAAA,CAAAC,SAAA,CACGvB,GAAWwB,cAACC,IAAW,CAACC,SAAU1B,IAClCZ,EAAYJ,UAAYY,GAAY4B,cAACG,IAAc,IAAKT,IACxD9B,EAAYJ,SAAWY,GACtB4B,cAACI,IAAiB,IAAKV,MAExB,C","file":"static/js/webProduct.1ec16e49.chunk.js","sourcesContent":["import { toRelativeLink } from \"@starrepublic/epi/cms/components/RelativeLink\"\nimport { ContentProps } from \"@starrepublic/epi/types/cms/props\"\nimport products from \"api/products\"\nimport { browserHistory } from \"common/Root\"\nimport PageSpinner from \"common/Spinners/PageSpinner\"\nimport useStore from \"global-hook-store\"\nimport useBreakpoint from \"hooks/useBreakpoint\"\nimport Variant from \"models/Variant\"\nimport ProductDetails from \"pages/WebVariant/ProductDetails\"\nimport ProductDetailsNew from \"pages/WebVariant/ProductDetailsNew\"\nimport { WebProductContent } from \"pages/WebVariant/types\"\nimport React, { useEffect, useState } from \"react\"\nimport productStore from \"stores/productStore\"\n\ntype Props = ContentProps\n\nconst WebProduct: React.FC = ({ content, pageInfo, propsInfo }) => {\n const {\n state: { productPage },\n actions: {\n setProductPage,\n setVariantModels,\n setSelectedVariant: setSelectedVariantAction\n }\n } = useStore(productStore)\n const isMobile = useBreakpoint(\"md\")\n\n const [selectedVariant, setSelectedVariant] = useState()\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n const fetchData = async () => {\n setLoading(true)\n\n const variants = await products.getVariants(content.code)\n const keys = Object.keys(variants)\n const firstVariant = variants[keys[0]]\n\n if (content.isSellable) {\n setSelectedVariant(firstVariant)\n await setVariantModels(variants)\n await setSelectedVariantAction(firstVariant)\n }\n\n await setProductPage({ content, pageInfo, propsInfo })\n\n if (content.isSellable) {\n window[\"ignoreApiRequest\"] = true\n if (keys[0] != null) {\n browserHistory.replace({\n pathname: toRelativeLink(keys[0])\n })\n }\n }\n\n setLoading(false)\n }\n\n fetchData()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [content && content.code])\n\n const sharedProps = {\n key: `product-details-${content.code}`,\n selectedVariant,\n productPage\n }\n\n return (\n <>\n {loading && }\n {productPage.content && !isMobile && }\n {productPage.content && isMobile && (\n \n )}\n \n )\n}\nexport default WebProduct\n"],"sourceRoot":""}