{"version":3,"file":"useProductPageExpectedDeliveryQuickView.dy6nn9l0.js","sources":["../../../wwwdev/scripts/autogen/translation-keys/trans-website-progressivediscount.ts","../../../wwwdev/esm/components/pages/PDP/shared/productStore.ts","../../../wwwdev/esm/components/expecteddelivery/shared/hooks/useProductPageExpectedDeliveryQuickView.ts"],"sourcesContent":["/* eslint-disable */\r\n/// This file is auto generated - do not edit manually\r\nexport const UrlText = 'Website.ProgressiveDiscount.UrlText';\r\n","import type { ProductPageViewModel, ProductSubscriptionInfoViewModel } from 'autogen/swagger/all';\r\nimport { createContext, useContext } from 'react';\r\nimport { createStore, useStore } from 'zustand';\r\n\r\ntype productStoreProps = {\r\n productId: ProductPageViewModel['productInformation']['productId'];\r\n isSubscription: ProductSubscriptionInfoViewModel['isSubscriptionSelected'];\r\n};\r\ntype productState = productStoreProps & {\r\n setIsSubscription: (x: productStoreProps['isSubscription']) => void;\r\n};\r\n\r\nexport type productStore = ReturnType;\r\n\r\nexport const createProductStore = (initProps: productStoreProps) => {\r\n return createStore()((set) => ({\r\n ...initProps,\r\n setIsSubscription: (isSubscription) => set((state) => ({ ...state, isSubscription }))\r\n }));\r\n};\r\n\r\nexport const ProductContext = createContext(null);\r\n\r\nexport function useProductStore() {\r\n const store = useContext(ProductContext);\r\n if (!store) throw new Error('Missing ProductContext.Provider in the tree');\r\n return useStore(store);\r\n}\r\n","import useExpectedDeliveryQuickView, {\r\n type ExpectedDeliveryParams\r\n} from 'components/expecteddelivery/shared/hooks/useExpectedDeliveryQuickView';\r\nimport { useGetExpectedDeliveryInformationForProductPageQuery } from 'autogen/swagger/all/hooks';\r\nimport { useEffect } from 'react';\r\nimport { useProductStore } from 'components/pages/PDP/shared/productStore';\r\n\r\nexport function useProductPageExpectedDeliveryQuickView() {\r\n const { productId, isSubscription } = useProductStore();\r\n const [{ isOpen, params: initialParams }, toggle] = useExpectedDeliveryQuickView();\r\n const { data: summaryModel } = useGetExpectedDeliveryInformationForProductPageQuery(\r\n { productId, isSubscription },\r\n {\r\n enabled: isOpen && initialParams?.type === 'productPage' && initialParams.productId === productId,\r\n refetchOnWindowFocus: false\r\n }\r\n );\r\n\r\n const params: ExpectedDeliveryParams = {\r\n type: 'productPage',\r\n productId,\r\n isSubscription,\r\n zipCode: summaryModel?.zipCodeWithSource.zipCode\r\n };\r\n\r\n useEffect(() => {\r\n toggle({\r\n isOpen,\r\n params\r\n });\r\n }, [params.zipCode]);\r\n\r\n return (isOpen: boolean) =>\r\n toggle({\r\n isOpen,\r\n params\r\n });\r\n}\r\n"],"names":["UrlText","createProductStore","initProps","createStore","set","setIsSubscription","state","isSubscription","ProductContext","createContext","useProductStore","store","useContext","Error","useStore","useProductPageExpectedDeliveryQuickView","productId","isOpen","params","initialParams","toggle","useExpectedDeliveryQuickView","data","summaryModel","useGetExpectedDeliveryInformationForProductPageQuery","enabled","type","refetchOnWindowFocus","zipCode","zipCodeWithSource","useEffect"],"mappings":"2GAEO,MAAMA,EAAU,sCCYVC,EAAsBC,GACxBC,EAAAA,EAAsCC,IAAA,CACzC,GAAGF,EACHG,kBAAuCD,GAAAA,EAAgBE,IAAA,CAAE,GAAGA,EAAOC,eAAAA,CAAAA,EAAiB,CAAA,EACtF,EAGOC,EAAiBC,gBAAmC,IAAI,EAE9D,SAASC,GAAkB,CACxBC,MAAAA,EAAQC,aAAWJ,CAAc,EACvC,GAAI,CAACG,EAAa,MAAA,IAAIE,MAAM,6CAA6C,EACzE,OAAOC,EAASH,CAAK,CACzB,CCpBO,SAASI,GAA0C,CAChD,KAAA,CAAEC,UAAAA,EAAWT,eAAAA,GAAmBG,EAAgB,EAChD,CAAC,CAAEO,OAAAA,EAAQC,OAAQC,CAAAA,EAAiBC,CAAM,EAAIC,EAA6B,EAC3E,CAAEC,KAAMC,GAAiBC,EAC3B,CAAER,UAAAA,EAAWT,eAAAA,CAAAA,EACb,CACIkB,QAASR,IAAUE,GAAAA,YAAAA,EAAeO,QAAS,eAAiBP,EAAcH,YAAcA,EACxFW,qBAAsB,EAAA,CAE9B,EAEMT,EAAiC,CACnCQ,KAAM,cACNV,UAAAA,EACAT,eAAAA,EACAqB,QAASL,GAAAA,YAAAA,EAAcM,kBAAkBD,OAC7C,EAEAE,OAAAA,EAAAA,UAAU,IAAM,CACLV,EAAA,CACHH,OAAAA,EACAC,OAAAA,CAAAA,CACH,CAAA,EACF,CAACA,EAAOU,OAAO,CAAC,EAEXX,GACJG,EAAO,CACHH,OAAAA,EACAC,OAAAA,CAAAA,CACH,CACT"}