hemfixarna-web-components 0.3.1 → 0.9.2
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.
- package/dist/cjs/hemfixarna-address_16.cjs.entry.js +1753 -0
- package/dist/cjs/hemfixarna-address_16.cjs.entry.js.map +1 -0
- package/dist/cjs/hemfixarna-components.cjs.js +28 -0
- package/dist/cjs/hemfixarna-components.cjs.js.map +1 -0
- package/dist/cjs/index-d9e286dc.js +1652 -0
- package/dist/cjs/index-d9e286dc.js.map +1 -0
- package/dist/cjs/index.cjs.js +4 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +24 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/collection/assets/back.svg +3 -0
- package/dist/collection/assets/cart.svg +10 -0
- package/dist/collection/assets/checked.svg +10 -0
- package/dist/collection/assets/close.svg +5 -0
- package/dist/collection/assets/copy.png +0 -0
- package/dist/collection/assets/date.svg +6 -0
- package/dist/collection/assets/down.svg +3 -0
- package/dist/collection/assets/hemfixarna.svg +11 -0
- package/dist/collection/assets/info.svg +5 -0
- package/dist/collection/assets/minus.svg +4 -0
- package/dist/collection/assets/plus.svg +5 -0
- package/dist/collection/collection-manifest.json +27 -0
- package/dist/collection/components/hemfixarna-address/hemfixarna-address.js +67 -0
- package/dist/collection/components/hemfixarna-address/hemfixarna-address.js.map +1 -0
- package/dist/collection/components/hemfixarna-box/hemfixarna-box.js +97 -0
- package/dist/collection/components/hemfixarna-box/hemfixarna-box.js.map +1 -0
- package/dist/{hemfixarna-components/hemfixarna-breadcrumbs.entry.js → collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js} +46 -11
- package/dist/collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js.map +1 -0
- package/dist/collection/components/hemfixarna-byggmax/hemfixarna-byggmax.css +0 -0
- package/dist/collection/components/hemfixarna-byggmax/hemfixarna-byggmax.js +50 -0
- package/dist/collection/components/hemfixarna-byggmax/hemfixarna-byggmax.js.map +1 -0
- package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js +41 -0
- package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js.map +1 -0
- package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js +18 -0
- package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js.map +1 -0
- package/dist/collection/components/hemfixarna-checkout/hemfixarna-checkout.js +92 -0
- package/dist/collection/components/hemfixarna-checkout/hemfixarna-checkout.js.map +1 -0
- package/dist/collection/components/hemfixarna-component/hemfixarna-component.js +221 -0
- package/dist/collection/components/hemfixarna-component/hemfixarna-component.js.map +1 -0
- package/dist/collection/components/hemfixarna-component/hemfixarna.css +752 -0
- package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.css +118 -0
- package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js +76 -0
- package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js.map +1 -0
- package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js +84 -0
- package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js.map +1 -0
- package/dist/{hemfixarna-components/hemfixarna-info.entry.js → collection/components/hemfixarna-info/hemfixarna-info.js} +27 -11
- package/dist/collection/components/hemfixarna-info/hemfixarna-info.js.map +1 -0
- package/dist/collection/components/hemfixarna-order/hemfixarna-order.js +50 -0
- package/dist/collection/components/hemfixarna-order/hemfixarna-order.js.map +1 -0
- package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js +80 -0
- package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js.map +1 -0
- package/dist/{hemfixarna-components/hemfixarna-product.entry.js → collection/components/hemfixarna-product/hemfixarna-product.js} +15 -16
- package/dist/collection/components/hemfixarna-product/hemfixarna-product.js.map +1 -0
- package/dist/collection/components/hemfixarna-service/hemfixarna-service.js +18 -0
- package/dist/collection/components/hemfixarna-service/hemfixarna-service.js.map +1 -0
- package/dist/collection/components/hemfixarna-start/hemfixarna-start.js +41 -0
- package/dist/collection/components/hemfixarna-start/hemfixarna-start.js.map +1 -0
- package/dist/collection/index.js +2 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/store/index.js +25 -0
- package/dist/collection/store/index.js.map +1 -0
- package/dist/{hemfixarna-components/index-2bf8566c.js → collection/types/index.js} +3 -6
- package/dist/collection/types/index.js.map +1 -0
- package/dist/collection/utils/api.js +41 -0
- package/dist/collection/utils/api.js.map +1 -0
- package/dist/{hemfixarna-components/calc-a9ece205.js → collection/utils/calc.js} +36 -6
- package/dist/collection/utils/calc.js.map +1 -0
- package/dist/collection/utils/creditSafe.js +18 -0
- package/dist/collection/utils/creditSafe.js.map +1 -0
- package/dist/collection/utils/felixFunctions.js +189 -0
- package/dist/collection/utils/felixFunctions.js.map +1 -0
- package/dist/collection/utils/form.js +7 -0
- package/dist/collection/utils/form.js.map +1 -0
- package/dist/esm/hemfixarna-address_16.entry.js +1734 -0
- package/dist/esm/hemfixarna-address_16.entry.js.map +1 -0
- package/dist/esm/hemfixarna-components.js +23 -0
- package/dist/esm/hemfixarna-components.js.map +1 -0
- package/dist/esm/index-ca1aada9.js +1621 -0
- package/dist/esm/index-ca1aada9.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +20 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/hemfixarna-components/hemfixarna-components.esm.js +1 -162
- package/dist/hemfixarna-components/hemfixarna-components.esm.js.map +1 -1
- package/dist/hemfixarna-components/index.esm.js +0 -1
- package/dist/hemfixarna-components/index.esm.js.map +1 -1
- package/dist/hemfixarna-components/p-8829e98e.js +3 -0
- package/dist/hemfixarna-components/p-8829e98e.js.map +1 -0
- package/dist/hemfixarna-components/p-c05e2af1.entry.js +2 -0
- package/dist/hemfixarna-components/p-c05e2af1.entry.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/components/hemfixarna-address/hemfixarna-address.d.ts +1 -0
- package/dist/types/components/hemfixarna-cart/hemfixarna-cart.d.ts +1 -9
- package/dist/types/components/hemfixarna-checkout/hemfixarna-checkout.d.ts +3 -1
- package/dist/types/components/hemfixarna-getuser/hemfixarna-getuser.d.ts +1 -1
- package/dist/types/components/hemfixarna-order/hemfixarna-order.d.ts +3 -0
- package/dist/types/components/hemfixarna-orderrows/hemfixarna-orderrows.d.ts +8 -0
- package/dist/types/components.d.ts +19 -0
- package/dist/types/store/index.d.ts +2 -6
- package/dist/types/types/index.d.ts +18 -7
- package/dist/types/utils/api.d.ts +20 -2
- package/dist/types/utils/calc.d.ts +5 -1
- package/dist/types/utils/creditSafe.d.ts +3 -0
- package/dist/types/utils/form.d.ts +2 -0
- package/package.json +2 -1
- package/dist/hemfixarna-components/api-3228fe30.js +0 -28
- package/dist/hemfixarna-components/api-3228fe30.js.map +0 -1
- package/dist/hemfixarna-components/app-globals-0f993ce5.js +0 -5
- package/dist/hemfixarna-components/app-globals-0f993ce5.js.map +0 -1
- package/dist/hemfixarna-components/calc-a9ece205.js.map +0 -1
- package/dist/hemfixarna-components/css-shim-62d2171c.js +0 -6
- package/dist/hemfixarna-components/css-shim-62d2171c.js.map +0 -1
- package/dist/hemfixarna-components/dom-46a68c9b.js +0 -75
- package/dist/hemfixarna-components/dom-46a68c9b.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-address.entry.js +0 -52
- package/dist/hemfixarna-components/hemfixarna-address.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-box.entry.js +0 -35
- package/dist/hemfixarna-components/hemfixarna-box.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-breadcrumbs.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js +0 -20
- package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-cart.entry.js +0 -82
- package/dist/hemfixarna-components/hemfixarna-cart.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-category.entry.js +0 -21
- package/dist/hemfixarna-components/hemfixarna-category.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-checkout.entry.js +0 -54
- package/dist/hemfixarna-components/hemfixarna-checkout.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-component.entry.js +0 -133
- package/dist/hemfixarna-components/hemfixarna-component.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-demo.entry.js +0 -65
- package/dist/hemfixarna-components/hemfixarna-demo.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-getuser.entry.js +0 -410
- package/dist/hemfixarna-components/hemfixarna-getuser.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-info.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-order.entry.js +0 -24
- package/dist/hemfixarna-components/hemfixarna-order.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-product.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-service.entry.js +0 -21
- package/dist/hemfixarna-components/hemfixarna-service.entry.js.map +0 -1
- package/dist/hemfixarna-components/hemfixarna-start.entry.js +0 -18
- package/dist/hemfixarna-components/hemfixarna-start.entry.js.map +0 -1
- package/dist/hemfixarna-components/index-2bf8566c.js.map +0 -1
- package/dist/hemfixarna-components/index-59ed730c.js +0 -3397
- package/dist/hemfixarna-components/index-59ed730c.js.map +0 -1
- package/dist/hemfixarna-components/index-75ed3bb8.js +0 -216
- package/dist/hemfixarna-components/index-75ed3bb8.js.map +0 -1
- package/dist/hemfixarna-components/shadow-css-05e0c1f4.js +0 -389
- package/dist/hemfixarna-components/shadow-css-05e0c1f4.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hemfixarna-product.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-product/hemfixarna-product.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOjE,MAAM,OAAO,iBAAiB;;kBACF,CAAC;;EAE3B,UAAU;IACR,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IAC9E,IAAI,aAAa,EAAE;MACjB,aAAa,CAAC,MAAM,EAAE,CAAC;MACvB,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;KAC9B;SAAM;MACL,KAAK,CAAC,IAAI,GAAG;QACX,GAAG,KAAK,CAAC,IAAI;QACb;UACE,EAAE,EAAE,KAAK,CAAC,eAAe,CAAC,EAAE;UAC5B,GAAG,EAAE,KAAK,CAAC,eAAe,CAAC,GAAG;UAC9B,GAAG,EAAE,KAAK,CAAC,eAAe,CAAC,GAAG;UAC9B,MAAM,EAAE,CAAC;UACT,KAAK,EAAE,EAAE;UACT,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,KAAK;UAClC,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,UAAU;UACtC,SAAS,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,SAAS;UAC3C,cAAc,EAAE,KAAK,CAAC,eAAe,CAAC,cAAc;UACpD,mBAAmB,EAAE,KAAK,CAAC,eAAe,CAAC,mBAAmB;UAC9D,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI;SAC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AC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAI;kBACpH,gBAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAQ;kBACvC,WAAK,KAAK,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAI,CACpG,CACH,CACN,CAAC,CACD;UACL,UAAI,KAAK,EAAC,2BAA2B;;YAAS,IAAI,CAAC,aAAa,EAAE;kBAAS;UAC3E,cAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,kBAAkB,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,WAElG;UACR,KAAK,CAAC,OAAO,IAAI,uBAAiB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,GAAI,CAC5D,CACF,CACF,CACP,CAAC;EACJ,CAAC;;;;;CACF","sourcesContent":["import { Component, State, getAssetPath, h } from '@stencil/core';\nimport state from '../../store';\nimport { getPartPrice, getProductPrice } from '../../utils/calc';\nimport { Icon, Part } from '../../types';\n\n@Component({\n tag: 'hemfixarna-product',\n shadow: false,\n})\nexport class HemfixarnaProduct {\n @State() amount: number = 0;\n\n addProduct() {\n const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);\n if (productInCart) {\n productInCart.amount++;\n state.cart = [...state.cart];\n } else {\n state.cart = [\n ...state.cart,\n {\n id: state.selectedProduct.ID,\n rut: state.selectedProduct.rut,\n rot: state.selectedProduct.rot,\n amount: 1,\n parts: [],\n price: state.selectedProduct.price,\n name: state.selectedProduct.post_title,\n start_fee: !state.selectedProduct.start_fee,\n terms_checkout: state.selectedProduct.terms_checkout,\n terms_show_checkbox: state.selectedProduct.terms_show_checkbox,\n icon: state.selectedProduct.icon,\n },\n ];\n }\n }\n\n removeProduct() {\n const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);\n if (productInCart && productInCart.amount > 1) {\n productInCart.amount--;\n state.cart = [...state.cart];\n } else {\n state.cart = state.cart.filter(p => p.id !== state.selectedProduct.ID);\n }\n }\n\n //Handle cart and parts\n addPart(part: Part) {\n const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);\n if (productInCart) {\n const partInCart = productInCart.parts.find(sp => sp.id === part.ID);\n if (partInCart) {\n partInCart.amount++;\n productInCart.parts = [...productInCart.parts];\n } else {\n productInCart.parts = [...productInCart.parts, { id: part.ID, amount: 1, price: part.price, name: part.post_title }];\n }\n state.cart = [...state.cart.filter(p => p.id !== productInCart.id), productInCart];\n }\n }\n\n removePart(part: Part) {\n const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);\n if (productInCart) {\n const partInCart = productInCart.parts.find(sp => sp.id === part.ID);\n if (partInCart && partInCart.amount > 1) {\n partInCart.amount--;\n productInCart.parts = [...productInCart.parts];\n } else {\n productInCart.parts = productInCart.parts.filter(sp => sp.id !== part.ID);\n }\n state.cart = [...state.cart.filter(p => p.id !== productInCart.id), productInCart];\n }\n }\n\n goToCart() {\n const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);\n if (productInCart) {\n state.step = 5;\n }\n }\n\n getAmount() {\n return state.cart.find(p => p.id === state.selectedProduct.ID)?.amount || 0;\n }\n\n getPartAmount(partId: number) {\n const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);\n return productInCart?.parts.find(sp => sp.id === partId)?.amount || 0;\n }\n\n getTotalPrice() {\n let price = 0;\n const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);\n if (productInCart) {\n const partsPrice = productInCart.parts.reduce((acc, curr) => {\n const part = state.selectedProduct.parts.find(p => p.ID === curr.id);\n if (part) {\n return acc + part.price * curr.amount;\n }\n return acc;\n }, 0);\n price = state.selectedProduct.price * productInCart.amount + partsPrice;\n } else {\n price = state.selectedProduct.price;\n }\n return getProductPrice(state.selectedProduct, price);\n }\n\n render() {\n const checked = getAssetPath(`./assets/checked.svg`);\n const plus = getAssetPath(`./assets/plus.svg`);\n const minus = getAssetPath(`./assets/minus.svg`);\n\n return (\n <div class=\"hemfixarna_product\">\n <div class=\"hemfixarna_product--top\">\n {state.selectedProduct.icon && (\n <img width={80} src={(state.selectedProduct.icon as Icon).url ?? (state.selectedProduct.icon as string)} alt={state.selectedProduct.post_title} />\n )}\n <div>\n <h1>{state.selectedProduct.post_title}</h1>\n <h2>Från: {getProductPrice(state.selectedProduct)} kr</h2>\n </div>\n </div>\n\n <div class=\"hemfixarna_product--grid\">\n <div class=\"hemfixarna_product--left\">\n {state.selectedProduct.list?.length && (\n <ul class=\"hemfixarna_features\">\n {state.selectedProduct.list.map(l => (\n <li key={l.bullet}>\n <img src={checked} alt=\"checked\" />\n <p>{l.bullet}</p>\n </li>\n ))}\n </ul>\n )}\n <p class=\"hemfixarna_terms\">\n <strong>OBS! </strong>\n <span innerHTML={state.selectedProduct.terms}></span>\n </p>\n </div>\n <div class=\"hemfixarna_product--right\">\n <ul>\n <li class=\"hemfixarna_product--item\">\n <div>\n <p>Antal {state.selectedProduct.post_title}</p>\n <p class=\"hemfixarna_product--price\">{getProductPrice(state.selectedProduct)}kr/st</p>\n </div>\n <div class=\"hemfixarna_counter\">\n <img class={`${this.getAmount() === 0 ? 'disabled' : ''}`} src={minus} onClick={() => this.removeProduct()} />\n <span>{this.getAmount()}</span>\n <img src={plus} onClick={() => this.addProduct()} />\n </div>\n </li>\n {state.selectedProduct.parts?.length &&\n state.selectedProduct.parts.map(p => (\n <li class=\"hemfixarna_part\">\n <div>\n <p>{p.post_title}</p>\n <p class=\"hemfixarna_product--price\">{getPartPrice(p, state.selectedProduct)}kr/st</p>\n </div>\n <div class=\"hemfixarna_counter\">\n <img class={`${this.getPartAmount(p.ID) === 0 ? 'disabled' : ''}`} src={minus} onClick={() => this.removePart(p)} />\n <span>{this.getPartAmount(p.ID)}</span>\n <img class={`${this.getAmount() === 0 ? 'disabled' : ''}`} src={plus} onClick={() => this.addPart(p)} />\n </div>\n </li>\n ))}\n </ul>\n <h4 class=\"hemfixarna_product--total\">Totalt {this.getTotalPrice()} kr</h4>\n <button onClick={() => this.goToCart()} class={`hemfixarna_buy ${this.getAmount() === 0 ? 'disabled' : ''}`}>\n Boka\n </button>\n {state.options && <hemfixarna-info list={state.options.trust} />}\n </div>\n </div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import state from '../../store';
|
|
3
|
+
export class HemfixarnaService {
|
|
4
|
+
setSelectedProduct(product) {
|
|
5
|
+
state.selectedProduct = product;
|
|
6
|
+
state.step = 4;
|
|
7
|
+
}
|
|
8
|
+
render() {
|
|
9
|
+
return (h("div", null, h("h2", null, state.selectedService.post_title), h("div", { class: "hemfixarna_categories--wrapper" }, h("div", null, h("ul", { class: "hemfixarna_categories" }, state.selectedService.products
|
|
10
|
+
.sort((a, b) => (a.post_title < b.post_title ? -1 : 1))
|
|
11
|
+
.map(p => {
|
|
12
|
+
var _a;
|
|
13
|
+
return (h("hemfixarna-box", { post: p, icon: (_a = p.icon.url) !== null && _a !== void 0 ? _a : p.icon, postTitle: p.post_title }));
|
|
14
|
+
}))), h("hemfixarna-info", { list: state.options.trust }))));
|
|
15
|
+
}
|
|
16
|
+
static get is() { return "hemfixarna-service"; }
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=hemfixarna-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hemfixarna-service.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-service/hemfixarna-service.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,MAAM,aAAa,CAAC;AAMhC,MAAM,OAAO,iBAAiB;EAC5B,kBAAkB,CAAC,OAAgB;IACjC,KAAK,CAAC,eAAe,GAAG,OAAO,CAAC;IAChC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;EACjB,CAAC;EAED,MAAM;IACJ,OAAO,CACL;MACE,cAAK,KAAK,CAAC,eAAe,CAAC,UAAU,CAAM;MAC3C,WAAK,KAAK,EAAC,gCAAgC;QACzC;UACE,UAAI,KAAK,EAAC,uBAAuB,IAC9B,KAAK,CAAC,eAAe,CAAC,QAAQ;aAC5B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aACtD,GAAG,CAAC,CAAC,CAAC,EAAE;;YAAC,OAAA,CACR,sBAAgB,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAC,CAAC,CAAC,IAAa,CAAC,GAAG,mCAAK,CAAC,CAAC,IAAe,EAAE,SAAS,EAAE,CAAC,CAAC,UAAU,GAAmB,CACtH,CAAA;WAAA,CAAC,CACD,CACD;QACN,uBAAiB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,GAAI,CAC1C,CACF,CACP,CAAC;EACJ,CAAC;;CACF","sourcesContent":["import { Component, h } from '@stencil/core';\nimport { Icon, Product } from '../../types';\nimport state from '../../store';\n\n@Component({\n tag: 'hemfixarna-service',\n shadow: false,\n})\nexport class HemfixarnaService {\n setSelectedProduct(product: Product) {\n state.selectedProduct = product;\n state.step = 4;\n }\n\n render() {\n return (\n <div>\n <h2>{state.selectedService.post_title}</h2>\n <div class=\"hemfixarna_categories--wrapper\">\n <div>\n <ul class=\"hemfixarna_categories\">\n {state.selectedService.products\n .sort((a, b) => (a.post_title < b.post_title ? -1 : 1))\n .map(p => (\n <hemfixarna-box post={p} icon={(p.icon as Icon).url ?? (p.icon as string)} postTitle={p.post_title}></hemfixarna-box>\n ))}\n </ul>\n </div>\n <hemfixarna-info list={state.options.trust} />\n </div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import state from '../../store';
|
|
3
|
+
export class HemfixarnaGrid {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.tree = undefined;
|
|
6
|
+
}
|
|
7
|
+
render() {
|
|
8
|
+
return (h("div", null, h("h2", null, "Alla tj\u00E4nster"), h("div", { class: "hemfixarna_categories--wrapper" }, h("ul", { class: "hemfixarna_categories" }, this.tree.sub_cats
|
|
9
|
+
.sort((a, b) => (a.name < b.name ? -1 : 1))
|
|
10
|
+
.map(c => {
|
|
11
|
+
var _a;
|
|
12
|
+
return (h("hemfixarna-box", { post: c, icon: (_a = c.icon.url) !== null && _a !== void 0 ? _a : c.icon, postTitle: c.name }));
|
|
13
|
+
})), h("hemfixarna-info", { list: state.options.trust }))));
|
|
14
|
+
}
|
|
15
|
+
static get is() { return "hemfixarna-start"; }
|
|
16
|
+
static get properties() {
|
|
17
|
+
return {
|
|
18
|
+
"tree": {
|
|
19
|
+
"type": "unknown",
|
|
20
|
+
"mutable": false,
|
|
21
|
+
"complexType": {
|
|
22
|
+
"original": "Category",
|
|
23
|
+
"resolved": "Category",
|
|
24
|
+
"references": {
|
|
25
|
+
"Category": {
|
|
26
|
+
"location": "import",
|
|
27
|
+
"path": "../../types"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"required": false,
|
|
32
|
+
"optional": false,
|
|
33
|
+
"docs": {
|
|
34
|
+
"tags": [],
|
|
35
|
+
"text": ""
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=hemfixarna-start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hemfixarna-start.js","sourceRoot":"","sources":["../../../src/components/hemfixarna-start/hemfixarna-start.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,MAAM,aAAa,CAAC;AAMhC,MAAM,OAAO,cAAc;;;;EAGzB,MAAM;IACJ,OAAO,CACL;MACE,mCAAsB;MACtB,WAAK,KAAK,EAAC,gCAAgC;QACzC,UAAI,KAAK,EAAC,uBAAuB,IAC9B,IAAI,CAAC,IAAI,CAAC,QAAQ;WAChB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;WAC1C,GAAG,CAAC,CAAC,CAAC,EAAE;;UAAC,OAAA,CACR,sBAAgB,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAC,CAAC,CAAC,IAAa,CAAC,GAAG,mCAAK,CAAC,CAAC,IAAe,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,GAAmB,CAChH,CAAA;SAAA,CAAC,CACD;QACL,uBAAiB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,GAAI,CAC1C,CACF,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, h } from '@stencil/core';\nimport { Category, Icon } from '../../types';\nimport state from '../../store';\n\n@Component({\n tag: 'hemfixarna-start',\n shadow: false,\n})\nexport class HemfixarnaGrid {\n @Prop() tree: Category;\n\n render() {\n return (\n <div>\n <h2>Alla tjänster</h2>\n <div class=\"hemfixarna_categories--wrapper\">\n <ul class=\"hemfixarna_categories\">\n {this.tree.sub_cats\n .sort((a, b) => (a.name < b.name ? -1 : 1))\n .map(c => (\n <hemfixarna-box post={c} icon={(c.icon as Icon).url ?? (c.icon as string)} postTitle={c.name}></hemfixarna-box>\n ))}\n </ul>\n <hemfixarna-info list={state.options.trust} />\n </div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC","sourcesContent":["export * from './components';\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createStore } from '@stencil/store';
|
|
2
|
+
const { state, onChange, } = createStore({
|
|
3
|
+
step: 1,
|
|
4
|
+
checkoutStep: 1,
|
|
5
|
+
checkoutEdit: false,
|
|
6
|
+
selectedCategory: null,
|
|
7
|
+
selectedService: null,
|
|
8
|
+
selectedProduct: null,
|
|
9
|
+
cart: [],
|
|
10
|
+
business: 'undefined',
|
|
11
|
+
options: null,
|
|
12
|
+
rut: true,
|
|
13
|
+
rot: true,
|
|
14
|
+
token: null,
|
|
15
|
+
user: null,
|
|
16
|
+
modal: null,
|
|
17
|
+
});
|
|
18
|
+
onChange('cart', cart => {
|
|
19
|
+
window.sessionStorage.setItem(`hemfixarna-${state.business}-cart`, JSON.stringify(cart));
|
|
20
|
+
});
|
|
21
|
+
onChange('user', user => {
|
|
22
|
+
window.sessionStorage.setItem(`hemfixarna-${state.business}-user`, JSON.stringify(user));
|
|
23
|
+
});
|
|
24
|
+
export default state;
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAwB7C,MAAM,EACJ,KAAK,EACL,QAAQ,GACT,GAGG,WAAW,CAAC;EACd,IAAI,EAAE,CAAC;EACP,YAAY,EAAE,CAAC;EACf,YAAY,EAAE,KAAK;EACnB,gBAAgB,EAAE,IAAI;EACtB,eAAe,EAAE,IAAI;EACrB,eAAe,EAAE,IAAI;EACrB,IAAI,EAAE,EAAE;EACR,QAAQ,EAAE,WAAW;EACrB,OAAO,EAAE,IAAI;EACb,GAAG,EAAE,IAAI;EACT,GAAG,EAAE,IAAI;EACT,KAAK,EAAE,IAAI;EACX,IAAI,EAAE,IAAI;EACV,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC;AAEH,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;EACtB,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,cAAc,KAAK,CAAC,QAAQ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3F,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;EACtB,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,cAAc,KAAK,CAAC,QAAQ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3F,CAAC,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC","sourcesContent":["import { createStore } from '@stencil/store';\nimport { OnChangeHandler } from '@stencil/store/dist/types';\nimport { Business, CartItem, Category, Product, Service, User, WpOptions } from '../types';\n\ntype StateType = {\n step: number;\n selectedCategory: Category | null;\n selectedService: Service | null;\n selectedProduct: Product | null;\n cart: Array<CartItem>;\n business: Business | 'undefined';\n options: WpOptions | null;\n rut: boolean;\n rot: boolean;\n token: string | null;\n checkoutStep: number;\n checkoutEdit: boolean;\n user: User | null;\n modal: {\n title: string;\n text: string[];\n } | null;\n};\n\nconst {\n state,\n onChange,\n}: {\n state: StateType;\n onChange: OnChangeHandler<StateType>;\n} = createStore({\n step: 1,\n checkoutStep: 1,\n checkoutEdit: false,\n selectedCategory: null,\n selectedService: null,\n selectedProduct: null,\n cart: [],\n business: 'undefined',\n options: null,\n rut: true,\n rot: true,\n token: null,\n user: null,\n modal: null,\n});\n\nonChange('cart', cart => {\n window.sessionStorage.setItem(`hemfixarna-${state.business}-cart`, JSON.stringify(cart));\n});\n\nonChange('user', user => {\n window.sessionStorage.setItem(`hemfixarna-${state.business}-user`, JSON.stringify(user));\n});\n\nexport default state;\n"]}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
var Business;
|
|
1
|
+
export var Business;
|
|
2
2
|
(function (Business) {
|
|
3
3
|
Business["byggmax"] = "byggmax";
|
|
4
4
|
})(Business || (Business = {}));
|
|
5
|
-
var TopCategory;
|
|
5
|
+
export var TopCategory;
|
|
6
6
|
(function (TopCategory) {
|
|
7
7
|
TopCategory["byggmax"] = "category/bygg";
|
|
8
8
|
})(TopCategory || (TopCategory = {}));
|
|
9
|
-
|
|
10
|
-
export { Business as B, TopCategory as T };
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=index-2bf8566c.js.map
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AA8IA,MAAM,CAAN,IAAY,QAEX;AAFD,WAAY,QAAQ;EAClB,+BAAmB,CAAA;AACrB,CAAC,EAFW,QAAQ,KAAR,QAAQ,QAEnB;AAED,MAAM,CAAN,IAAY,WAEX;AAFD,WAAY,WAAW;EACrB,wCAAyB,CAAA;AAC3B,CAAC,EAFW,WAAW,KAAX,WAAW,QAEtB","sourcesContent":["type Icon = {\n url: string;\n};\n\ninterface Part {\n ID: number;\n post_author: number;\n post_date: Date;\n post_date_gmt: Date;\n post_content: string;\n post_title: string;\n post_excerpt: string;\n post_status: string;\n comment_status: string;\n ping_status: string;\n post_password: string;\n post_name: string;\n to_ping: string;\n pinged: string;\n post_modified: Date;\n post_modified_gmt: Date;\n post_content_filtered: string;\n post_parent: 0 | 1;\n guid: string;\n menu_order: 0;\n post_type: string;\n post_mime_type: string;\n comment_count: number;\n filter: string;\n price: number;\n}\n\ninterface Product {\n ID: number;\n post_author: string;\n post_date: Date;\n post_date_gmt: Date;\n post_content: string;\n post_title: string;\n post_excerpt: string;\n post_status: string;\n comment_status: string;\n ping_status: string;\n post_password: string;\n post_name: string;\n to_ping: string;\n pinged: string;\n post_modified: Date;\n post_modified_gmt: Date;\n post_content_filtered: string;\n post_parent: 0;\n guid: string;\n menu_order: 0;\n post_type: string;\n post_mime_type: string;\n comment_count: 0;\n filter: string;\n price: number;\n icon?: Icon | string;\n parts?: Array<Part>;\n list: Array<{ bullet: string }>;\n terms: string;\n terms_checkout: string;\n terms_show_checkbox: boolean;\n rut: boolean;\n rot: boolean;\n start_fee: boolean;\n}\n\ninterface Service {\n ID: 41857;\n icon?: Icon | string;\n post_author: 34419;\n post_date: Date;\n post_date_gmt: Date;\n post_content: string;\n post_title: string;\n post_excerpt: string;\n post_status: string;\n comment_status: string;\n ping_status: string;\n post_password: string;\n post_name: string;\n to_ping: string;\n pinged: string;\n post_modified: Date;\n post_modified_gmt: Date;\n post_content_filtered: string;\n post_parent: 0;\n guid: string;\n menu_order: 0;\n post_type: 'service';\n post_mime_type: string;\n comment_count: 0;\n filter: string;\n products: Array<Product>;\n}\n\ninterface Category {\n count: number;\n description: string;\n name: string;\n icon?: Icon | string;\n parent: 0 | 1;\n slug: string;\n taxonomy: 'service_cat';\n term_group: 0 | 1;\n term_id: number;\n term_order: string;\n term_taxonomy_id: number;\n sub_cats?: Array<Category>;\n services?: Array<Service>;\n}\n\ninterface WpOptions {\n link: { title: string; url: string };\n trust: { trust_badge: string }[];\n thank_you_image: string;\n start_fee: number;\n terms: string;\n}\ninterface CartPart {\n id: number;\n amount: number;\n price: number;\n name: string;\n}\n\ninterface CartItem {\n id: number;\n price: number;\n name: string;\n amount: number;\n parts: CartPart[];\n rut: boolean;\n rot: boolean;\n start_fee: boolean;\n terms_checkout: string;\n terms_show_checkbox: boolean;\n icon?: Icon | string;\n}\n\nexport enum Business {\n byggmax = 'byggmax',\n}\n\nexport enum TopCategory {\n byggmax = 'category/bygg',\n}\n\ninterface User {\n email: string;\n phone: string;\n ssn: string;\n firstName?: string;\n lastName?: string;\n street?: string;\n zip?: string;\n town?: string;\n}\n\nexport type { User, Category, Product, Service, Part, WpOptions, CartItem, CartPart, Icon };\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const base = process.env.API_URL ? `${process.env.API_URL}/wp-json/headless` : 'https://hemfixarna.se/wp-json/headless';
|
|
2
|
+
const getTaxonomy = async (endpoint) => {
|
|
3
|
+
if (!endpoint) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const type = endpoint.split('/')[0];
|
|
7
|
+
const slug = endpoint.split('/')[1];
|
|
8
|
+
try {
|
|
9
|
+
const res = await fetch(`${base}/${type}/${slug}`);
|
|
10
|
+
return await res.json();
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.log(error);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const getOptions = async () => {
|
|
17
|
+
try {
|
|
18
|
+
const res = await fetch(`${base}/webcoptions`);
|
|
19
|
+
return (await res.json());
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.log(error);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const postOrder = async (data) => {
|
|
26
|
+
try {
|
|
27
|
+
const res = await fetch(`${base}/weborder`, {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
body: JSON.stringify(data),
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return (await res.json());
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.log(error);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export { getTaxonomy, getOptions, postOrder };
|
|
41
|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,EAAE,MAAM;MACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;MAC1B,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;OACnC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAA+E,CAAC;GACzG;EAAC,OAAO,KAAK,EAAE;IACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;GACpB;AACH,CAAC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { Business, WpOptions } from '../types';\n\nconst base = process.env.API_URL ? `${process.env.API_URL}/wp-json/headless` : 'https://hemfixarna.se/wp-json/headless';\n\nconst getTaxonomy = async (endpoint: string) => {\n if (!endpoint) {\n return;\n }\n const type = endpoint.split('/')[0];\n const slug = endpoint.split('/')[1];\n try {\n const res = await fetch(`${base}/${type}/${slug}`);\n return await res.json();\n } catch (error) {\n console.log(error);\n }\n};\n\nconst getOptions = async () => {\n try {\n const res = await fetch(`${base}/webcoptions`);\n return (await res.json()) as WpOptions;\n } catch (error) {\n console.log(error);\n }\n};\n\nexport interface PostOrderData {\n name: string;\n customer: Business;\n phone: string;\n social_security_number: string;\n email: string;\n address: string;\n earliest_visit_date: string;\n order_items: string;\n start_fee: string;\n total: number;\n}\n\nconst postOrder = async (data: PostOrderData) => {\n try {\n const res = await fetch(`${base}/weborder`, {\n method: 'POST',\n body: JSON.stringify(data),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n return (await res.json()) as { message: string; post_id: number; data: PostOrderData; status?: number };\n } catch (error) {\n console.log(error);\n }\n};\n\nexport { getTaxonomy, getOptions, postOrder };\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import state from '../store';
|
|
3
2
|
const getRutPrice = (price) => {
|
|
4
3
|
return Math.ceil(price / 2);
|
|
5
4
|
};
|
|
@@ -79,7 +78,38 @@ const getStartFee = () => {
|
|
|
79
78
|
return { rut: 0, rot: 0, length: 0 };
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
const getItemPrice = (item) => {
|
|
82
|
+
const partsPrice = item.parts.reduce((acc, curr) => {
|
|
83
|
+
return acc + curr.price * curr.amount;
|
|
84
|
+
}, 0);
|
|
85
|
+
return getProductPrice(item, item.price * item.amount + partsPrice);
|
|
86
|
+
};
|
|
87
|
+
const calculateRot = () => {
|
|
88
|
+
const totalWithRot = state.cart.reduce((acc, curr) => {
|
|
89
|
+
return curr.rot ? acc + getItemPrice(curr) : acc;
|
|
90
|
+
}, 0) + getStartFee().rot;
|
|
91
|
+
const totalWithoutRot = state.cart.reduce((acc, curr) => {
|
|
92
|
+
const partsPrice = curr.parts.reduce((acc, curr) => {
|
|
93
|
+
return acc + curr.price * curr.amount;
|
|
94
|
+
}, 0);
|
|
95
|
+
return curr.rot ? acc + curr.price * curr.amount + partsPrice : acc;
|
|
96
|
+
}, 0) + Number(state.options.start_fee);
|
|
97
|
+
return totalWithoutRot - totalWithRot;
|
|
98
|
+
};
|
|
99
|
+
const calculateRut = () => {
|
|
100
|
+
const totalWithRut = state.cart.reduce((acc, curr) => {
|
|
101
|
+
return curr.rut ? acc + getItemPrice(curr) : acc;
|
|
102
|
+
}, 0) + getStartFee().rut;
|
|
103
|
+
const totalWithoutRut = state.cart.reduce((acc, curr) => {
|
|
104
|
+
const partsPrice = curr.parts.reduce((acc, curr) => {
|
|
105
|
+
return acc + curr.price * curr.amount;
|
|
106
|
+
}, 0);
|
|
107
|
+
return curr.rut ? acc + curr.price * curr.amount + partsPrice : acc;
|
|
108
|
+
}, 0) + Number(state.options.start_fee);
|
|
109
|
+
return totalWithoutRut - totalWithRut;
|
|
110
|
+
};
|
|
111
|
+
const getTotalPrice = () => {
|
|
112
|
+
return state.cart.reduce((acc, curr) => acc + getItemPrice(curr), 0) + getStartFee().rot + getStartFee().rut;
|
|
113
|
+
};
|
|
114
|
+
export { getProductPriceWithRotAndRut, getProductPrice, getRotPrice, getRutPrice, getRotStartFee, getRutStartFee, getPartPrice, getStartFee, calculateRot, calculateRut, getItemPrice, getTotalPrice, };
|
|
115
|
+
//# sourceMappingURL=calc.js.map
|
|
@@ -0,0 +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,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE;EACpC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,GAAG,EAAE;EAC1B,IAAI,CAAC,KAAK,CAAC,OAAO;IAAE,OAAO,GAAG,CAAC;EAC/B,IAAI,KAAK,CAAC,GAAG,EAAE;IACb,OAAO,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;GAC7C;OAAM;IACL,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;GAChC;AACH,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,GAAG,EAAE;EAC1B,IAAI,CAAC,KAAK,CAAC,OAAO;IAAE,OAAO,GAAG,CAAC;EAC/B,IAAI,KAAK,CAAC,GAAG,EAAE;IACb,OAAO,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;GAC7C;OAAM;IACL,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;GAChC;AACH,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,OAA2B,EAAE,KAAc,EAAE,SAAiB,CAAC,EAA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AEF,OAAO,EACL,4BAA4B,EAC5B,eAAe,EACf,WAAW,EACX,WAAW,EACX,cAAc,EACd,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,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 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 {\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 {\n return part.price * amount;\n }\n};\n\nconst getStartFee = () => {\n if (!state.cart) return { rut: 0, rot: 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 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 if (hasRut && hasRot) {\n return { rut: rutPrice, rot: rotPrice, length: 2 };\n } else if (hasRut) {\n return { rut: rutPrice, rot: 0, length: 1 };\n } else if (hasRot) {\n return { rut: 0, rot: rotPrice, length: 1 };\n } else {\n return { rut: 0, rot: 0, length: 0 };\n }\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) + getStartFee().rot;\n const totalWithoutRot =\n state.cart.reduce((acc, curr) => {\n const partsPrice = curr.parts.reduce((acc, curr) => {\n return acc + curr.price * curr.amount;\n }, 0);\n return curr.rot ? acc + curr.price * curr.amount + partsPrice : acc;\n }, 0) + Number(state.options.start_fee);\n return totalWithoutRot - totalWithRot;\n};\n\nconst calculateRut = () => {\n const totalWithRut =\n state.cart.reduce((acc, curr) => {\n return curr.rut ? acc + getItemPrice(curr) : acc;\n }, 0) + getStartFee().rut;\n const totalWithoutRut =\n state.cart.reduce((acc, curr) => {\n const partsPrice = curr.parts.reduce((acc, curr) => {\n return acc + curr.price * curr.amount;\n }, 0);\n return curr.rut ? acc + curr.price * curr.amount + partsPrice : acc;\n }, 0) + Number(state.options.start_fee);\n return totalWithoutRut - totalWithRut;\n};\n\nconst getTotalPrice = () => {\n return state.cart.reduce((acc, curr) => acc + getItemPrice(curr), 0) + getStartFee().rot + getStartFee().rut;\n};\n\nexport {\n getProductPriceWithRotAndRut,\n getProductPrice,\n getRotPrice,\n getRutPrice,\n getRotStartFee,\n getRutStartFee,\n getPartPrice,\n getStartFee,\n calculateRot,\n calculateRut,\n getItemPrice,\n getTotalPrice,\n};\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MD5 } from 'md5-js-tools';
|
|
2
|
+
const apiSearch = async (query) => {
|
|
3
|
+
var _a;
|
|
4
|
+
const res = await fetch((_a = process.env.CREDIT_SAFE_API_URL) !== null && _a !== void 0 ? _a : 'https://hemfixare-lookup.vercel.app/api', {
|
|
5
|
+
method: 'POST',
|
|
6
|
+
headers: {
|
|
7
|
+
'Content-Type': 'application/json',
|
|
8
|
+
},
|
|
9
|
+
body: JSON.stringify({
|
|
10
|
+
query,
|
|
11
|
+
hash: MD5.generate(String.fromCharCode(83, 101, 67, 82, 101, 116) + query),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
const data = await res.json();
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
export default apiSearch;
|
|
18
|
+
//# sourceMappingURL=creditSafe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"creditSafe.js","sourceRoot":"","sources":["../../src/utils/creditSafe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,MAAM,SAAS,GAAG,KAAK,EAAE,KAAa,EAA0B,EAAE;;EAChE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,mBAAmB,mCAAI,yCAAyC,EAAE;IACpG,MAAM,EAAE,MAAM;IACd,OAAO,EAAE;MACP,cAAc,EAAE,kBAAkB;KACnC;IACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;MACnB,KAAK;MACL,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;KAC3E,CAAC;GACH,CAAC,CAAC;EACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;EAC9B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { User } from '../types';\nimport { MD5 } from 'md5-js-tools';\n\nconst apiSearch = async (query: string): Promise<Partial<User>> => {\n const res = await fetch(process.env.CREDIT_SAFE_API_URL ?? 'https://hemfixare-lookup.vercel.app/api', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n query,\n hash: MD5.generate(String.fromCharCode(83, 101, 67, 82, 101, 116) + query),\n }),\n });\n const data = await res.json();\n return data;\n};\n\nexport default apiSearch;\n"]}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import state from '../store';
|
|
3
|
+
import { Buffer } from 'buffer';
|
|
4
|
+
const baseURL = process.env.FELIX_URL || 'https://stage.hemfixare.se/fmi/data/v1/databases/Hemfix_web/sessions';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
window.Buffer = Buffer;
|
|
7
|
+
let client;
|
|
8
|
+
async function initializeFelix() {
|
|
9
|
+
var _a;
|
|
10
|
+
const auth = Buffer.from('CustomWebForm:aFMZ4iJzoaEBcwskBDxqb4Pb').toString('base64');
|
|
11
|
+
const res = await apiCall('sessions', 'POST', null, auth);
|
|
12
|
+
return ((_a = res === null || res === void 0 ? void 0 : res.response) === null || _a === void 0 ? void 0 : _a.token) || null;
|
|
13
|
+
}
|
|
14
|
+
async function apiCall(endpoint, method, data, basic = false) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
if (!client) {
|
|
17
|
+
client = axios.create({
|
|
18
|
+
baseURL,
|
|
19
|
+
validateStatus: () => true,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
// console.log(basic);
|
|
23
|
+
const headers = {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
'Authorization': basic ? `Basic ${basic}` : `Bearer ${state.token ? state.token : ''}`,
|
|
26
|
+
// 'Access-Control-Allow-Origin': 'stage.hemfixare.se',
|
|
27
|
+
};
|
|
28
|
+
const config = {
|
|
29
|
+
method,
|
|
30
|
+
url: endpoint,
|
|
31
|
+
headers,
|
|
32
|
+
data,
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
const response = await client.request(config);
|
|
36
|
+
return {
|
|
37
|
+
response: response.data,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return {
|
|
42
|
+
error: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
43
|
+
message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.data) || error.message,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function sendPerson(data) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
// Implement the logic for sending a person
|
|
50
|
+
const endpoint = 'layouts/pa.Passage/records';
|
|
51
|
+
const method = 'POST';
|
|
52
|
+
const fieldData = {
|
|
53
|
+
// ... Initialize fieldData object with data
|
|
54
|
+
Pa01_FirstName: 'change',
|
|
55
|
+
Pa02_LastName: 'change',
|
|
56
|
+
Pa03_Address1: 'change',
|
|
57
|
+
Pa04_Address2: 'change',
|
|
58
|
+
Pa05_Zipcode: 'change',
|
|
59
|
+
Pa06_City: 'change',
|
|
60
|
+
Pa07_State: 'change',
|
|
61
|
+
Pa08_Country: 'change',
|
|
62
|
+
Pa11_StatusExternal: 'change',
|
|
63
|
+
Pa12_PersonalNo: 'change',
|
|
64
|
+
Pa20_Email: 'change',
|
|
65
|
+
Pa30_Phone: 'change',
|
|
66
|
+
Pa50_Type: 'change',
|
|
67
|
+
Pa51_Notes: 'change',
|
|
68
|
+
Pa041_AssignmentAddress: 'change',
|
|
69
|
+
Pa042_AssignmentZipCode: 'change',
|
|
70
|
+
Pa043_AssignmentCity: 'change',
|
|
71
|
+
};
|
|
72
|
+
const portalData = {
|
|
73
|
+
Parameter: [
|
|
74
|
+
// ... Initialize portalData array with data
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
// If products are present in data
|
|
78
|
+
if (data.products && Array.isArray(data.products)) {
|
|
79
|
+
// ... Process products and add them to portalData
|
|
80
|
+
}
|
|
81
|
+
const requestData = {
|
|
82
|
+
fieldData,
|
|
83
|
+
portalData,
|
|
84
|
+
};
|
|
85
|
+
const res = await apiCall(endpoint, method, requestData);
|
|
86
|
+
if ((_a = res === null || res === void 0 ? void 0 : res.response) === null || _a === void 0 ? void 0 : _a.recordId) {
|
|
87
|
+
// ... Process recordId
|
|
88
|
+
}
|
|
89
|
+
return ((_b = res === null || res === void 0 ? void 0 : res.response) === null || _b === void 0 ? void 0 : _b.recordId) || false;
|
|
90
|
+
}
|
|
91
|
+
async function checkPerson(ssn, url) {
|
|
92
|
+
var _a;
|
|
93
|
+
// Implement the logic for checking a person
|
|
94
|
+
const endpoint = 'layouts/pa.Passage/records';
|
|
95
|
+
const method = 'POST';
|
|
96
|
+
const data = {
|
|
97
|
+
'fieldData': {
|
|
98
|
+
Pa50_Type: url,
|
|
99
|
+
},
|
|
100
|
+
'script': 'pa.pub.PassageCheckPerson',
|
|
101
|
+
'script.param': ssn,
|
|
102
|
+
};
|
|
103
|
+
const res = await apiCall(endpoint, method, data);
|
|
104
|
+
return ((_a = res === null || res === void 0 ? void 0 : res.response) === null || _a === void 0 ? void 0 : _a.recordId) || null;
|
|
105
|
+
}
|
|
106
|
+
async function getPersonData(id) {
|
|
107
|
+
var _a;
|
|
108
|
+
// Implement the logic for getting person data
|
|
109
|
+
const endpoint = `layouts/pa.PassageGetData/records/${id}`;
|
|
110
|
+
const method = 'GET';
|
|
111
|
+
const res = await apiCall(endpoint, method);
|
|
112
|
+
return ((_a = res === null || res === void 0 ? void 0 : res.response) === null || _a === void 0 ? void 0 : _a.data) || null;
|
|
113
|
+
}
|
|
114
|
+
async function updatePerson(data, id) {
|
|
115
|
+
var _a;
|
|
116
|
+
// Implement the logic for updating a person
|
|
117
|
+
const endpoint = `layouts/pa.Passage/records/${id}`;
|
|
118
|
+
const method = 'PATCH';
|
|
119
|
+
const fieldData = {
|
|
120
|
+
// ... Initialize fieldData object with data
|
|
121
|
+
Pa01_FirstName: 'change',
|
|
122
|
+
Pa02_LastName: 'change',
|
|
123
|
+
Pa03_Address1: 'change',
|
|
124
|
+
Pa04_Address2: 'change',
|
|
125
|
+
Pa05_Zipcode: 'change',
|
|
126
|
+
Pa06_City: 'change',
|
|
127
|
+
Pa07_State: 'change',
|
|
128
|
+
Pa08_Country: 'change',
|
|
129
|
+
Pa11_StatusExternal: 'change',
|
|
130
|
+
Pa12_PersonalNo: 'change',
|
|
131
|
+
Pa20_Email: 'change',
|
|
132
|
+
Pa30_Phone: 'change',
|
|
133
|
+
Pa50_Type: 'change',
|
|
134
|
+
Pa51_Notes: 'change',
|
|
135
|
+
Pa041_AssignmentAddress: 'change',
|
|
136
|
+
Pa042_AssignmentZipCode: 'change',
|
|
137
|
+
Pa043_AssignmentCity: 'change',
|
|
138
|
+
};
|
|
139
|
+
const portalData = {
|
|
140
|
+
Parameter: [
|
|
141
|
+
// ... Initialize portalData array with data
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
// If products are present in data
|
|
145
|
+
if (data.products && Array.isArray(data.products)) {
|
|
146
|
+
// ... Process products and add them to portalData
|
|
147
|
+
}
|
|
148
|
+
// If serviceArr is present in data
|
|
149
|
+
if (data.serviceArr && Array.isArray(data.serviceArr) && !((_a = data.products) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
150
|
+
// ... Process serviceArr and add them to portalData
|
|
151
|
+
}
|
|
152
|
+
// If recievedChanged is "true" in data
|
|
153
|
+
if (data.recievedChanged) {
|
|
154
|
+
// ... Add assignment data to fieldData
|
|
155
|
+
}
|
|
156
|
+
const requestData = {
|
|
157
|
+
fieldData,
|
|
158
|
+
portalData,
|
|
159
|
+
};
|
|
160
|
+
const res = await apiCall(endpoint, method, requestData);
|
|
161
|
+
if ((res === null || res === void 0 ? void 0 : res.message) === 'OK') {
|
|
162
|
+
// ... Process response
|
|
163
|
+
return id;
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
async function findPricing(data) {
|
|
168
|
+
// Implement the logic for finding pricing
|
|
169
|
+
const endpoint = 'layouts/pa.PassagePricing/_find';
|
|
170
|
+
const method = 'POST';
|
|
171
|
+
const query = {
|
|
172
|
+
query: [
|
|
173
|
+
{
|
|
174
|
+
As014_WebFormType_c: data,
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
};
|
|
178
|
+
const res = await apiCall(endpoint, method, query);
|
|
179
|
+
return res;
|
|
180
|
+
}
|
|
181
|
+
async function processPassageRecords(data) {
|
|
182
|
+
// Implement the logic for processing passage records
|
|
183
|
+
const endpoint = `layouts/pa.Passage/script/pa.pub.ProcessCustomWebForm?script.param=${data}`;
|
|
184
|
+
const method = 'GET';
|
|
185
|
+
const res = await apiCall(endpoint, method);
|
|
186
|
+
return res;
|
|
187
|
+
}
|
|
188
|
+
export { initializeFelix, sendPerson, checkPerson, getPersonData, updatePerson, findPricing, processPassageRecords };
|
|
189
|
+
//# sourceMappingURL=felixFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"felixFunctions.js","sourceRoot":"","sources":["../../src/utils/felixFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,KAAK,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,sEAAsE,CAAC;AAEhH,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;AA8CvB,IAAI,MAAqB,CAAC;AAE1B,KAAK,UAAU,eAAe;;EAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;EACtF,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;EAC1D,OAAO,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,0CAAE,KAAK,KAAI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AO,GAAG,CAAC;AACb,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import axios, { AxiosInstance, AxiosResponse, AxiosRequestConfig } from 'axios';\nimport state from '../store';\nimport { Buffer } from 'buffer';\nconst baseURL = process.env.FELIX_URL || 'https://stage.hemfixare.se/fmi/data/v1/databases/Hemfix_web/sessions';\n\n// @ts-ignore\nwindow.Buffer = Buffer;\n\ninterface Product {\n [index: number]: string;\n}\n\ninterface Service {\n [index: number]: string;\n}\n\ninterface PortalParameter {\n 'Parameter::Pad001_Name': string;\n 'Parameter::Pad002_Data': string;\n 'Parameter::Pad031_Antal'?: string;\n}\n\ninterface FieldData {\n Pa01_FirstName: string;\n Pa02_LastName: string;\n Pa03_Address1: string;\n Pa04_Address2: string;\n Pa05_Zipcode: string;\n Pa06_City: string;\n Pa07_State: string;\n Pa08_Country: string;\n Pa11_StatusExternal: string;\n Pa12_PersonalNo: string;\n Pa20_Email: string;\n Pa30_Phone: string;\n Pa50_Type: string;\n Pa51_Notes: string;\n Pa041_AssignmentAddress?: string;\n Pa042_AssignmentZipCode?: string;\n Pa043_AssignmentCity?: string;\n}\n\ninterface PortalData {\n Parameter: PortalParameter[];\n}\n\ninterface ApiCallResponse {\n error?: number;\n message?: string;\n response?: Record<string, any>;\n}\n\nlet client: AxiosInstance;\n\nasync function initializeFelix(): Promise<string> {\n const auth = Buffer.from('CustomWebForm:aFMZ4iJzoaEBcwskBDxqb4Pb').toString('base64');\n const res = await apiCall('sessions', 'POST', null, auth);\n return res?.response?.token || null;\n}\n\nasync function apiCall(endpoint: string, method: 'GET' | 'POST' | 'PATCH', data?: any, basic: boolean | string = false): Promise<ApiCallResponse> {\n if (!client) {\n client = axios.create({\n baseURL,\n validateStatus: () => true,\n });\n }\n\n // console.log(basic);\n\n const headers: { [key: string]: string } = {\n 'Content-Type': 'application/json',\n 'Authorization': basic ? `Basic ${basic}` : `Bearer ${state.token ? state.token : ''}`,\n // 'Access-Control-Allow-Origin': 'stage.hemfixare.se',\n };\n\n const config: AxiosRequestConfig = {\n method,\n url: endpoint,\n headers,\n data,\n };\n\n try {\n const response: AxiosResponse = await client.request(config);\n return {\n response: response.data,\n };\n } catch (error) {\n return {\n error: error.response?.status,\n message: error.response?.data || error.message,\n };\n }\n}\n\nasync function sendPerson(data: {\n products: Product[];\n serviceArr: Service[];\n // ... Define the data structure\n}): Promise<string | false> {\n // Implement the logic for sending a person\n const endpoint = 'layouts/pa.Passage/records';\n const method = 'POST';\n\n const fieldData: FieldData = {\n // ... Initialize fieldData object with data\n Pa01_FirstName: 'change',\n Pa02_LastName: 'change',\n Pa03_Address1: 'change',\n Pa04_Address2: 'change',\n Pa05_Zipcode: 'change',\n Pa06_City: 'change',\n Pa07_State: 'change',\n Pa08_Country: 'change',\n Pa11_StatusExternal: 'change',\n Pa12_PersonalNo: 'change',\n Pa20_Email: 'change',\n Pa30_Phone: 'change',\n Pa50_Type: 'change',\n Pa51_Notes: 'change',\n Pa041_AssignmentAddress: 'change',\n Pa042_AssignmentZipCode: 'change',\n Pa043_AssignmentCity: 'change',\n };\n\n const portalData: PortalData = {\n Parameter: [\n // ... Initialize portalData array with data\n ],\n };\n\n // If products are present in data\n if (data.products && Array.isArray(data.products)) {\n // ... Process products and add them to portalData\n }\n\n const requestData = {\n fieldData,\n portalData,\n };\n\n const res = await apiCall(endpoint, method, requestData);\n if (res?.response?.recordId) {\n // ... Process recordId\n }\n return res?.response?.recordId || false;\n}\n\nasync function checkPerson(ssn: string, url: string): Promise<string | null> {\n // Implement the logic for checking a person\n const endpoint = 'layouts/pa.Passage/records';\n const method = 'POST';\n\n const data = {\n 'fieldData': {\n Pa50_Type: url,\n },\n 'script': 'pa.pub.PassageCheckPerson',\n 'script.param': ssn,\n };\n\n const res = await apiCall(endpoint, method, data);\n return res?.response?.recordId || null;\n}\n\nasync function getPersonData(id: string): Promise<any> {\n // Implement the logic for getting person data\n const endpoint = `layouts/pa.PassageGetData/records/${id}`;\n const method = 'GET';\n\n const res = await apiCall(endpoint, method);\n return res?.response?.data || null;\n}\n\nasync function updatePerson(\n data: {\n // ... Define the data structure\n products: Product[];\n serviceArr: Service[];\n recievedChanged: boolean;\n },\n id: string,\n): Promise<string | false> {\n // Implement the logic for updating a person\n const endpoint = `layouts/pa.Passage/records/${id}`;\n const method = 'PATCH';\n\n const fieldData: FieldData = {\n // ... Initialize fieldData object with data\n Pa01_FirstName: 'change',\n Pa02_LastName: 'change',\n Pa03_Address1: 'change',\n Pa04_Address2: 'change',\n Pa05_Zipcode: 'change',\n Pa06_City: 'change',\n Pa07_State: 'change',\n Pa08_Country: 'change',\n Pa11_StatusExternal: 'change',\n Pa12_PersonalNo: 'change',\n Pa20_Email: 'change',\n Pa30_Phone: 'change',\n Pa50_Type: 'change',\n Pa51_Notes: 'change',\n Pa041_AssignmentAddress: 'change',\n Pa042_AssignmentZipCode: 'change',\n Pa043_AssignmentCity: 'change',\n };\n\n const portalData: PortalData = {\n Parameter: [\n // ... Initialize portalData array with data\n ],\n };\n\n // If products are present in data\n if (data.products && Array.isArray(data.products)) {\n // ... Process products and add them to portalData\n }\n\n // If serviceArr is present in data\n if (data.serviceArr && Array.isArray(data.serviceArr) && !data.products?.length) {\n // ... Process serviceArr and add them to portalData\n }\n\n // If recievedChanged is \"true\" in data\n if (data.recievedChanged) {\n // ... Add assignment data to fieldData\n }\n\n const requestData = {\n fieldData,\n portalData,\n };\n\n const res = await apiCall(endpoint, method, requestData);\n if (res?.message === 'OK') {\n // ... Process response\n return id;\n }\n return false;\n}\n\nasync function findPricing(data: string): Promise<any> {\n // Implement the logic for finding pricing\n const endpoint = 'layouts/pa.PassagePricing/_find';\n const method = 'POST';\n\n const query = {\n query: [\n {\n As014_WebFormType_c: data,\n },\n ],\n };\n\n const res = await apiCall(endpoint, method, query);\n return res;\n}\n\nasync function processPassageRecords(data: string): Promise<any> {\n // Implement the logic for processing passage records\n const endpoint = `layouts/pa.Passage/script/pa.pub.ProcessCustomWebForm?script.param=${data}`;\n const method = 'GET';\n\n const res = await apiCall(endpoint, method);\n return res;\n}\n\nexport { initializeFelix, sendPerson, checkPerson, getPersonData, updatePerson, findPricing, processPassageRecords };\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const hideField = (field) => {
|
|
2
|
+
return field.split(' ').reduce((acc, curr) => {
|
|
3
|
+
return curr.length < 2 ? curr : acc + curr.slice(0, 1) + '*'.repeat(curr.length - 2) + curr.slice(curr.length - 1, curr.length) + ' ';
|
|
4
|
+
}, '');
|
|
5
|
+
};
|
|
6
|
+
export { hideField };
|
|
7
|
+
//# sourceMappingURL=form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/utils/form.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE;EAClC,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IAC3C,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;EACxI,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["const hideField = (field: string) => {\n return field.split(' ').reduce((acc, curr) => {\n return curr.length < 2 ? curr : acc + curr.slice(0, 1) + '*'.repeat(curr.length - 2) + curr.slice(curr.length - 1, curr.length) + ' ';\n }, '');\n};\n\nexport { hideField };\n"]}
|