{ "version": 3, "sources": ["../../javascript/components/MarketContext.ts", "../../javascript/components/OutOfStock.tsx", "../../javascript/utilities/createNotificationRequest.ts"], "sourcesContent": ["import React from \"react\"\n\ntype Market = {\n countryIso: string\n locale: string\n stockLocationId: number\n}\n\nconst MarketContext = React.createContext({\n countryIso: \"\",\n locale: \"\",\n stockLocationId: 0\n})\n\nexport { MarketContext as default, Market as Market }\n", "import React, { useState, useEffect } from \"react\"\nimport ActionButton from \"./ActionButton\"\n\nimport MarketContext, { Market } from \"./MarketContext\"\nimport TranslationContext, { Translations } from \"./TranslationContext\"\n\nimport createNotificationRequest from \"../utilities/createNotificationRequest\"\n\ninterface OutOfStockProps {\n sku: string\n variantId: number\n}\n\nconst OutOfStock: React.FC = ({ sku, variantId }) => {\n const [email, setEmail] = useState(\"\")\n const [success, setSuccess] = useState(false)\n\n useEffect(() => {\n setSuccess(false)\n }, [variantId])\n\n const handleNotifyClick = async (\n countryIso: string,\n locale: string,\n stockLocationId: number\n ) => {\n if (!email) {\n /* TODO: Prompt user to input their email */\n return\n }\n\n const response = await createNotificationRequest({\n variantId,\n email,\n stockLocationId,\n countryIso,\n locale\n })\n if (response.status == 200) {\n setSuccess(true)\n }\n }\n\n return (\n \n {(market: Market) => (\n \n {(translations: Translations) => {\n let outOfStockNotify = translations.out_of_stock_notify.replace(\n \"$sku\",\n sku\n )\n let outOfStockSuccess = translations.out_of_stock_success.replace(\n \"$sku\",\n sku\n )\n return (\n
\n

\n \n {\n setEmail(e.target.value)\n }}\n />\n\n {\n handleNotifyClick(\n market.countryIso,\n market.locale,\n market.stockLocationId\n )\n }}\n />\n
\n \n \n )\n }}\n
\n )}\n
\n )\n}\n\nexport default OutOfStock\n", "const createNotificationRequest = ({\n variantId,\n stockLocationId,\n email,\n countryIso,\n locale\n}: {\n variantId: number\n email: string\n stockLocationId: number\n countryIso: string\n locale: string\n}) => {\n const spreeApiUrl = `/${countryIso}/${locale}/stock_notification_requests?`\n let queryParameters = [\n `quilt_stock_notification_request[variant_id]=${variantId.toString(10)}`,\n `quilt_stock_notification_request[stock_location_id]=${stockLocationId}`,\n `quilt_stock_notification_request[email]=${email}`,\n `quilt_stock_notification_request[locale]=${locale}`,\n `quilt_stock_notification_request[country_iso]=${countryIso}`\n ].join(\"&\")\n\n const csrfToken = document\n .querySelector(\"meta[name=csrf-token]\")\n ?.getAttribute(\"content\")\n\n return fetch(spreeApiUrl + queryParameters, {\n method: \"POST\",\n headers: {\n \"X-CSRF-Token\": csrfToken ?? \"\"\n }\n })\n}\n\nexport default createNotificationRequest\n"], "mappings": "2OAAA,IAAAA,EAAkB,SAQZC,EAAgB,EAAAC,QAAM,cAAsB,CAChD,WAAY,GACZ,OAAQ,GACR,gBAAiB,CACnB,CAAC,ECZD,IAAAC,EAA2C,SCA3C,IAAMC,EAA4B,CAAC,CACjC,UAAAC,EACA,gBAAAC,EACA,MAAAC,EACA,WAAAC,EACA,OAAAC,CACF,IAMM,CAZN,IAAAC,EAaE,IAAMC,EAAc,IAAIH,KAAcC,iCAClCG,EAAkB,CACpB,gDAAgDP,EAAU,SAAS,EAAE,IACrE,uDAAuDC,IACvD,2CAA2CC,IAC3C,4CAA4CE,IAC5C,iDAAiDD,GACnD,EAAE,KAAK,GAAG,EAEJK,GAAYH,EAAA,SACf,cAAc,uBAAuB,IADtB,YAAAA,EAEd,aAAa,WAEjB,OAAO,MAAMC,EAAcC,EAAiB,CAC1C,OAAQ,OACR,QAAS,CACP,eAAgBC,GAAA,KAAAA,EAAa,EAC/B,CACF,CAAC,CACH,EAEOC,EAAQV,EDrBf,IAAMW,EAAwC,CAAC,CAAE,IAAAC,EAAK,UAAAC,CAAU,IAAM,CACpE,GAAM,CAACC,EAAOC,CAAQ,KAAI,YAAiB,EAAE,EACvC,CAACC,EAASC,CAAU,KAAI,YAAkB,EAAK,KAErD,aAAU,IAAM,CACdA,EAAW,EAAK,CAClB,EAAG,CAACJ,CAAS,CAAC,EAEd,IAAMK,EAAoB,CACxBC,EACAC,EACAC,IACGC,EAAA,wBACH,GAAI,CAACR,EAEH,QAGe,MAAMS,EAA0B,CAC/C,UAAAV,EACA,MAAAC,EACA,gBAAAO,EACA,WAAAF,EACA,OAAAC,CACF,CAAC,GACY,QAAU,KACrBH,EAAW,EAAI,CAEnB,GAEA,OACE,EAAAO,QAAA,cAACC,EAAc,SAAd,KACGC,GACA,EAAAF,QAAA,cAACG,EAAmB,SAAnB,KACGC,GAA+B,CAC/B,IAAIC,EAAmBD,EAAa,oBAAoB,QACtD,OACAhB,CACF,EACIkB,EAAoBF,EAAa,qBAAqB,QACxD,OACAhB,CACF,EACA,OACE,EAAAY,QAAA,cAAC,OAAI,UAAU,gBACb,EAAAA,QAAA,cAAC,KACC,UAAW,sBACTR,EAAU,6BAA+B,KAE3C,wBAAyB,CAAE,OAAQa,CAAiB,EACrD,EACD,EAAAL,QAAA,cAAC,OACC,UAAW,4BACTR,EAAU,mCAAqC,MAGjD,EAAAQ,QAAA,cAAC,SACC,GAAG,qBACH,KAAK,QACL,YAAaI,EAAa,WAC1B,UAAU,0BACV,SAAWG,GAAM,CACfhB,EAASgB,EAAE,OAAO,KAAK,CACzB,EACF,EAEA,EAAAP,QAAA,cAACQ,EAAA,CACC,KAAMJ,EAAa,UACnB,eAAc,GACd,QAAS,IAAM,CACbV,EACEQ,EAAO,WACPA,EAAO,OACPA,EAAO,eACT,CACF,EACF,CACF,EACA,EAAAF,QAAA,cAAC,OACC,UAAW;AAAA;AAAA,sBAEPR,EAAU,GAAK;AAAA,oBAEnB,wBAAyB,CAAE,OAAQc,CAAkB,EACtD,CACH,CAEJ,CACF,CAEJ,CAEJ,EAEOG,EAAQtB", "names": ["import_react", "MarketContext", "React", "import_react", "createNotificationRequest", "variantId", "stockLocationId", "email", "countryIso", "locale", "_a", "spreeApiUrl", "queryParameters", "csrfToken", "createNotificationRequest_default", "OutOfStock", "sku", "variantId", "email", "setEmail", "success", "setSuccess", "handleNotifyClick", "countryIso", "locale", "stockLocationId", "__async", "createNotificationRequest_default", "React", "MarketContext", "market", "TranslationContext", "translations", "outOfStockNotify", "outOfStockSuccess", "e", "ActionButton_default", "OutOfStock_default"] }