hemfixarna-web-components 1.8.13 → 1.8.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@ const patchBrowser = () => {
20
20
  };
21
21
 
22
22
  patchBrowser().then(options => {
23
- return index.bootstrapLazy([["hemfixarna-address_15.cjs",[[1,"hemfixarna-demo",{"selectedSlug":[32],"selectedID":[32],"tooltipText":[32],"tree":[32],"customer":[32],"widgetStyle":[32],"buttonBg":[32],"buttonColor":[32],"partner":[32],"colorAccessibility":[32],"loggedIn":[32],"loginError":[32]}],[1,"hemfixarna-component",{"id":[1],"slug":[1],"business":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"],"modal":[32],"showModal":[32],"product":[32],"proppedProduct":[32],"loginSourceError":[32]},[[0,"click","handleClick"]]],[0,"hemfixarna-cart"],[0,"hemfixarna-order"],[0,"hemfixarna-product",{"amount":[32],"hideDescription":[32]}],[0,"hemfixarna-start",{"tree":[16],"slug":[1]}],[0,"hemfixarna-breadcrumbs",{"closeModal":[16]}],[0,"hemfixarna-checkout",{"date":[32],"dateError":[32],"generalError":[32],"loading":[32],"enteredPin":[32],"selectedSubSource":[32],"partnerOrderId":[32],"sellerID":[32],"RefferalID":[32]}],[0,"hemfixarna-contact",{"vertical":[4]}],[0,"hemfixarna-invoice",{"formError":[32],"displayImages":[32],"formImages":[32],"formState":[32]}],[0,"hemfixarna-address",{"street":[32],"streetError":[32],"zip":[32],"zipError":[32],"town":[32],"townError":[32]}],[0,"hemfixarna-getuser",{"email":[32],"emailError":[32],"phone":[32],"phoneError":[32],"ssn":[32],"ssnError":[32]}],[0,"hemfixarna-orderrows",{"cart":[4]}],[0,"hemfixarna-box",{"post":[16],"category":[16],"icon":[1],"postTitle":[1,"post-title"]}],[0,"hemfixarna-info"]]],["hemfixarna-byggmax.cjs",[[1,"hemfixarna-byggmax",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"],"slug":[1]}]]],["hemfixarna-doro.cjs",[[1,"hemfixarna-doro",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-elfa.cjs",[[1,"hemfixarna-elfa",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-fargvaruhuset.cjs",[[1,"hemfixarna-fargvaruhuset",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-flyttsmart.cjs",[[1,"hemfixarna-flyttsmart",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-forebygg.cjs",[[1,"hemfixarna-forebygg",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-hornbach.cjs",[[1,"hemfixarna-hornbach",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-kbygg.cjs",[[1,"hemfixarna-kbygg",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-klint.cjs",[[1,"hemfixarna-klint",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-kund.cjs",[[1,"hemfixarna-kund",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-norrgavel.cjs",[[1,"hemfixarna-norrgavel",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-power.cjs",[[1,"hemfixarna-power",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-skanska.cjs",[[1,"hemfixarna-skanska",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-sparfonster.cjs",[[1,"hemfixarna-sparfonster",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-string-furniture.cjs",[[1,"hemfixarna-string-furniture",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-superfront.cjs",[[1,"hemfixarna-superfront",{"id":[1],"loadFromQuery":[1,"load-from-query"],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-tesla.cjs",[[1,"hemfixarna-tesla",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-traningspartner.cjs",[[1,"hemfixarna-traningspartner",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-zaptec.cjs",[[1,"hemfixarna-zaptec",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-category.cjs",[[0,"hemfixarna-category"]]],["hemfixarna-service.cjs",[[0,"hemfixarna-service"]]]], options);
23
+ return index.bootstrapLazy([["hemfixarna-address_15.cjs",[[1,"hemfixarna-demo",{"selectedSlug":[32],"selectedID":[32],"tooltipText":[32],"tree":[32],"customer":[32],"widgetStyle":[32],"buttonBg":[32],"buttonColor":[32],"partner":[32],"colorAccessibility":[32],"loggedIn":[32],"loginError":[32]}],[1,"hemfixarna-component",{"id":[1],"slug":[1],"business":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"],"modal":[32],"showModal":[32],"product":[32],"proppedProduct":[32],"loginSourceError":[32]},[[0,"click","handleClick"]]],[0,"hemfixarna-cart"],[0,"hemfixarna-order"],[0,"hemfixarna-product",{"amount":[32],"hideDescription":[32]}],[0,"hemfixarna-start",{"tree":[16],"slug":[1]}],[0,"hemfixarna-breadcrumbs",{"closeModal":[16]}],[0,"hemfixarna-checkout",{"date":[32],"dateError":[32],"generalError":[32],"loading":[32],"enteredPin":[32],"selectedSubSource":[32],"partnerOrderId":[32],"sellerID":[32],"RefferalID":[32],"termsChecked":[32]}],[0,"hemfixarna-contact",{"vertical":[4]}],[0,"hemfixarna-invoice",{"formError":[32],"displayImages":[32],"formImages":[32],"formState":[32]}],[0,"hemfixarna-address",{"street":[32],"streetError":[32],"zip":[32],"zipError":[32],"town":[32],"townError":[32]}],[0,"hemfixarna-getuser",{"email":[32],"emailError":[32],"phone":[32],"phoneError":[32],"ssn":[32],"ssnError":[32]}],[0,"hemfixarna-orderrows",{"cart":[4]}],[0,"hemfixarna-box",{"post":[16],"category":[16],"icon":[1],"postTitle":[1,"post-title"]}],[0,"hemfixarna-info"]]],["hemfixarna-byggmax.cjs",[[1,"hemfixarna-byggmax",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"],"slug":[1]}]]],["hemfixarna-doro.cjs",[[1,"hemfixarna-doro",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-elfa.cjs",[[1,"hemfixarna-elfa",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-fargvaruhuset.cjs",[[1,"hemfixarna-fargvaruhuset",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-flyttsmart.cjs",[[1,"hemfixarna-flyttsmart",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-forebygg.cjs",[[1,"hemfixarna-forebygg",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-hornbach.cjs",[[1,"hemfixarna-hornbach",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-kbygg.cjs",[[1,"hemfixarna-kbygg",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-klint.cjs",[[1,"hemfixarna-klint",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-kund.cjs",[[1,"hemfixarna-kund",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-norrgavel.cjs",[[1,"hemfixarna-norrgavel",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-power.cjs",[[1,"hemfixarna-power",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-skanska.cjs",[[1,"hemfixarna-skanska",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-sparfonster.cjs",[[1,"hemfixarna-sparfonster",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-string-furniture.cjs",[[1,"hemfixarna-string-furniture",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-superfront.cjs",[[1,"hemfixarna-superfront",{"id":[1],"loadFromQuery":[1,"load-from-query"],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-tesla.cjs",[[1,"hemfixarna-tesla",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-traningspartner.cjs",[[1,"hemfixarna-traningspartner",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-zaptec.cjs",[[1,"hemfixarna-zaptec",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-category.cjs",[[0,"hemfixarna-category"]]],["hemfixarna-service.cjs",[[0,"hemfixarna-service"]]]], options);
24
24
  });
25
25
 
26
26
  exports.setNonce = index.setNonce;
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["hemfixarna-address_15.cjs",[[1,"hemfixarna-demo",{"selectedSlug":[32],"selectedID":[32],"tooltipText":[32],"tree":[32],"customer":[32],"widgetStyle":[32],"buttonBg":[32],"buttonColor":[32],"partner":[32],"colorAccessibility":[32],"loggedIn":[32],"loginError":[32]}],[1,"hemfixarna-component",{"id":[1],"slug":[1],"business":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"],"modal":[32],"showModal":[32],"product":[32],"proppedProduct":[32],"loginSourceError":[32]},[[0,"click","handleClick"]]],[0,"hemfixarna-cart"],[0,"hemfixarna-order"],[0,"hemfixarna-product",{"amount":[32],"hideDescription":[32]}],[0,"hemfixarna-start",{"tree":[16],"slug":[1]}],[0,"hemfixarna-breadcrumbs",{"closeModal":[16]}],[0,"hemfixarna-checkout",{"date":[32],"dateError":[32],"generalError":[32],"loading":[32],"enteredPin":[32],"selectedSubSource":[32],"partnerOrderId":[32],"sellerID":[32],"RefferalID":[32]}],[0,"hemfixarna-contact",{"vertical":[4]}],[0,"hemfixarna-invoice",{"formError":[32],"displayImages":[32],"formImages":[32],"formState":[32]}],[0,"hemfixarna-address",{"street":[32],"streetError":[32],"zip":[32],"zipError":[32],"town":[32],"townError":[32]}],[0,"hemfixarna-getuser",{"email":[32],"emailError":[32],"phone":[32],"phoneError":[32],"ssn":[32],"ssnError":[32]}],[0,"hemfixarna-orderrows",{"cart":[4]}],[0,"hemfixarna-box",{"post":[16],"category":[16],"icon":[1],"postTitle":[1,"post-title"]}],[0,"hemfixarna-info"]]],["hemfixarna-byggmax.cjs",[[1,"hemfixarna-byggmax",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"],"slug":[1]}]]],["hemfixarna-doro.cjs",[[1,"hemfixarna-doro",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-elfa.cjs",[[1,"hemfixarna-elfa",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-fargvaruhuset.cjs",[[1,"hemfixarna-fargvaruhuset",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-flyttsmart.cjs",[[1,"hemfixarna-flyttsmart",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-forebygg.cjs",[[1,"hemfixarna-forebygg",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-hornbach.cjs",[[1,"hemfixarna-hornbach",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-kbygg.cjs",[[1,"hemfixarna-kbygg",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-klint.cjs",[[1,"hemfixarna-klint",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-kund.cjs",[[1,"hemfixarna-kund",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-norrgavel.cjs",[[1,"hemfixarna-norrgavel",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-power.cjs",[[1,"hemfixarna-power",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-skanska.cjs",[[1,"hemfixarna-skanska",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-sparfonster.cjs",[[1,"hemfixarna-sparfonster",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-string-furniture.cjs",[[1,"hemfixarna-string-furniture",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-superfront.cjs",[[1,"hemfixarna-superfront",{"id":[1],"loadFromQuery":[1,"load-from-query"],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-tesla.cjs",[[1,"hemfixarna-tesla",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-traningspartner.cjs",[[1,"hemfixarna-traningspartner",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-zaptec.cjs",[[1,"hemfixarna-zaptec",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-category.cjs",[[0,"hemfixarna-category"]]],["hemfixarna-service.cjs",[[0,"hemfixarna-service"]]]], options);
17
+ return index.bootstrapLazy([["hemfixarna-address_15.cjs",[[1,"hemfixarna-demo",{"selectedSlug":[32],"selectedID":[32],"tooltipText":[32],"tree":[32],"customer":[32],"widgetStyle":[32],"buttonBg":[32],"buttonColor":[32],"partner":[32],"colorAccessibility":[32],"loggedIn":[32],"loginError":[32]}],[1,"hemfixarna-component",{"id":[1],"slug":[1],"business":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"],"modal":[32],"showModal":[32],"product":[32],"proppedProduct":[32],"loginSourceError":[32]},[[0,"click","handleClick"]]],[0,"hemfixarna-cart"],[0,"hemfixarna-order"],[0,"hemfixarna-product",{"amount":[32],"hideDescription":[32]}],[0,"hemfixarna-start",{"tree":[16],"slug":[1]}],[0,"hemfixarna-breadcrumbs",{"closeModal":[16]}],[0,"hemfixarna-checkout",{"date":[32],"dateError":[32],"generalError":[32],"loading":[32],"enteredPin":[32],"selectedSubSource":[32],"partnerOrderId":[32],"sellerID":[32],"RefferalID":[32],"termsChecked":[32]}],[0,"hemfixarna-contact",{"vertical":[4]}],[0,"hemfixarna-invoice",{"formError":[32],"displayImages":[32],"formImages":[32],"formState":[32]}],[0,"hemfixarna-address",{"street":[32],"streetError":[32],"zip":[32],"zipError":[32],"town":[32],"townError":[32]}],[0,"hemfixarna-getuser",{"email":[32],"emailError":[32],"phone":[32],"phoneError":[32],"ssn":[32],"ssnError":[32]}],[0,"hemfixarna-orderrows",{"cart":[4]}],[0,"hemfixarna-box",{"post":[16],"category":[16],"icon":[1],"postTitle":[1,"post-title"]}],[0,"hemfixarna-info"]]],["hemfixarna-byggmax.cjs",[[1,"hemfixarna-byggmax",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"],"slug":[1]}]]],["hemfixarna-doro.cjs",[[1,"hemfixarna-doro",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-elfa.cjs",[[1,"hemfixarna-elfa",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-fargvaruhuset.cjs",[[1,"hemfixarna-fargvaruhuset",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-flyttsmart.cjs",[[1,"hemfixarna-flyttsmart",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-forebygg.cjs",[[1,"hemfixarna-forebygg",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-hornbach.cjs",[[1,"hemfixarna-hornbach",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-kbygg.cjs",[[1,"hemfixarna-kbygg",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-klint.cjs",[[1,"hemfixarna-klint",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-kund.cjs",[[1,"hemfixarna-kund",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-norrgavel.cjs",[[1,"hemfixarna-norrgavel",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-power.cjs",[[1,"hemfixarna-power",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-skanska.cjs",[[1,"hemfixarna-skanska",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-sparfonster.cjs",[[1,"hemfixarna-sparfonster",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-string-furniture.cjs",[[1,"hemfixarna-string-furniture",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-superfront.cjs",[[1,"hemfixarna-superfront",{"id":[1],"loadFromQuery":[1,"load-from-query"],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-tesla.cjs",[[1,"hemfixarna-tesla",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-traningspartner.cjs",[[1,"hemfixarna-traningspartner",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-zaptec.cjs",[[1,"hemfixarna-zaptec",{"id":[1],"widgetStyle":[1,"widget-style"],"buttonColor":[1,"button-color"],"buttonBg":[1,"button-bg"]}]]],["hemfixarna-category.cjs",[[0,"hemfixarna-category"]]],["hemfixarna-service.cjs",[[0,"hemfixarna-service"]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -11,7 +11,11 @@ export class HemfixarnaCheckout {
11
11
  this.dateError = null;
12
12
  this.date = e.target.value;
13
13
  };
14
- this.handleChangeTerms = () => {
14
+ this.handleChangeTerms = (e) => {
15
+ this.generalError = null;
16
+ this.termsChecked = e.target.checked;
17
+ };
18
+ this.handleChangeItemTerms = () => {
15
19
  this.generalError = null;
16
20
  };
17
21
  this.sendOrder = async () => {
@@ -73,6 +77,7 @@ export class HemfixarnaCheckout {
73
77
  id_sub_source: this.selectedSubSource ? this.selectedSubSource : '',
74
78
  seller_id: (_a = this.sellerID) !== null && _a !== void 0 ? _a : '',
75
79
  referral_id: (_b = this.RefferalID) !== null && _b !== void 0 ? _b : '',
80
+ marketing_approval: this.termsChecked ? 1 : 0,
76
81
  };
77
82
  const felixOrder = await postPerson(order);
78
83
  if (!felixOrder || !((_d = (_c = felixOrder.response) === null || _c === void 0 ? void 0 : _c.scriptResult) === null || _d === void 0 ? void 0 : _d.includes('OK'))) {
@@ -105,11 +110,6 @@ export class HemfixarnaCheckout {
105
110
  if (!validDate) {
106
111
  this.dateError = 'Ange ett giltigt datum';
107
112
  }
108
- const checkBoxes = Array.from(this.el.querySelectorAll('input[type="checkbox"]'));
109
- const notValidTerms = checkBoxes.find(i => !i.checked);
110
- if (notValidTerms) {
111
- this.generalError = 'Du måste godkänna villkoren';
112
- }
113
113
  if (state.customer.source && state.selectSource) {
114
114
  if (!this.sellerID) {
115
115
  this.generalError = 'Ange säljare';
@@ -120,7 +120,7 @@ export class HemfixarnaCheckout {
120
120
  return;
121
121
  }
122
122
  }
123
- if (validDate && !notValidTerms) {
123
+ if (validDate) {
124
124
  this.sendOrder();
125
125
  }
126
126
  };
@@ -136,9 +136,9 @@ export class HemfixarnaCheckout {
136
136
  return h("hemfixarna-getuser", null);
137
137
  }
138
138
  else if (state.checkoutStep === 2) {
139
- return (h("div", { class: "mb-2" }, h("div", { class: "hemfixarna_addressinfo" }, h("div", null, h("p", null, hideField(state.user.firstName)), h("p", null, hideField(state.user.lastName)), h("p", null, state.user.email), h("p", null, state.user.phone)), h("div", null, h("p", null, hideField(state.user.street)), h("p", null, hideField(state.user.zip)), h("p", null, hideField(state.user.town))), h("button", { onClick: () => (state.checkoutEdit = true) }, "Beh\u00F6ver du \u00E4ndra adressen?")), h("form", { onSubmit: e => this.handleSubmit(e) }, h("div", null, h("img", { src: dateLogo, width: 24 }), h("input", { class: `${this.date.length ? 'input_active' : ''}`, min: new Date().toISOString().split('T')[0], onChange: e => this.handleChangeDate(e), type: "date", name: "date", value: this.date }), h("label", { htmlFor: "date" }, "Tidigaste datum f\u00F6r hembes\u00F6k"), h("img", { src: down, width: 24 })), this.dateError && h("span", null, this.dateError), state.customer.source && state.selectSource ? (h(Fragment, null, h("p", null, "Inloggad som:", h("strong", null, " ", state.customer.source.fieldData.So01_Name)), h("label", null, "S\u00E4ljare (S\u00E4ljarId)", h("input", { type: "text", value: this.sellerID, onChange: e => (this.sellerID = e.target.value) })), h("label", null, "PartnerOrderID (RefferalID)", h("input", { type: "text", value: this.RefferalID, onChange: e => (this.RefferalID = e.target.value) })), ((_a = state.customer.source.sub_sources) === null || _a === void 0 ? void 0 : _a.length) ? (h("div", null, h("select", { onChange: e => (this.selectedSubSource = e.target.value) }, h("option", { disabled: true, selected: true, value: "null" }, "V\u00E4lj underk\u00E4lla"), state.customer.source.sub_sources.map(sub => (h("option", { value: sub['So_SubSource::Sus01_Name'] }, sub['So_SubSource::Sus01_Name'])))))) : (h("p", null, "Det finns inga underk\u00E4llor att v\u00E4lja")))) : null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeTerms(), type: "checkbox" }), h("span", { innerHTML: state.options.terms })), state.cart
139
+ return (h("div", { class: "mb-2" }, h("div", { class: "hemfixarna_addressinfo" }, h("div", null, h("p", null, hideField(state.user.firstName)), h("p", null, hideField(state.user.lastName)), h("p", null, state.user.email), h("p", null, state.user.phone)), h("div", null, h("p", null, hideField(state.user.street)), h("p", null, hideField(state.user.zip)), h("p", null, hideField(state.user.town))), h("button", { onClick: () => (state.checkoutEdit = true) }, "Beh\u00F6ver du \u00E4ndra adressen?")), h("form", { onSubmit: e => this.handleSubmit(e) }, h("div", null, h("img", { src: dateLogo, width: 24 }), h("input", { class: `${this.date.length ? 'input_active' : ''}`, min: new Date().toISOString().split('T')[0], onChange: e => this.handleChangeDate(e), type: "date", name: "date", value: this.date }), h("label", { htmlFor: "date" }, "Tidigaste datum f\u00F6r hembes\u00F6k"), h("img", { src: down, width: 24 })), this.dateError && h("span", null, this.dateError), state.customer.source && state.selectSource ? (h(Fragment, null, h("p", null, "Inloggad som:", h("strong", null, " ", state.customer.source.fieldData.So01_Name)), h("label", null, "S\u00E4ljare (S\u00E4ljarId)", h("input", { type: "text", value: this.sellerID, onChange: e => (this.sellerID = e.target.value) })), h("label", null, "PartnerOrderID (RefferalID)", h("input", { type: "text", value: this.RefferalID, onChange: e => (this.RefferalID = e.target.value) })), ((_a = state.customer.source.sub_sources) === null || _a === void 0 ? void 0 : _a.length) ? (h("div", null, h("select", { onChange: e => (this.selectedSubSource = e.target.value) }, h("option", { disabled: true, selected: true, value: "null" }, "V\u00E4lj underk\u00E4lla"), state.customer.source.sub_sources.map(sub => (h("option", { value: sub['So_SubSource::Sus01_Name'] }, sub['So_SubSource::Sus01_Name'])))))) : (h("p", null, "Det finns inga underk\u00E4llor att v\u00E4lja")))) : null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: e => this.handleChangeTerms(e), type: "checkbox" }), h("span", { innerHTML: state.options.terms })), state.cart
140
140
  .filter(i => { var _a; return (_a = i.terms_checkout) === null || _a === void 0 ? void 0 : _a.length; })
141
- .map(item => (h(Fragment, null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeTerms(), type: "checkbox" }), h("span", null, item.terms_checkout))))), this.generalError && h("span", null, this.generalError), h("div", { class: this.loading ? 'loading' : '' }, h("input", { type: "submit", value: this.loading ? '' : 'Skicka bokning' }), h("img", { width: 20, height: 20, src: loading, alt: "spinner" })))));
141
+ .map(item => (h(Fragment, null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeItemTerms(), type: "checkbox" }), h("span", null, item.terms_checkout))))), this.generalError && h("span", null, this.generalError), h("div", { class: this.loading ? 'loading' : '' }, h("input", { type: "submit", value: this.loading ? '' : 'Skicka bokning' }), h("img", { width: 20, height: 20, src: loading, alt: "spinner" })))));
142
142
  }
143
143
  };
144
144
  this.date = '';
@@ -150,6 +150,7 @@ export class HemfixarnaCheckout {
150
150
  this.partnerOrderId = null;
151
151
  this.sellerID = null;
152
152
  this.RefferalID = null;
153
+ this.termsChecked = false;
153
154
  }
154
155
  componentWillLoad() {
155
156
  if (Boolean(state.user && state.user.street)) {
@@ -167,7 +168,8 @@ export class HemfixarnaCheckout {
167
168
  "selectedSubSource": {},
168
169
  "partnerOrderId": {},
169
170
  "sellerID": {},
170
- "RefferalID": {}
171
+ "RefferalID": {},
172
+ "termsChecked": {}
171
173
  };
172
174
  }
173
175
  static get elementRef() { return "el"; }
@@ -1 +1 @@
1
- {"version":3,"file":"hemfixarna-checkout.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-checkout/hemfixarna-checkout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAc,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMjD,MAAM,OAAO,kBAAkB;;IAY7B,qBAAgB,GAAG,CAAC,CAAQ,EAAE,EAAE;MAC9B,IAAI,CAAC,SAAS,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AK,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAC,SAAS,GAAG,CACtD,CACD,CACH,CACP,CAAC;OACH;IACH,CAAC,CAAC;gBAnOsB,EAAE;qBACU,IAAI;wBACD,IAAI;mBACxB,KAAK;sBACM,EAAE;6BAEY,IAAI;0BACP,IAAI;oBACV,IAAI;sBACF,IAAI;;EAsHzC,iBAAiB;IACf,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;MAC5C,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC;KACxB;EACH,CAAC;;;;;;;;;;;;;;CAiGF","sourcesContent":["import { Component, Element, Fragment, State, getAssetPath, h } from '@stencil/core';\nimport state from '../../store';\nimport { Business } from '../../types';\nimport { postOrder } from '../../utils/api';\nimport { FelixOrder, postPerson } from '../../utils/felixApi';\nimport { hideField } from '../../utils/form';\nimport { scrollToTop } from '../../utils/scroll';\n\n@Component({\n tag: 'hemfixarna-checkout',\n shadow: false,\n})\nexport class HemfixarnaCheckout {\n @State() date: string = '';\n @State() dateError: string | null = null;\n @State() generalError: string | null = null;\n @State() loading = false;\n @State() enteredPin: string = '';\n @Element() private el: HTMLElement;\n @State() selectedSubSource: string | null = null;\n @State() partnerOrderId: string | null = null;\n @State() sellerID: string | null = null;\n @State() RefferalID: string | null = null;\n\n handleChangeDate = (e: Event) => {\n this.dateError = null;\n this.date = (e.target as HTMLInputElement).value;\n };\n\n handleChangeTerms = () => {\n this.generalError = null;\n };\n\n sendOrder = async () => {\n if (this.loading) return;\n this.loading = true;\n\n const startFees = state.cart\n .filter(item => item.start_fee_obj)\n .map(item => ({\n ID: item.start_fee_obj?.ID,\n title: item.start_fee_obj?.title,\n price: item.start_fee_obj?.price,\n rut: item.rut ? 1 : 0,\n rot: item.rot ? 1 : 0,\n green: item.green ? 1 : 0,\n }));\n\n let order: FelixOrder = {\n firstName: state.creditSafeUser.firstName,\n lastName: state.creditSafeUser.lastName,\n street: state.user.street,\n zip: state.user.zip,\n town: state.user.town,\n ssn: state.user.ssn,\n email: state.user.email,\n phone: state.user.phone,\n url: `${state.business === Business.string ? 'string' : state.business}-webk`,\n date: this.date,\n products: [\n ...state.cart.map(item => {\n const parts = item.parts.map(part => ({\n id: String(part.id),\n name: part.name,\n quantity: part.amount,\n rut: 0,\n rot: 0,\n start_fee_id: item.start_fee_obj ? item.start_fee_obj.ID : null,\n }));\n return [\n {\n id: String(item.id),\n name: item.name,\n quantity: item.amount,\n rot: item.rot ? 1 : 0,\n rut: item.rut ? 1 : 0,\n start_fee_id: item.start_fee_obj ? item.start_fee_obj.ID : null,\n },\n ...parts,\n ];\n }),\n ].flat(),\n start_fees: startFees,\n creditSafe: state.creditSafeUser,\n customer: state.business,\n id_source: state.customer.source ? state.customer.source.fieldData.So01_Name : '',\n id_sub_source: this.selectedSubSource ? this.selectedSubSource : '',\n seller_id: this.sellerID ?? '',\n referral_id: this.RefferalID ?? '',\n };\n\n const felixOrder = await postPerson(order);\n if (!felixOrder || !felixOrder.response?.scriptResult?.includes('OK')) {\n order = { ...order, felixStatus: 'error' };\n } else {\n order = { ...order, felixStatus: 'success' };\n }\n\n try {\n const { data: orderConfirm, status } = await postOrder(order);\n if (orderConfirm && status && status === 200) {\n state.step = 6;\n const el = this.el.closest('.hemfixarna_content');\n scrollToTop(el);\n } else {\n this.generalError = 'Något gick fel, försök igen senare';\n }\n } catch (error) {\n this.generalError = 'Något gick fel, försök igen senare';\n }\n this.loading = false;\n };\n\n handleSubmit = (e: Event) => {\n e.preventDefault();\n this.generalError = null;\n const validDate = this.date.length > 0;\n if (!validDate) {\n this.dateError = 'Ange ett giltigt datum';\n }\n const checkBoxes = Array.from(this.el.querySelectorAll('input[type=\"checkbox\"]'));\n const notValidTerms = checkBoxes.find(i => !(i as HTMLInputElement).checked);\n if (notValidTerms) {\n this.generalError = 'Du måste godkänna villkoren';\n }\n if (state.customer.source && state.selectSource) {\n if (!this.sellerID) {\n this.generalError = 'Ange säljare';\n return;\n }\n if (state.customer.source.sub_sources?.length && !this.selectedSubSource) {\n this.generalError = 'Välj underkälla';\n return;\n }\n }\n if (validDate && !notValidTerms) {\n this.sendOrder();\n }\n };\n\n componentWillLoad() {\n if (Boolean(state.user && state.user.street)) {\n state.checkoutStep = 2;\n }\n }\n\n render = () => {\n const dateLogo = getAssetPath(`./assets/date.svg`);\n const down = getAssetPath(`./assets/down.svg`);\n const loading = getAssetPath(`./assets/spinner.gif`);\n\n if (state.checkoutEdit) {\n return <hemfixarna-address />;\n } else if (state.checkoutStep === 1) {\n return <hemfixarna-getuser />;\n } else if (state.checkoutStep === 2) {\n return (\n <div class=\"mb-2\">\n <div class=\"hemfixarna_addressinfo\">\n <div>\n <p>{hideField(state.user.firstName)}</p>\n <p>{hideField(state.user.lastName)}</p>\n <p>{state.user.email}</p>\n <p>{state.user.phone}</p>\n </div>\n <div>\n <p>{hideField(state.user.street)}</p>\n <p>{hideField(state.user.zip)}</p>\n <p>{hideField(state.user.town)}</p>\n </div>\n <button onClick={() => (state.checkoutEdit = true)}>Behöver du ändra adressen?</button>\n </div>\n <form onSubmit={e => this.handleSubmit(e)}>\n <div>\n <img src={dateLogo} width={24} />\n <input\n class={`${this.date.length ? 'input_active' : ''}`}\n min={new Date().toISOString().split('T')[0]}\n onChange={e => this.handleChangeDate(e)}\n type=\"date\"\n name=\"date\"\n value={this.date}\n />\n <label htmlFor=\"date\">Tidigaste datum för hembesök</label>\n <img src={down} width={24} />\n </div>\n {this.dateError && <span>{this.dateError}</span>}\n {state.customer.source && state.selectSource ? (\n <Fragment>\n <p>\n Inloggad som:\n <strong> {state.customer.source.fieldData.So01_Name}</strong>\n </p>\n <label>\n Säljare (SäljarId)\n <input type=\"text\" value={this.sellerID} onChange={e => (this.sellerID = (e.target as HTMLInputElement).value)} />\n </label>\n <label>\n PartnerOrderID (RefferalID)\n <input type=\"text\" value={this.RefferalID} onChange={e => (this.RefferalID = (e.target as HTMLInputElement).value)} />\n </label>\n {state.customer.source.sub_sources?.length ? (\n <div>\n <select onChange={e => (this.selectedSubSource = (e.target as HTMLSelectElement).value)}>\n <option disabled selected value=\"null\">\n Välj underkälla\n </option>\n {state.customer.source.sub_sources.map(sub => (\n <option value={sub['So_SubSource::Sus01_Name']}>{sub['So_SubSource::Sus01_Name']}</option>\n ))}\n </select>\n </div>\n ) : (\n <p>Det finns inga underkällor att välja</p>\n )}\n </Fragment>\n ) : null}\n <label class=\"hemfixarna_checkbox\">\n <input onChange={() => this.handleChangeTerms()} type=\"checkbox\" />\n <span innerHTML={state.options.terms} />\n </label>\n {state.cart\n .filter(i => i.terms_checkout?.length)\n .map(item => (\n <Fragment>\n <label class=\"hemfixarna_checkbox\">\n <input onChange={() => this.handleChangeTerms()} type=\"checkbox\" />\n <span>{item.terms_checkout}</span>\n </label>\n </Fragment>\n ))}\n {this.generalError && <span>{this.generalError}</span>}\n <div class={this.loading ? 'loading' : ''}>\n <input type=\"submit\" value={this.loading ? '' : 'Skicka bokning'} />\n <img width={20} height={20} src={loading} alt=\"spinner\" />\n </div>\n </form>\n </div>\n );\n }\n };\n}\n"]}
1
+ {"version":3,"file":"hemfixarna-checkout.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-checkout/hemfixarna-checkout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAc,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBA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CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,GAAI;cACpE,WAAK,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAC,SAAS,GAAG,CACtD,CACD,CACH,CACP,CAAC;OACH;IACH,CAAC,CAAC;gBArOsB,EAAE;qBACU,IAAI;wBACD,IAAI;mBACxB,KAAK;sBACM,EAAE;6BAEY,IAAI;0BACP,IAAI;oBACV,IAAI;sBACF,IAAI;wBACR,KAAK;;EAuHtC,iBAAiB;IACf,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;MAC5C,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC;KACxB;EACH,CAAC;;;;;;;;;;;;;;;CAiGF","sourcesContent":["import { Component, Element, Fragment, State, getAssetPath, h } from '@stencil/core';\nimport state from '../../store';\nimport { Business } from '../../types';\nimport { postOrder } from '../../utils/api';\nimport { FelixOrder, postPerson } from '../../utils/felixApi';\nimport { hideField } from '../../utils/form';\nimport { scrollToTop } from '../../utils/scroll';\n\n@Component({\n tag: 'hemfixarna-checkout',\n shadow: false,\n})\nexport class HemfixarnaCheckout {\n @State() date: string = '';\n @State() dateError: string | null = null;\n @State() generalError: string | null = null;\n @State() loading = false;\n @State() enteredPin: string = '';\n @Element() private el: HTMLElement;\n @State() selectedSubSource: string | null = null;\n @State() partnerOrderId: string | null = null;\n @State() sellerID: string | null = null;\n @State() RefferalID: string | null = null;\n @State() termsChecked: boolean = false;\n\n handleChangeDate = (e: Event) => {\n this.dateError = null;\n this.date = (e.target as HTMLInputElement).value;\n };\n\n handleChangeTerms = (e: Event) => {\n this.generalError = null;\n this.termsChecked = (e.target as HTMLInputElement).checked;\n };\n\n handleChangeItemTerms = () => {\n this.generalError = null;\n };\n\n sendOrder = async () => {\n if (this.loading) return;\n this.loading = true;\n\n const startFees = state.cart\n .filter(item => item.start_fee_obj)\n .map(item => ({\n ID: item.start_fee_obj?.ID,\n title: item.start_fee_obj?.title,\n price: item.start_fee_obj?.price,\n rut: item.rut ? 1 : 0,\n rot: item.rot ? 1 : 0,\n green: item.green ? 1 : 0,\n }));\n\n let order: FelixOrder = {\n firstName: state.creditSafeUser.firstName,\n lastName: state.creditSafeUser.lastName,\n street: state.user.street,\n zip: state.user.zip,\n town: state.user.town,\n ssn: state.user.ssn,\n email: state.user.email,\n phone: state.user.phone,\n url: `${state.business === Business.string ? 'string' : state.business}-webk`,\n date: this.date,\n products: [\n ...state.cart.map(item => {\n const parts = item.parts.map(part => ({\n id: String(part.id),\n name: part.name,\n quantity: part.amount,\n rut: 0,\n rot: 0,\n start_fee_id: item.start_fee_obj ? item.start_fee_obj.ID : null,\n }));\n return [\n {\n id: String(item.id),\n name: item.name,\n quantity: item.amount,\n rot: item.rot ? 1 : 0,\n rut: item.rut ? 1 : 0,\n start_fee_id: item.start_fee_obj ? item.start_fee_obj.ID : null,\n },\n ...parts,\n ];\n }),\n ].flat(),\n start_fees: startFees,\n creditSafe: state.creditSafeUser,\n customer: state.business,\n id_source: state.customer.source ? state.customer.source.fieldData.So01_Name : '',\n id_sub_source: this.selectedSubSource ? this.selectedSubSource : '',\n seller_id: this.sellerID ?? '',\n referral_id: this.RefferalID ?? '',\n marketing_approval: this.termsChecked ? 1 : 0,\n };\n\n const felixOrder = await postPerson(order);\n if (!felixOrder || !felixOrder.response?.scriptResult?.includes('OK')) {\n order = { ...order, felixStatus: 'error' };\n } else {\n order = { ...order, felixStatus: 'success' };\n }\n\n try {\n const { data: orderConfirm, status } = await postOrder(order);\n if (orderConfirm && status && status === 200) {\n state.step = 6;\n const el = this.el.closest('.hemfixarna_content');\n scrollToTop(el);\n } else {\n this.generalError = 'Något gick fel, försök igen senare';\n }\n } catch (error) {\n this.generalError = 'Något gick fel, försök igen senare';\n }\n this.loading = false;\n };\n\n handleSubmit = (e: Event) => {\n e.preventDefault();\n this.generalError = null;\n const validDate = this.date.length > 0;\n if (!validDate) {\n this.dateError = 'Ange ett giltigt datum';\n }\n if (state.customer.source && state.selectSource) {\n if (!this.sellerID) {\n this.generalError = 'Ange säljare';\n return;\n }\n if (state.customer.source.sub_sources?.length && !this.selectedSubSource) {\n this.generalError = 'Välj underkälla';\n return;\n }\n }\n if (validDate) {\n this.sendOrder();\n }\n };\n\n componentWillLoad() {\n if (Boolean(state.user && state.user.street)) {\n state.checkoutStep = 2;\n }\n }\n\n render = () => {\n const dateLogo = getAssetPath(`./assets/date.svg`);\n const down = getAssetPath(`./assets/down.svg`);\n const loading = getAssetPath(`./assets/spinner.gif`);\n\n if (state.checkoutEdit) {\n return <hemfixarna-address />;\n } else if (state.checkoutStep === 1) {\n return <hemfixarna-getuser />;\n } else if (state.checkoutStep === 2) {\n return (\n <div class=\"mb-2\">\n <div class=\"hemfixarna_addressinfo\">\n <div>\n <p>{hideField(state.user.firstName)}</p>\n <p>{hideField(state.user.lastName)}</p>\n <p>{state.user.email}</p>\n <p>{state.user.phone}</p>\n </div>\n <div>\n <p>{hideField(state.user.street)}</p>\n <p>{hideField(state.user.zip)}</p>\n <p>{hideField(state.user.town)}</p>\n </div>\n <button onClick={() => (state.checkoutEdit = true)}>Behöver du ändra adressen?</button>\n </div>\n <form onSubmit={e => this.handleSubmit(e)}>\n <div>\n <img src={dateLogo} width={24} />\n <input\n class={`${this.date.length ? 'input_active' : ''}`}\n min={new Date().toISOString().split('T')[0]}\n onChange={e => this.handleChangeDate(e)}\n type=\"date\"\n name=\"date\"\n value={this.date}\n />\n <label htmlFor=\"date\">Tidigaste datum för hembesök</label>\n <img src={down} width={24} />\n </div>\n {this.dateError && <span>{this.dateError}</span>}\n {state.customer.source && state.selectSource ? (\n <Fragment>\n <p>\n Inloggad som:\n <strong> {state.customer.source.fieldData.So01_Name}</strong>\n </p>\n <label>\n Säljare (SäljarId)\n <input type=\"text\" value={this.sellerID} onChange={e => (this.sellerID = (e.target as HTMLInputElement).value)} />\n </label>\n <label>\n PartnerOrderID (RefferalID)\n <input type=\"text\" value={this.RefferalID} onChange={e => (this.RefferalID = (e.target as HTMLInputElement).value)} />\n </label>\n {state.customer.source.sub_sources?.length ? (\n <div>\n <select onChange={e => (this.selectedSubSource = (e.target as HTMLSelectElement).value)}>\n <option disabled selected value=\"null\">\n Välj underkälla\n </option>\n {state.customer.source.sub_sources.map(sub => (\n <option value={sub['So_SubSource::Sus01_Name']}>{sub['So_SubSource::Sus01_Name']}</option>\n ))}\n </select>\n </div>\n ) : (\n <p>Det finns inga underkällor att välja</p>\n )}\n </Fragment>\n ) : null}\n <label class=\"hemfixarna_checkbox\">\n <input onChange={e => this.handleChangeTerms(e)} type=\"checkbox\" />\n <span innerHTML={state.options.terms} />\n </label>\n {state.cart\n .filter(i => i.terms_checkout?.length)\n .map(item => (\n <Fragment>\n <label class=\"hemfixarna_checkbox\">\n <input onChange={() => this.handleChangeItemTerms()} type=\"checkbox\" />\n <span>{item.terms_checkout}</span>\n </label>\n </Fragment>\n ))}\n {this.generalError && <span>{this.generalError}</span>}\n <div class={this.loading ? 'loading' : ''}>\n <input type=\"submit\" value={this.loading ? '' : 'Skicka bokning'} />\n <img width={20} height={20} src={loading} alt=\"spinner\" />\n </div>\n </form>\n </div>\n );\n }\n };\n}\n"]}
@@ -3,7 +3,7 @@ const getRutPrice = (price) => {
3
3
  return Math.ceil(price / 2);
4
4
  };
5
5
  const getRotPrice = (price) => {
6
- return Math.ceil(price / 2);
6
+ return Math.ceil(price * 0.7);
7
7
  };
8
8
  const getGreenPrice = (price) => {
9
9
  return Math.ceil(price * 0.5);
@@ -1 +1 @@
1
- {"version":3,"file":"calc.js","sourceRoot":"","sources":["../../src/utils/calc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,UAAU,CAAC;AAG7B,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE;EACpC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CA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AAG,EAAE;MACZ,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE;QACxB,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC;QAC3B,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;OAChE;WAAM;QACL,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;OACrD;KACF;IAED,OAAO,GAAG,CAAC;EACb,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;EAEjD,OAAO,eAAe,GAAG,YAAY,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,GAAG,EAAE;EACzB,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,iBAAiB,EAAE,CAAC,GAAG,GAAG,iBAAiB,EAAE,CAAC,GAAG,GAAG,iBAAiB,EAAE,CAAC,KAAK,GAAG,iBAAiB,EAAE,CAAC,OAAO,CAAC;AACrL,CAAC,CAAC;AAEF,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,WAAW,EACX,cAAc,EACd,WAAW,EACX,cAAc,EACd,WAAW,EACX,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EAClB,CAAC","sourcesContent":["import state from '../store';\nimport { CartItem, CartPart, Part, Product } from '../types';\n\nconst getRutPrice = (price: number) => {\n return Math.ceil(price / 2);\n};\n\nconst getRotPrice = (price: number) => {\n return Math.ceil(price / 2);\n};\n\nconst getGreenPrice = (price: number) => {\n return Math.ceil(price * 0.5);\n};\n\nconst getRutStartFee = () => {\n if (!state.options) return 448;\n if (state.rut) {\n return getRutPrice(state.options.start_fee);\n } else {\n return state.options.start_fee;\n }\n};\n\nconst getRotStartFee = () => {\n if (!state.options) return 448;\n if (state.rot) {\n return getRotPrice(state.options.start_fee);\n } else {\n return state.options.start_fee;\n }\n};\n\nconst getProductPrice = (product: Product | CartItem, price?: number, amount: number = 1) => {\n if (product.rot && state.rot) {\n return getRotPrice((price || product.price) * amount);\n } else if (product.rut && state.rut) {\n return getRutPrice((price || product.price) * amount);\n } else if (product.green && state.green) {\n return getGreenPrice((price || product.price) * amount);\n } else {\n return (price || product.price) * amount;\n }\n};\n\nconst getProductPriceWithRotAndRut = (product: Product) => {\n if (product.rot) {\n return getRotPrice(product.price);\n } else if (product.rut && state.rut) {\n return getRutPrice(product.price);\n } else {\n return product.price;\n }\n};\n\nconst getPartPrice = (part: Part | CartPart, product: Product | CartItem, amount: number = 1) => {\n if (product.rot && state.rot) {\n return getRotPrice(part.price * amount);\n } else if (product.rut && state.rut) {\n return getRutPrice(part.price * amount);\n } else if (product.green && state.green) {\n return getGreenPrice(part.price * amount);\n } else {\n return part.price * amount;\n }\n};\n\n\nconst groupCartItemsByStartFee = (cart: CartItem[]) => {\n return cart.reduce((groups, item) => {\n const startFeeID = item.start_fee_obj?.ID || null;\n if (!groups[startFeeID]) {\n groups[startFeeID] = [];\n }\n groups[startFeeID].push(item);\n return groups;\n }, {} as Record<string, CartItem[]>);\n};\n\nconst calculateStartFee = (cart: CartItem[] = state.cart) => {\n const uniqueStartFees = new Set<number>();\n let totalRut = 0;\n let totalRot = 0;\n let totalGreen = 0;\n let totalDefault = 0;\n\n cart.forEach(item => {\n const startFee = item.start_fee_obj;\n if (startFee && !uniqueStartFees.has(startFee.ID)) {\n uniqueStartFees.add(startFee.ID);\n\n if (item.rut) {\n totalRut += state.rut ? getRutPrice(startFee.price) : startFee.price;\n }\n if (item.rot) {\n totalRot += state.rot ? getRotPrice(startFee.price) : startFee.price;\n }\n if (item.green) {\n totalGreen += state.green ? getGreenPrice(startFee.price) : startFee.price;\n }\n if (!item.rut && !item.rot && !item.green) {\n totalDefault += startFee.price;\n }\n }\n });\n\n const appliedDiscounts = [totalRut > 0, totalRot > 0, totalGreen > 0];\n return {\n rut: totalRut,\n rot: totalRot,\n green: totalGreen,\n default: totalDefault,\n length: appliedDiscounts.filter(Boolean).length,\n };\n};\n\nconst getStartFee = () => {\n if (!state.cart) return { rut: 0, rot: 0, green: 0 };\n const hasRut = state.cart.some(item => item.rut && item.start_fee);\n const hasRot = state.cart.some(item => item.rot && item.start_fee);\n const hasGreen = state.cart.some(item => item.green && item.start_fee);\n const rutPrice = state.rut ? getRutPrice(state.options.start_fee) : state.options.start_fee * 1;\n const rotPrice = state.rot ? getRotPrice(state.options.start_fee) : state.options.start_fee * 1;\n const greenPrice = state.green ? getGreenPrice(state.options.start_fee) : state.options.start_fee * 1;\n return { rut: hasRut ? rutPrice : 0, rot: hasRot ? rotPrice : 0, green: hasGreen ? greenPrice : 0, length: [hasRut, hasRot, hasGreen].filter(d => d).length };\n};\n\nconst getItemPrice = (item: CartItem) => {\n const partsPrice = item.parts.reduce((acc, curr) => {\n return acc + curr.price * curr.amount;\n }, 0);\n return getProductPrice(item, item.price * item.amount + partsPrice);\n};\n\nconst calculateRot = () => {\n const totalWithRot =\n state.cart.reduce((acc, curr) => {\n return curr.rot ? acc + getItemPrice(curr) : acc;\n }, 0) + (state.cart.some(item => item.rot) ? calculateStartFee().rot : 0);\n\n const totalWithoutRot = state.cart.reduce((acc, curr) => {\n const partsPrice = curr.parts.reduce((acc, part) => {\n return acc + part.price * part.amount;\n }, 0);\n const startFee = curr.start_fee_obj?.price || 0;\n\n if (curr.rot) {\n if (!acc.startFeeApplied) {\n acc.startFeeApplied = true;\n acc.amount += curr.price * curr.amount + partsPrice + startFee;\n } else {\n acc.amount += curr.price * curr.amount + partsPrice;\n }\n }\n \n return acc;\n }, { amount: 0, startFeeApplied: false }).amount;\n\n return totalWithoutRot - totalWithRot;\n};\n\nconst calculateGreenDiscount = () => {\n const totalWithGreen =\n state.cart.reduce((acc, curr) => {\n return curr.green ? acc + getItemPrice(curr) : acc;\n }, 0) + (state.cart.some(item => item.green) ? calculateStartFee().green : 0);\n\n const totalWithoutGreen = state.cart.reduce((acc, curr) => {\n const partsPrice = curr.parts.reduce((acc, part) => {\n return acc + part.price * part.amount;\n }, 0);\n const startFee = curr.start_fee_obj?.price || 0;\n\n if (curr.green) {\n if (!acc.startFeeApplied) {\n acc.startFeeApplied = true;\n acc.amount += curr.price * curr.amount + partsPrice + startFee;\n } else {\n acc.amount += curr.price * curr.amount + partsPrice;\n }\n }\n \n return acc;\n }, { amount: 0, startFeeApplied: false }).amount;\n\n return totalWithoutGreen - totalWithGreen;\n};\n\nconst calculateRut = () => {\n const totalWithRut =\n state.cart.reduce((acc, curr) => {\n return curr.rut ? acc + getItemPrice(curr) : acc;\n }, 0) + (state.cart.some(item => item.rut) ? calculateStartFee().rut : 0);\n\n const totalWithoutRut = state.cart.reduce((acc, curr) => {\n const partsPrice = curr.parts.reduce((acc, part) => {\n return acc + part.price * part.amount;\n }, 0);\n const startFee = curr.start_fee_obj?.price || 0;\n\n if (curr.rut) {\n if (!acc.startFeeApplied) {\n acc.startFeeApplied = true;\n acc.amount += curr.price * curr.amount + partsPrice + startFee;\n } else {\n acc.amount += curr.price * curr.amount + partsPrice;\n }\n }\n \n return acc;\n }, { amount: 0, startFeeApplied: false }).amount;\n\n return totalWithoutRut - totalWithRut;\n};\n\nconst getTotalPrice = () => {\n return state.cart.reduce((acc, curr) => acc + getItemPrice(curr), 0) + calculateStartFee().rot + calculateStartFee().rut + calculateStartFee().green + calculateStartFee().default;\n};\n\nexport {\n calculateGreenDiscount,\n calculateRot,\n calculateRut,\n getGreenPrice,\n getItemPrice,\n getPartPrice,\n getProductPrice,\n getProductPriceWithRotAndRut,\n getRotPrice,\n getRotStartFee,\n getRutPrice,\n getRutStartFee,\n getStartFee,\n getTotalPrice,\n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WAAW,EACX,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EAClB,CAAC","sourcesContent":["import state from '../store';\nimport { CartItem, CartPart, Part, Product } from '../types';\n\nconst getRutPrice = (price: number) => {\n return Math.ceil(price / 2);\n};\n\nconst getRotPrice = (price: number) => {\n return Math.ceil(price * 0.7);\n};\n\nconst getGreenPrice = (price: number) => {\n return Math.ceil(price * 0.5);\n};\n\nconst getRutStartFee = () => {\n if (!state.options) return 448;\n if (state.rut) {\n return getRutPrice(state.options.start_fee);\n } else {\n return state.options.start_fee;\n }\n};\n\nconst getRotStartFee = () => {\n if (!state.options) return 448;\n if (state.rot) {\n return getRotPrice(state.options.start_fee);\n } else {\n return state.options.start_fee;\n }\n};\n\nconst getProductPrice = (product: Product | CartItem, price?: number, amount: number = 1) => {\n if (product.rot && state.rot) {\n return getRotPrice((price || product.price) * amount);\n } else if (product.rut && state.rut) {\n return getRutPrice((price || product.price) * amount);\n } else if (product.green && state.green) {\n return getGreenPrice((price || product.price) * amount);\n } else {\n return (price || product.price) * amount;\n }\n};\n\nconst getProductPriceWithRotAndRut = (product: Product) => {\n if (product.rot) {\n return getRotPrice(product.price);\n } else if (product.rut && state.rut) {\n return getRutPrice(product.price);\n } else {\n return product.price;\n }\n};\n\nconst getPartPrice = (part: Part | CartPart, product: Product | CartItem, amount: number = 1) => {\n if (product.rot && state.rot) {\n return getRotPrice(part.price * amount);\n } else if (product.rut && state.rut) {\n return getRutPrice(part.price * amount);\n } else if (product.green && state.green) {\n return getGreenPrice(part.price * amount);\n } else {\n return part.price * amount;\n }\n};\n\n\nconst groupCartItemsByStartFee = (cart: CartItem[]) => {\n return cart.reduce((groups, item) => {\n const startFeeID = item.start_fee_obj?.ID || null;\n if (!groups[startFeeID]) {\n groups[startFeeID] = [];\n }\n groups[startFeeID].push(item);\n return groups;\n }, {} as Record<string, CartItem[]>);\n};\n\nconst calculateStartFee = (cart: CartItem[] = state.cart) => {\n const uniqueStartFees = new Set<number>();\n let totalRut = 0;\n let totalRot = 0;\n let totalGreen = 0;\n let totalDefault = 0;\n\n cart.forEach(item => {\n const startFee = item.start_fee_obj;\n if (startFee && !uniqueStartFees.has(startFee.ID)) {\n uniqueStartFees.add(startFee.ID);\n\n if (item.rut) {\n totalRut += state.rut ? getRutPrice(startFee.price) : startFee.price;\n }\n if (item.rot) {\n totalRot += state.rot ? getRotPrice(startFee.price) : startFee.price;\n }\n if (item.green) {\n totalGreen += state.green ? getGreenPrice(startFee.price) : startFee.price;\n }\n if (!item.rut && !item.rot && !item.green) {\n totalDefault += startFee.price;\n }\n }\n });\n\n const appliedDiscounts = [totalRut > 0, totalRot > 0, totalGreen > 0];\n return {\n rut: totalRut,\n rot: totalRot,\n green: totalGreen,\n default: totalDefault,\n length: appliedDiscounts.filter(Boolean).length,\n };\n};\n\nconst getStartFee = () => {\n if (!state.cart) return { rut: 0, rot: 0, green: 0 };\n const hasRut = state.cart.some(item => item.rut && item.start_fee);\n const hasRot = state.cart.some(item => item.rot && item.start_fee);\n const hasGreen = state.cart.some(item => item.green && item.start_fee);\n const rutPrice = state.rut ? getRutPrice(state.options.start_fee) : state.options.start_fee * 1;\n const rotPrice = state.rot ? getRotPrice(state.options.start_fee) : state.options.start_fee * 1;\n const greenPrice = state.green ? getGreenPrice(state.options.start_fee) : state.options.start_fee * 1;\n return { rut: hasRut ? rutPrice : 0, rot: hasRot ? rotPrice : 0, green: hasGreen ? greenPrice : 0, length: [hasRut, hasRot, hasGreen].filter(d => d).length };\n};\n\nconst getItemPrice = (item: CartItem) => {\n const partsPrice = item.parts.reduce((acc, curr) => {\n return acc + curr.price * curr.amount;\n }, 0);\n return getProductPrice(item, item.price * item.amount + partsPrice);\n};\n\nconst calculateRot = () => {\n const totalWithRot =\n state.cart.reduce((acc, curr) => {\n return curr.rot ? acc + getItemPrice(curr) : acc;\n }, 0) + (state.cart.some(item => item.rot) ? calculateStartFee().rot : 0);\n\n const totalWithoutRot = state.cart.reduce((acc, curr) => {\n const partsPrice = curr.parts.reduce((acc, part) => {\n return acc + part.price * part.amount;\n }, 0);\n const startFee = curr.start_fee_obj?.price || 0;\n\n if (curr.rot) {\n if (!acc.startFeeApplied) {\n acc.startFeeApplied = true;\n acc.amount += curr.price * curr.amount + partsPrice + startFee;\n } else {\n acc.amount += curr.price * curr.amount + partsPrice;\n }\n }\n \n return acc;\n }, { amount: 0, startFeeApplied: false }).amount;\n\n return totalWithoutRot - totalWithRot;\n};\n\nconst calculateGreenDiscount = () => {\n const totalWithGreen =\n state.cart.reduce((acc, curr) => {\n return curr.green ? acc + getItemPrice(curr) : acc;\n }, 0) + (state.cart.some(item => item.green) ? calculateStartFee().green : 0);\n\n const totalWithoutGreen = state.cart.reduce((acc, curr) => {\n const partsPrice = curr.parts.reduce((acc, part) => {\n return acc + part.price * part.amount;\n }, 0);\n const startFee = curr.start_fee_obj?.price || 0;\n\n if (curr.green) {\n if (!acc.startFeeApplied) {\n acc.startFeeApplied = true;\n acc.amount += curr.price * curr.amount + partsPrice + startFee;\n } else {\n acc.amount += curr.price * curr.amount + partsPrice;\n }\n }\n \n return acc;\n }, { amount: 0, startFeeApplied: false }).amount;\n\n return totalWithoutGreen - totalWithGreen;\n};\n\nconst calculateRut = () => {\n const totalWithRut =\n state.cart.reduce((acc, curr) => {\n return curr.rut ? acc + getItemPrice(curr) : acc;\n }, 0) + (state.cart.some(item => item.rut) ? calculateStartFee().rut : 0);\n\n const totalWithoutRut = state.cart.reduce((acc, curr) => {\n const partsPrice = curr.parts.reduce((acc, part) => {\n return acc + part.price * part.amount;\n }, 0);\n const startFee = curr.start_fee_obj?.price || 0;\n\n if (curr.rut) {\n if (!acc.startFeeApplied) {\n acc.startFeeApplied = true;\n acc.amount += curr.price * curr.amount + partsPrice + startFee;\n } else {\n acc.amount += curr.price * curr.amount + partsPrice;\n }\n }\n \n return acc;\n }, { amount: 0, startFeeApplied: false }).amount;\n\n return totalWithoutRut - totalWithRut;\n};\n\nconst getTotalPrice = () => {\n return state.cart.reduce((acc, curr) => acc + getItemPrice(curr), 0) + calculateStartFee().rot + calculateStartFee().rut + calculateStartFee().green + calculateStartFee().default;\n};\n\nexport {\n calculateGreenDiscount,\n calculateRot,\n calculateRut,\n getGreenPrice,\n getItemPrice,\n getPartPrice,\n getProductPrice,\n getProductPriceWithRotAndRut,\n getRotPrice,\n getRotStartFee,\n getRutPrice,\n getRutStartFee,\n getStartFee,\n getTotalPrice,\n groupCartItemsByStartFee,\n calculateStartFee\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"felixApi.js","sourceRoot":"","sources":["../../src/utils/felixApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,IAAI,GAAG,GAAG,SAAS,EAAE,gBAAgB,CAAC;AA6C5C,MAAM,UAAU,GAAG,KAAK,EAAE,UAAsB,EAAE,EAAE;EAClD,IAAI;IACF,OAAO,MAAM,aAAa,CAcxB,GAAG,IAAI,eAAe,EAAE;MACxB,MAAM,EAAE,MAAM;MACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;MAChC,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;OACnC;KACF,CAAC,CAAC;GACJ;EAAC,OAAO,KAAK,EAAE;IACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;GACpB;AACH,CAAC,CAAC;AAEF,OAAO,EAAc,UAAU,EAAE,CAAC","sourcesContent":["import { fetchWithType } from './api';\nimport { getApiUrl } from './enviroment';\n\nconst base = `${getApiUrl()}/wp-json/felix`;\n\ninterface FelixOrder {\n firstName: string;\n lastName: string;\n street: string;\n zip: string;\n town: string;\n ssn: string;\n email: string;\n phone: string;\n url: string;\n date: string;\n notes?: string;\n wws?: string;\n referral_id?: string;\n id_source?: string;\n id_sub_source?: string;\n products: {\n id: string;\n name: string;\n quantity: number;\n rut: number;\n rot: number;\n }[];\n start_fees: {\n ID: number;\n price: number;\n rut: number;\n rot: number;\n green: number;\n }[];\n creditSafe: {\n firstName: string;\n lastName: string;\n street: string;\n zip: string;\n town: string;\n };\n felixStatus?: 'success' | 'error';\n customer?: string;\n seller_id?: string;\n refferal_id?: string;\n}\n\nconst postPerson = async (felixOrder: FelixOrder) => {\n try {\n return await fetchWithType<\n | {\n response: {\n scriptResult: string;\n scriptError: string;\n };\n messages: [\n {\n code: string;\n message: string;\n },\n ];\n }\n | false\n >(`${base}/createperson`, {\n method: 'POST',\n body: JSON.stringify(felixOrder),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n } catch (error) {\n console.log(error);\n }\n};\n\nexport { FelixOrder, postPerson };\n"]}
1
+ {"version":3,"file":"felixApi.js","sourceRoot":"","sources":["../../src/utils/felixApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,IAAI,GAAG,GAAG,SAAS,EAAE,gBAAgB,CAAC;AA8C5C,MAAM,UAAU,GAAG,KAAK,EAAE,UAAsB,EAAE,EAAE;EAClD,IAAI;IACF,OAAO,MAAM,aAAa,CAcxB,GAAG,IAAI,eAAe,EAAE;MACxB,MAAM,EAAE,MAAM;MACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;MAChC,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;OACnC;KACF,CAAC,CAAC;GACJ;EAAC,OAAO,KAAK,EAAE;IACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;GACpB;AACH,CAAC,CAAC;AAEF,OAAO,EAAc,UAAU,EAAE,CAAC","sourcesContent":["import { fetchWithType } from './api';\nimport { getApiUrl } from './enviroment';\n\nconst base = `${getApiUrl()}/wp-json/felix`;\n\ninterface FelixOrder {\n firstName: string;\n lastName: string;\n street: string;\n zip: string;\n town: string;\n ssn: string;\n email: string;\n phone: string;\n url: string;\n date: string;\n notes?: string;\n wws?: string;\n referral_id?: string;\n id_source?: string;\n id_sub_source?: string;\n products: {\n id: string;\n name: string;\n quantity: number;\n rut: number;\n rot: number;\n }[];\n start_fees: {\n ID: number;\n price: number;\n rut: number;\n rot: number;\n green: number;\n }[];\n creditSafe: {\n firstName: string;\n lastName: string;\n street: string;\n zip: string;\n town: string;\n };\n felixStatus?: 'success' | 'error';\n customer?: string;\n seller_id?: string;\n refferal_id?: string;\n marketing_approval?: number;\n}\n\nconst postPerson = async (felixOrder: FelixOrder) => {\n try {\n return await fetchWithType<\n | {\n response: {\n scriptResult: string;\n scriptError: string;\n };\n messages: [\n {\n code: string;\n message: string;\n },\n ];\n }\n | false\n >(`${base}/createperson`, {\n method: 'POST',\n body: JSON.stringify(felixOrder),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n } catch (error) {\n console.log(error);\n }\n};\n\nexport { FelixOrder, postPerson };\n"]}
@@ -87,7 +87,7 @@ const getRutPrice = (price) => {
87
87
  return Math.ceil(price / 2);
88
88
  };
89
89
  const getRotPrice = (price) => {
90
- return Math.ceil(price / 2);
90
+ return Math.ceil(price * 0.7);
91
91
  };
92
92
  const getGreenPrice = (price) => {
93
93
  return Math.ceil(price * 0.5);
@@ -502,7 +502,11 @@ const HemfixarnaCheckout = class {
502
502
  this.dateError = null;
503
503
  this.date = e.target.value;
504
504
  };
505
- this.handleChangeTerms = () => {
505
+ this.handleChangeTerms = (e) => {
506
+ this.generalError = null;
507
+ this.termsChecked = e.target.checked;
508
+ };
509
+ this.handleChangeItemTerms = () => {
506
510
  this.generalError = null;
507
511
  };
508
512
  this.sendOrder = async () => {
@@ -564,6 +568,7 @@ const HemfixarnaCheckout = class {
564
568
  id_sub_source: this.selectedSubSource ? this.selectedSubSource : '',
565
569
  seller_id: (_a = this.sellerID) !== null && _a !== void 0 ? _a : '',
566
570
  referral_id: (_b = this.RefferalID) !== null && _b !== void 0 ? _b : '',
571
+ marketing_approval: this.termsChecked ? 1 : 0,
567
572
  };
568
573
  const felixOrder = await postPerson(order);
569
574
  if (!felixOrder || !((_d = (_c = felixOrder.response) === null || _c === void 0 ? void 0 : _c.scriptResult) === null || _d === void 0 ? void 0 : _d.includes('OK'))) {
@@ -596,11 +601,6 @@ const HemfixarnaCheckout = class {
596
601
  if (!validDate) {
597
602
  this.dateError = 'Ange ett giltigt datum';
598
603
  }
599
- const checkBoxes = Array.from(this.el.querySelectorAll('input[type="checkbox"]'));
600
- const notValidTerms = checkBoxes.find(i => !i.checked);
601
- if (notValidTerms) {
602
- this.generalError = 'Du måste godkänna villkoren';
603
- }
604
604
  if (state.customer.source && state.selectSource) {
605
605
  if (!this.sellerID) {
606
606
  this.generalError = 'Ange säljare';
@@ -611,7 +611,7 @@ const HemfixarnaCheckout = class {
611
611
  return;
612
612
  }
613
613
  }
614
- if (validDate && !notValidTerms) {
614
+ if (validDate) {
615
615
  this.sendOrder();
616
616
  }
617
617
  };
@@ -627,9 +627,9 @@ const HemfixarnaCheckout = class {
627
627
  return h("hemfixarna-getuser", null);
628
628
  }
629
629
  else if (state.checkoutStep === 2) {
630
- return (h("div", { class: "mb-2" }, h("div", { class: "hemfixarna_addressinfo" }, h("div", null, h("p", null, hideField(state.user.firstName)), h("p", null, hideField(state.user.lastName)), h("p", null, state.user.email), h("p", null, state.user.phone)), h("div", null, h("p", null, hideField(state.user.street)), h("p", null, hideField(state.user.zip)), h("p", null, hideField(state.user.town))), h("button", { onClick: () => (state.checkoutEdit = true) }, "Beh\u00F6ver du \u00E4ndra adressen?")), h("form", { onSubmit: e => this.handleSubmit(e) }, h("div", null, h("img", { src: dateLogo, width: 24 }), h("input", { class: `${this.date.length ? 'input_active' : ''}`, min: new Date().toISOString().split('T')[0], onChange: e => this.handleChangeDate(e), type: "date", name: "date", value: this.date }), h("label", { htmlFor: "date" }, "Tidigaste datum f\u00F6r hembes\u00F6k"), h("img", { src: down, width: 24 })), this.dateError && h("span", null, this.dateError), state.customer.source && state.selectSource ? (h(Fragment, null, h("p", null, "Inloggad som:", h("strong", null, " ", state.customer.source.fieldData.So01_Name)), h("label", null, "S\u00E4ljare (S\u00E4ljarId)", h("input", { type: "text", value: this.sellerID, onChange: e => (this.sellerID = e.target.value) })), h("label", null, "PartnerOrderID (RefferalID)", h("input", { type: "text", value: this.RefferalID, onChange: e => (this.RefferalID = e.target.value) })), ((_a = state.customer.source.sub_sources) === null || _a === void 0 ? void 0 : _a.length) ? (h("div", null, h("select", { onChange: e => (this.selectedSubSource = e.target.value) }, h("option", { disabled: true, selected: true, value: "null" }, "V\u00E4lj underk\u00E4lla"), state.customer.source.sub_sources.map(sub => (h("option", { value: sub['So_SubSource::Sus01_Name'] }, sub['So_SubSource::Sus01_Name'])))))) : (h("p", null, "Det finns inga underk\u00E4llor att v\u00E4lja")))) : null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeTerms(), type: "checkbox" }), h("span", { innerHTML: state.options.terms })), state.cart
630
+ return (h("div", { class: "mb-2" }, h("div", { class: "hemfixarna_addressinfo" }, h("div", null, h("p", null, hideField(state.user.firstName)), h("p", null, hideField(state.user.lastName)), h("p", null, state.user.email), h("p", null, state.user.phone)), h("div", null, h("p", null, hideField(state.user.street)), h("p", null, hideField(state.user.zip)), h("p", null, hideField(state.user.town))), h("button", { onClick: () => (state.checkoutEdit = true) }, "Beh\u00F6ver du \u00E4ndra adressen?")), h("form", { onSubmit: e => this.handleSubmit(e) }, h("div", null, h("img", { src: dateLogo, width: 24 }), h("input", { class: `${this.date.length ? 'input_active' : ''}`, min: new Date().toISOString().split('T')[0], onChange: e => this.handleChangeDate(e), type: "date", name: "date", value: this.date }), h("label", { htmlFor: "date" }, "Tidigaste datum f\u00F6r hembes\u00F6k"), h("img", { src: down, width: 24 })), this.dateError && h("span", null, this.dateError), state.customer.source && state.selectSource ? (h(Fragment, null, h("p", null, "Inloggad som:", h("strong", null, " ", state.customer.source.fieldData.So01_Name)), h("label", null, "S\u00E4ljare (S\u00E4ljarId)", h("input", { type: "text", value: this.sellerID, onChange: e => (this.sellerID = e.target.value) })), h("label", null, "PartnerOrderID (RefferalID)", h("input", { type: "text", value: this.RefferalID, onChange: e => (this.RefferalID = e.target.value) })), ((_a = state.customer.source.sub_sources) === null || _a === void 0 ? void 0 : _a.length) ? (h("div", null, h("select", { onChange: e => (this.selectedSubSource = e.target.value) }, h("option", { disabled: true, selected: true, value: "null" }, "V\u00E4lj underk\u00E4lla"), state.customer.source.sub_sources.map(sub => (h("option", { value: sub['So_SubSource::Sus01_Name'] }, sub['So_SubSource::Sus01_Name'])))))) : (h("p", null, "Det finns inga underk\u00E4llor att v\u00E4lja")))) : null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: e => this.handleChangeTerms(e), type: "checkbox" }), h("span", { innerHTML: state.options.terms })), state.cart
631
631
  .filter(i => { var _a; return (_a = i.terms_checkout) === null || _a === void 0 ? void 0 : _a.length; })
632
- .map(item => (h(Fragment, null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeTerms(), type: "checkbox" }), h("span", null, item.terms_checkout))))), this.generalError && h("span", null, this.generalError), h("div", { class: this.loading ? 'loading' : '' }, h("input", { type: "submit", value: this.loading ? '' : 'Skicka bokning' }), h("img", { width: 20, height: 20, src: loading, alt: "spinner" })))));
632
+ .map(item => (h(Fragment, null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeItemTerms(), type: "checkbox" }), h("span", null, item.terms_checkout))))), this.generalError && h("span", null, this.generalError), h("div", { class: this.loading ? 'loading' : '' }, h("input", { type: "submit", value: this.loading ? '' : 'Skicka bokning' }), h("img", { width: 20, height: 20, src: loading, alt: "spinner" })))));
633
633
  }
634
634
  };
635
635
  this.date = '';
@@ -641,6 +641,7 @@ const HemfixarnaCheckout = class {
641
641
  this.partnerOrderId = null;
642
642
  this.sellerID = null;
643
643
  this.RefferalID = null;
644
+ this.termsChecked = false;
644
645
  }
645
646
  componentWillLoad() {
646
647
  if (Boolean(state.user && state.user.street)) {