@postnord/pn-marketweb-components 1.0.43 → 1.0.44-beta1

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.
Files changed (72) hide show
  1. package/cjs/{convert-57b3dd5e.js → convert-b8a6d658.js} +55 -0
  2. package/cjs/loader.cjs.js +1 -1
  3. package/cjs/pn-choice-button.cjs.entry.js +39 -0
  4. package/cjs/pn-find-price-result.cjs.entry.js +44 -0
  5. package/cjs/pn-find-price-store-85b100ba.js +23 -0
  6. package/cjs/pn-find-price.cjs.entry.js +260 -0
  7. package/cjs/{pn-choice-button_2.cjs.entry.js → pn-find-service-and-price-result.cjs.entry.js} +0 -33
  8. package/cjs/pn-find-service-and-price.cjs.entry.js +1 -1
  9. package/cjs/pn-market-web-components.cjs.js +1 -1
  10. package/cjs/pn-product-pricelist.cjs.entry.js +1 -1
  11. package/collection/collection-manifest.json +2 -0
  12. package/collection/components/widgets/pn-find-price/data.js +68 -0
  13. package/collection/components/widgets/pn-find-price/find-price.stories.js +27 -0
  14. package/collection/components/widgets/pn-find-price/pn-find-price-result.css +3 -0
  15. package/collection/components/widgets/pn-find-price/pn-find-price-result.js +100 -0
  16. package/collection/components/widgets/pn-find-price/pn-find-price-store.js +20 -0
  17. package/collection/components/widgets/pn-find-price/pn-find-price-translations.js +71 -0
  18. package/collection/components/widgets/pn-find-price/pn-find-price-types.js +1 -0
  19. package/collection/components/widgets/pn-find-price/pn-find-price.css +55 -0
  20. package/collection/components/widgets/pn-find-price/pn-find-price.js +212 -0
  21. package/collection/globals/shared/productprice/convert.js +55 -1
  22. package/custom-elements/index.d.ts +12 -0
  23. package/custom-elements/index.js +391 -28
  24. package/esm/{convert-b49a0857.js → convert-8cce67c4.js} +55 -1
  25. package/esm/loader.js +1 -1
  26. package/esm/{pn-choice-button_2.entry.js → pn-choice-button.entry.js} +1 -39
  27. package/esm/pn-find-price-result.entry.js +40 -0
  28. package/esm/pn-find-price-store-d2053b72.js +21 -0
  29. package/esm/pn-find-price.entry.js +256 -0
  30. package/esm/pn-find-service-and-price-result.entry.js +41 -0
  31. package/esm/pn-find-service-and-price.entry.js +1 -1
  32. package/esm/pn-market-web-components.js +1 -1
  33. package/esm/pn-product-pricelist.entry.js +1 -1
  34. package/esm-es5/{convert-b49a0857.js → convert-8cce67c4.js} +1 -1
  35. package/esm-es5/loader.js +1 -1
  36. package/esm-es5/pn-choice-button.entry.js +1 -0
  37. package/esm-es5/pn-find-price-result.entry.js +1 -0
  38. package/esm-es5/pn-find-price-store-d2053b72.js +1 -0
  39. package/esm-es5/pn-find-price.entry.js +1 -0
  40. package/esm-es5/pn-find-service-and-price-result.entry.js +1 -0
  41. package/esm-es5/pn-find-service-and-price.entry.js +1 -1
  42. package/esm-es5/pn-market-web-components.js +1 -1
  43. package/esm-es5/pn-product-pricelist.entry.js +1 -1
  44. package/package.json +1 -1
  45. package/pn-market-web-components/{p-e6a209c6.system.entry.js → p-0d0ea574.system.entry.js} +1 -1
  46. package/pn-market-web-components/{p-b8af690a.entry.js → p-22738646.entry.js} +1 -1
  47. package/pn-market-web-components/p-233ca151.system.js +1 -0
  48. package/pn-market-web-components/p-325a7cae.entry.js +1 -0
  49. package/pn-market-web-components/p-4fcabdb8.entry.js +1 -0
  50. package/pn-market-web-components/p-50454694.system.entry.js +1 -0
  51. package/pn-market-web-components/{p-91624bd5.system.js → p-5ce5be4f.system.js} +2 -2
  52. package/pn-market-web-components/p-6ee881ea.system.entry.js +1 -0
  53. package/pn-market-web-components/p-725e4377.entry.js +1 -0
  54. package/pn-market-web-components/{p-21e0e386.js → p-7dd91709.js} +1 -1
  55. package/pn-market-web-components/p-a22df959.system.js +1 -1
  56. package/pn-market-web-components/p-b30e348c.system.entry.js +1 -0
  57. package/pn-market-web-components/p-bea2dcc6.entry.js +1 -0
  58. package/pn-market-web-components/p-c30207e6.js +1 -0
  59. package/pn-market-web-components/p-d8882f68.system.entry.js +1 -0
  60. package/pn-market-web-components/p-dd4de1a9.entry.js +1 -0
  61. package/pn-market-web-components/{p-e04f8d34.system.entry.js → p-eb75d0cf.system.entry.js} +1 -1
  62. package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
  63. package/types/components/widgets/pn-find-price/pn-find-price-result.d.ts +9 -0
  64. package/types/components/widgets/pn-find-price/pn-find-price-store.d.ts +33 -0
  65. package/types/components/widgets/pn-find-price/pn-find-price-translations.d.ts +71 -0
  66. package/types/components/widgets/pn-find-price/pn-find-price-types.d.ts +46 -0
  67. package/types/components/widgets/pn-find-price/pn-find-price.d.ts +16 -0
  68. package/types/components.d.ts +37 -0
  69. package/esm-es5/pn-choice-button_2.entry.js +0 -1
  70. package/pn-market-web-components/p-37801e32.entry.js +0 -1
  71. package/pn-market-web-components/p-861210ae.entry.js +0 -1
  72. package/pn-market-web-components/p-ec1127de.system.entry.js +0 -1
@@ -0,0 +1,68 @@
1
+
2
+ const sizeCategories = [
3
+ { name: "Document", value: "document", illustration: "claims", unit: "gram" },
4
+ { name: "Box Of Chocolate", value: "boxofchocolate", illustration: "outgoing", unit: "gram" },
5
+ { name: "Rubber Boots", value: "rubberboots", illustration: "christmas", unit: "combo" },
6
+ { name: "Moving Box", value:"movingbox", illustration: "outgoing", unit: "kgram" },
7
+ ];
8
+
9
+ const weights = {
10
+ "gram": [
11
+ { name: "50g", abbreviation: 'g', value: 50 },
12
+ { name: "100g", abbreviation: 'g', value: 100 },
13
+ { name: "250g", abbreviation: 'g', value: 250 },
14
+ { name: "500g", abbreviation: 'g', value: 500 },
15
+ { name: "1kg", abbreviation: 'kg', value: 1 },
16
+ { name: "2kg", abbreviation: 'kg', value: 2 },
17
+ ],
18
+ "kgram": [
19
+ { name: "1kg", abbreviation: 'kg', value: 1 },
20
+ { name: "2kg", abbreviation: 'kg', value: 2 },
21
+ { name: "3kg", abbreviation: 'kg', value: 3 },
22
+ { name: "4kg", abbreviation: 'kg', value: 4 },
23
+ { name: "5kg", abbreviation: 'kg', value: 5 },
24
+ { name: "6kg", abbreviation: 'kg', value: 6 },
25
+ { name: "7Kg", abbreviation: 'kg', value: 7 },
26
+ { name: "8kg", abbreviation: 'kg', value: 8 },
27
+ { name: "9kg", abbreviation: 'kg', value: 9 },
28
+ { name: "10kg", abbreviation: 'kg', value: 10 },
29
+ { name: "11kg", abbreviation: 'kg', value: 11 },
30
+ { name: "12kg", abbreviation: 'kg', value: 12 },
31
+ { name: "13kg", abbreviation: 'kg', value: 13 },
32
+ { name: "14kg", abbreviation: 'kg', value: 14 },
33
+ { name: "15kg", abbreviation: 'kg', value: 15 },
34
+ { name: "16kg", abbreviation: 'kg', value: 16 },
35
+ { name: "17kg", abbreviation: 'kg', value: 17 },
36
+ { name: "18kg", abbreviation: 'kg', value: 18 },
37
+ { name: "20kg", abbreviation: 'kg', value: 20 },
38
+ ],
39
+ "combo": [
40
+ { name: "50g", abbreviation: 'g', value: 50 },
41
+ { name: "100g", abbreviation: 'g', value: 100 },
42
+ { name: "250g", abbreviation: 'g', value: 250 },
43
+ { name: "500g", abbreviation: 'g', value: 500 },
44
+ { name: "1kg", abbreviation: 'kg', value: 1 },
45
+ { name: "2kg", abbreviation: 'kg', value: 2 },
46
+ { name: "3kg", abbreviation: 'kg', value: 3 },
47
+ { name: "4kg", abbreviation: 'kg', value: 4 },
48
+ { name: "5kg", abbreviation: 'kg', value: 5 },
49
+ { name: "6kg", abbreviation: 'kg', value: 6 },
50
+ { name: "7Kg", abbreviation: 'kg', value: 7 },
51
+ { name: "8kg", abbreviation: 'kg', value: 8 },
52
+ { name: "9kg", abbreviation: 'kg', value: 9 },
53
+ { name: "10kg", abbreviation: 'kg', value: 10 },
54
+ { name: "11kg", abbreviation: 'kg', value: 11 },
55
+ { name: "12kg", abbreviation: 'kg', value: 12 },
56
+ { name: "13kg", abbreviation: 'kg', value: 13 },
57
+ { name: "14kg", abbreviation: 'kg', value: 14 },
58
+ { name: "15kg", abbreviation: 'kg', value: 15 },
59
+ { name: "16kg", abbreviation: 'kg', value: 16 },
60
+ { name: "17kg", abbreviation: 'kg', value: 17 },
61
+ { name: "18kg", abbreviation: 'kg', value: 18 },
62
+ { name: "20kg", abbreviation: 'kg', value: 20 },
63
+ ]
64
+ };
65
+
66
+
67
+
68
+ export { weights, sizeCategories};
@@ -0,0 +1,27 @@
1
+ import readme from "./readme.md";
2
+
3
+ export default {
4
+ title: "Widgets /Find Price",
5
+ parameters: {
6
+ notes: readme
7
+ }
8
+ };
9
+
10
+ const Template = ({ ...args }) => {
11
+ return `
12
+ <div style="max-width: 100%; margin:1em auto 0;">
13
+ <pn-find-price
14
+ source="${args.source}"
15
+ market="${args.market}"
16
+ language="${args.language}"
17
+ ></pn-find-price>
18
+ </div>
19
+ `;
20
+ };
21
+
22
+ export const Primary = Template.bind({});
23
+ Primary.args = {
24
+ source: 'https://com-integration.postnord.com/globalassets/global/prices/sv-findprice.xlsx',
25
+ language: 'sv',
26
+ market: 'se',
27
+ };
@@ -0,0 +1,3 @@
1
+ pn-find-price-result .test {
2
+ margin: 3em 0;
3
+ }
@@ -0,0 +1,100 @@
1
+ import { Component, h, Prop, Host, Watch, State } from "@stencil/core";
2
+ import { state } from "./pn-find-price-store";
3
+ export class PnfindPriceResult {
4
+ constructor() {
5
+ this.item = null;
6
+ this.shownitems = [];
7
+ this.weightText = "";
8
+ }
9
+ componentWillLoad() {
10
+ this.composeItems();
11
+ }
12
+ composeItems() {
13
+ this.shownitems = [];
14
+ if (this.item.pricestamps) {
15
+ this.shownitems.push(Object.assign(Object.assign({}, this.item), { priceagent: null, pricesenddirect: null }));
16
+ }
17
+ if (this.item.priceagent) {
18
+ this.shownitems.push(Object.assign(Object.assign({}, this.item), { pricestamps: null, pricesenddirect: null }));
19
+ }
20
+ if (this.item.pricesenddirect) {
21
+ this.shownitems.push(Object.assign(Object.assign({}, this.item), { pricestamps: null, priceagent: null }));
22
+ }
23
+ this.weightText = (this.item.maxweight <= 20) ? this.item.maxweight + 'kg' :
24
+ (this.item.maxweight > 999) ? Math.round(this.item.maxweight / 1000) + " kg" : this.item.maxweight + " g";
25
+ }
26
+ render() {
27
+ return (h(Host, null, this.shownitems.map((item) => (h("pn-product-tile", null,
28
+ h("pn-illustration", { slot: "illustration", illustration: item.illustration }),
29
+ h("div", { slot: "content" },
30
+ h("div", { class: "content" },
31
+ h("h3", null, item.name),
32
+ (item.description) ? (h("div", { class: "description" }, item.description)) : null,
33
+ (item.info) ? (h("div", { class: "description" }, item.info)) : null)),
34
+ item.note ? (h("small", { slot: "note" },
35
+ h("p", null, item.note))) : null,
36
+ item.maxweight ? (h("pn-product-tile-info", { label: state.i18n.maxweightlabel, text: this.weightText })) : null,
37
+ item.maximummeasurements ? (h("pn-product-tile-info", { label: state.i18n.maxmeasurementlabel, text: item.maximummeasurements })) : null,
38
+ item.priceagent ? (h("pn-product-tile-price", { slot: "price", label: "", amount: item.priceagent + '', currency: state.market.currency, url: "https://shop.postnord.se/ebutik/default.aspx" })) : null,
39
+ item.pricestamps ? (h("pn-product-tile-price", { slot: "price", label: state.i18n.stampshopcta, amount: item.pricestamps + '', currency: state.market.currency })) : null,
40
+ item.pricesenddirect ? (h("pn-product-tile-price", { slot: "price", label: state.i18n.senddirectcta, amount: item.pricesenddirect + '', currency: state.market.currency, url: "https://portal.postnord.com/skickadirekt/" })) : null)))));
41
+ }
42
+ static get is() { return "pn-find-price-result"; }
43
+ static get originalStyleUrls() { return {
44
+ "$": ["pn-find-price-result.scss"]
45
+ }; }
46
+ static get styleUrls() { return {
47
+ "$": ["pn-find-price-result.css"]
48
+ }; }
49
+ static get properties() { return {
50
+ "item": {
51
+ "type": "unknown",
52
+ "mutable": true,
53
+ "complexType": {
54
+ "original": "ProductPriceItm",
55
+ "resolved": "ProductPriceItm",
56
+ "references": {
57
+ "ProductPriceItm": {
58
+ "location": "import",
59
+ "path": "./pn-find-price-types"
60
+ }
61
+ }
62
+ },
63
+ "required": false,
64
+ "optional": false,
65
+ "docs": {
66
+ "tags": [],
67
+ "text": ""
68
+ },
69
+ "defaultValue": "null"
70
+ },
71
+ "shownitems": {
72
+ "type": "unknown",
73
+ "mutable": false,
74
+ "complexType": {
75
+ "original": "ProductPriceItm[]",
76
+ "resolved": "ProductPriceItm[]",
77
+ "references": {
78
+ "ProductPriceItm": {
79
+ "location": "import",
80
+ "path": "./pn-find-price-types"
81
+ }
82
+ }
83
+ },
84
+ "required": false,
85
+ "optional": false,
86
+ "docs": {
87
+ "tags": [],
88
+ "text": ""
89
+ },
90
+ "defaultValue": "[]"
91
+ }
92
+ }; }
93
+ static get states() { return {
94
+ "weightText": {}
95
+ }; }
96
+ static get watchers() { return [{
97
+ "propName": "item",
98
+ "methodName": "composeItems"
99
+ }]; }
100
+ }
@@ -0,0 +1,20 @@
1
+ import { createStore } from "@stencil/store";
2
+ // Read more about how stencil stores work here: https://stenciljs.com/docs/stencil-store
3
+ const { state, onChange } = createStore({
4
+ i18n: {
5
+ componentheading: '',
6
+ deliveryscopeheading: '',
7
+ sizeheading: '',
8
+ resultlistheading: '',
9
+ weightlabel: '',
10
+ maxweightlabel: '',
11
+ maxmeasurementlabel: '',
12
+ senddirectcta: '',
13
+ stampshopcta: '',
14
+ },
15
+ market: {
16
+ currency: ""
17
+ }
18
+ });
19
+ export { state, onChange };
20
+ export default state;
@@ -0,0 +1,71 @@
1
+ export const translations = {
2
+ 'sv': {
3
+ 'componentheading': 'Vad vill du skicka?',
4
+ 'deliveryscopeheading': 'Endast leveranser inom Sverige',
5
+ 'sizeheading': 'Hur mycket väger det?',
6
+ 'resultlistheading': 'Några utvalda val',
7
+ 'weightlabel': 'Vikt',
8
+ 'maxweightlabel': 'Maxvikt',
9
+ 'maxmeasurementlabel': 'Maxvolym',
10
+ 'senddirectcta': 'Köp frakt via Skicka Direkt',
11
+ 'stampshopcta': 'Köp frimärken via vår webshop',
12
+ },
13
+ 'en': {
14
+ 'componentheading': 'What do you want to send?',
15
+ 'deliveryscopeheading': 'Deliveries within Sweden only',
16
+ 'sizeheading': 'How much does it weigh?',
17
+ 'resultlistheading': 'Some suitable options for you',
18
+ 'weightlabel': 'Weight',
19
+ 'maxweightlabel': 'Max weight',
20
+ 'maxmeasurementlabel': 'Maximum measurement',
21
+ 'senddirectcta': 'Buy shipping in Send Direct',
22
+ 'stampshopcta': 'Order home stamps from the webshop',
23
+ },
24
+ 'da': {
25
+ 'componentheading': 'Vad vill du skicka?',
26
+ 'deliveryscopeheading': 'Kun leveringer indenfor Sverige',
27
+ 'sizeheading': 'How much does it weigh?',
28
+ 'resultlistheading': 'Some suitable options for you',
29
+ 'weightlabel': 'Vægt',
30
+ 'maxweightlabel': 'Max vægt',
31
+ 'maxmeasurementlabel': 'Maks. Volumen',
32
+ 'senddirectcta': 'Buy shipping in Send Direct',
33
+ 'stampshopcta': 'Order home stamps from the webshop',
34
+ },
35
+ 'no': {
36
+ 'componentheading': 'Vad vill du skicka?',
37
+ 'deliveryscopeheading': 'Kun leveranser innen Sverige',
38
+ 'sizeheading': 'How much does it weigh?',
39
+ 'resultlistheading': 'Some suitable options for you',
40
+ 'weightlabel': 'Vekt',
41
+ 'maxweightlabel': 'Maks vekt',
42
+ 'maxmeasurementlabel': 'Maks volum',
43
+ 'senddirectcta': 'Buy shipping in Send Direct',
44
+ 'stampshopcta': 'Order home stamps from the webshop',
45
+ },
46
+ 'fi': {
47
+ 'componentheading': 'Vad vill du skicka?',
48
+ 'deliveryscopeheading': 'Toimitukset vain Ruotsin sisällä',
49
+ 'sizeheading': 'How much does it weigh?',
50
+ 'resultlistheading': 'Some suitable options for you',
51
+ 'weightlabel': 'Paino',
52
+ 'maxweightlabel': 'Max paino',
53
+ 'maxmeasurementlabel': 'Max äänenvoimakkuus',
54
+ 'senddirectcta': 'Buy shipping in Send Direct',
55
+ 'stampshopcta': 'Order home stamps from the webshop',
56
+ }
57
+ };
58
+ export const markets = {
59
+ 'se': {
60
+ "currency": "kr",
61
+ },
62
+ 'dk': {
63
+ "currency": "dk",
64
+ },
65
+ 'fi': {
66
+ "currency": " €",
67
+ },
68
+ 'no': {
69
+ "currency": "kr",
70
+ }
71
+ };
@@ -0,0 +1,55 @@
1
+ pn-find-price .findprice-form {
2
+ max-width: 50em;
3
+ margin: 0 auto;
4
+ }
5
+ pn-find-price h2,
6
+ pn-find-price .heading {
7
+ text-align: center;
8
+ font-size: 1.5em;
9
+ line-height: 1.1;
10
+ font-weight: bold;
11
+ margin-bottom: 1rem;
12
+ }
13
+ pn-find-price .sizecategory {
14
+ text-align: center;
15
+ margin-bottom: 3rem;
16
+ }
17
+ pn-find-price .weightoption {
18
+ display: flex;
19
+ gap: 1em;
20
+ }
21
+ pn-find-price .weightoption-input {
22
+ width: 5em;
23
+ position: relative;
24
+ }
25
+ pn-find-price .weightoption-input input::-webkit-outer-spin-button,
26
+ pn-find-price .weightoption-input input::-webkit-inner-spin-button {
27
+ -webkit-appearance: none;
28
+ margin: 0;
29
+ }
30
+ pn-find-price .weightoption-input-abbreviation {
31
+ position: absolute;
32
+ top: 50%;
33
+ transform: translateY(-50%);
34
+ right: 1.2em;
35
+ margin-top: 1.55rem;
36
+ font-weight: 500;
37
+ }
38
+ pn-find-price .weightoption-range {
39
+ flex-grow: 1;
40
+ align-self: flex-end;
41
+ position: relative;
42
+ top: 0.5em;
43
+ }
44
+ pn-find-price .weightoption-range input {
45
+ width: calc(100% - 1.5em);
46
+ }
47
+ pn-find-price .weightoption-range datalist {
48
+ width: 100%;
49
+ display: flex;
50
+ justify-content: space-between;
51
+ font-size: 0.75em;
52
+ }
53
+ pn-find-price .resultlist {
54
+ margin: 3em 0;
55
+ }
@@ -0,0 +1,212 @@
1
+ import { Component, h, Prop, State, Watch } from "@stencil/core";
2
+ import { translations, markets } from "./pn-find-price-translations";
3
+ import { weights, sizeCategories } from "./data.js";
4
+ import { convertFileForSizeCategogy } from "../../../globals/shared/productprice/convert.js";
5
+ import { state } from "./pn-find-price-store";
6
+ export class PnfindPrice {
7
+ constructor() {
8
+ this.source = "https://com-integration.postnord.com/globalassets/global/prices/sv-findprice.xlsx";
9
+ this.language = "sv";
10
+ this.market = "se";
11
+ this.filteredItems = [];
12
+ this.weight = { value: 0, name: "" };
13
+ this.weightvalue = 0;
14
+ this.sourceData = { types: [], data: [] };
15
+ this.sizecategory = { value: "", name: "", icon: "", unit: "" };
16
+ }
17
+ componentWillLoad() {
18
+ this.setState();
19
+ this.getDataSource();
20
+ }
21
+ async getDataSource() {
22
+ const cacheBusting = `?cache=${Math.floor(Math.random() * (10000 - 1) + 1)}`;
23
+ const req = await fetch(this.source + cacheBusting);
24
+ const reqbody = await req.blob();
25
+ try {
26
+ const convertedData = await convertFileForSizeCategogy(reqbody);
27
+ this.sourceData = convertedData;
28
+ this.filterItems();
29
+ }
30
+ catch (e) {
31
+ console.log('Unable to parse data');
32
+ }
33
+ }
34
+ setState() {
35
+ if (this.market) {
36
+ state.market = markets[this.market];
37
+ }
38
+ if (this.language && translations[this.language]) {
39
+ state.i18n = translations[this.language];
40
+ }
41
+ }
42
+ filterItems() {
43
+ var _a;
44
+ if (!((_a = this.sourceData) === null || _a === void 0 ? void 0 : _a.data)) {
45
+ console.log('Data has not yet been loaded');
46
+ return;
47
+ }
48
+ const deliveryScopeData = this.sourceData.data.filter((x) => x.deliveryscope === "Sweden");
49
+ if (!this.sizecategory) {
50
+ return;
51
+ }
52
+ const sizeItemData = deliveryScopeData.filter((x) => x.sizecategory === this.sizecategory.value);
53
+ if (!this.weight || !this.weight.value) {
54
+ return;
55
+ }
56
+ const comparisonWeight = this.weight.value <= 20 ? this.weight.value * 1000 : this.weight.value;
57
+ let weightFilteredData = sizeItemData.filter(x => (x.maxweight <= 20 ? x.maxweight * 1000 : x.maxweight) === comparisonWeight);
58
+ // if no value found select the next available value
59
+ if (weightFilteredData.length === 0) {
60
+ weightFilteredData = sizeItemData.filter(x => (x.maxweight <= 20 ? x.maxweight * 1000 : x.maxweight) >= comparisonWeight);
61
+ if (weightFilteredData.length > 0) {
62
+ //sort based on the maxvalue
63
+ weightFilteredData.sort((a, b) => { return (a.maxweight - b.maxweight); });
64
+ // map to get the next unique item
65
+ const uniqueWeightOptions = [...new Map(weightFilteredData.reverse().map(item => [item["id"], item])).values()];
66
+ if (uniqueWeightOptions.length > 0) {
67
+ weightFilteredData = uniqueWeightOptions;
68
+ }
69
+ }
70
+ }
71
+ this.filteredItems = weightFilteredData;
72
+ }
73
+ render() {
74
+ return (h("div", null,
75
+ h("div", { class: "findprice-form" },
76
+ h("div", null, (h("div", { class: "heading" }, state.i18n.deliveryscopeheading))),
77
+ h("div", null,
78
+ (h("div", { class: "heading" }, state.i18n.componentheading)),
79
+ h("div", { class: "sizecategory" }, sizeCategories.map((sizeCategory) => (h("pn-choice-button", { choiceid: sizeCategory.value, value: sizeCategory.value, name: "sizecategory", type: "radio", checked: sizeCategory.value === this.sizecategory.value, onChange: () => {
80
+ this.sizecategory = sizeCategories.filter(x => x.value === sizeCategory.value)[0];
81
+ if (this.weight.value === 0) {
82
+ this.weight = weights[this.sizecategory.unit][0];
83
+ this.weightvalue = this.weight.value;
84
+ }
85
+ } },
86
+ h("pn-illustration", { illustration: sizeCategory.illustration }),
87
+ " ",
88
+ sizeCategory.name))))),
89
+ (this.sizecategory.value && weights[this.sizecategory.unit]) ? (h("div", null,
90
+ (state.i18n.sizeheading) ? (h("div", { class: "heading" }, state.i18n.sizeheading)) : null,
91
+ h("div", { class: "weightoption" },
92
+ h("div", { class: "weightoption-input" },
93
+ h("pn-input", { inputid: "weightvalue", name: "weightvalue", type: "number", label: state.i18n.weightlabel, value: this.weightvalue, onChange: (e) => {
94
+ if (e && e.target && e.target.value) {
95
+ const weightNum = parseInt(e.target.value, 10);
96
+ if (!isNaN(weightNum)) {
97
+ let matchingWeights = weights[this.sizecategory.unit].filter((x) => {
98
+ let weightInGrams = (x.abbreviation === "kg") ? x.value * 1000 : x.value;
99
+ return weightInGrams >= weightNum;
100
+ });
101
+ if (matchingWeights && matchingWeights.length > 0) {
102
+ this.weight = matchingWeights[0];
103
+ this.weightvalue = this.weight.value;
104
+ }
105
+ }
106
+ }
107
+ } }),
108
+ h("span", { class: "weightoption-input-abbreviation" }, this.weight.abbreviation)),
109
+ h("div", { class: "weightoption-range" },
110
+ h("input", { type: "range", id: "weightrange", name: "weightrange", list: "weightlist", value: (!this.weight.value) ? 0 : weights[this.sizecategory.unit].findIndex((x) => x.value === this.weightvalue), onChange: (e) => {
111
+ const value = e.target.value;
112
+ this.weight = weights[this.sizecategory.unit][value];
113
+ this.weightvalue = this.weight.value;
114
+ }, min: "0",
115
+ // max={ weights[this.postagetype.value][weights[this.postagetype.value].length - 1].value }
116
+ max: weights[this.sizecategory.unit].length - 1 }),
117
+ h("datalist", { id: "weightlist" }, weights[this.sizecategory.unit].map((weight, weightindex) => {
118
+ let labelText = weight.name;
119
+ if (weights[this.sizecategory.unit].length > 6) {
120
+ labelText = (weightindex % 5 === 0 || weightindex === 0 || weightindex === weights[this.sizecategory.unit].length - 1) ? weight.name : '';
121
+ }
122
+ return (h("option", Object.assign({ value: weightindex }, (labelText ? { label: labelText } : {}))));
123
+ })))))) : null),
124
+ (this.filteredItems && this.filteredItems.length > 0) ? (h("div", { class: "resultlist" },
125
+ (state.i18n.resultlistheading) ? (h("div", { class: "heading" }, state.i18n.resultlistheading)) : null,
126
+ this.filteredItems.map((item) => (h("div", null,
127
+ h("pn-find-price-result", { item: item })))))) : null));
128
+ }
129
+ static get is() { return "pn-find-price"; }
130
+ static get originalStyleUrls() { return {
131
+ "$": ["pn-find-price.scss"]
132
+ }; }
133
+ static get styleUrls() { return {
134
+ "$": ["pn-find-price.css"]
135
+ }; }
136
+ static get properties() { return {
137
+ "source": {
138
+ "type": "string",
139
+ "mutable": false,
140
+ "complexType": {
141
+ "original": "string",
142
+ "resolved": "string",
143
+ "references": {}
144
+ },
145
+ "required": false,
146
+ "optional": false,
147
+ "docs": {
148
+ "tags": [],
149
+ "text": ""
150
+ },
151
+ "attribute": "source",
152
+ "reflect": false,
153
+ "defaultValue": "\"https://com-integration.postnord.com/globalassets/global/prices/sv-findprice.xlsx\""
154
+ },
155
+ "language": {
156
+ "type": "string",
157
+ "mutable": true,
158
+ "complexType": {
159
+ "original": "string",
160
+ "resolved": "string",
161
+ "references": {}
162
+ },
163
+ "required": false,
164
+ "optional": false,
165
+ "docs": {
166
+ "tags": [],
167
+ "text": ""
168
+ },
169
+ "attribute": "language",
170
+ "reflect": false,
171
+ "defaultValue": "\"sv\""
172
+ },
173
+ "market": {
174
+ "type": "string",
175
+ "mutable": true,
176
+ "complexType": {
177
+ "original": "string",
178
+ "resolved": "string",
179
+ "references": {}
180
+ },
181
+ "required": false,
182
+ "optional": false,
183
+ "docs": {
184
+ "tags": [],
185
+ "text": ""
186
+ },
187
+ "attribute": "market",
188
+ "reflect": false,
189
+ "defaultValue": "\"se\""
190
+ }
191
+ }; }
192
+ static get states() { return {
193
+ "filteredItems": {},
194
+ "weight": {},
195
+ "weightvalue": {},
196
+ "sourceData": {},
197
+ "sizecategory": {}
198
+ }; }
199
+ static get watchers() { return [{
200
+ "propName": "market",
201
+ "methodName": "setState"
202
+ }, {
203
+ "propName": "language",
204
+ "methodName": "setState"
205
+ }, {
206
+ "propName": "weightvalue",
207
+ "methodName": "filterItems"
208
+ }, {
209
+ "propName": "sizecategory",
210
+ "methodName": "filterItems"
211
+ }]; }
212
+ }
@@ -40,4 +40,58 @@ async function convertFileFromStream(stream, filterColumnNames = ["what", "deliv
40
40
  return fileData;
41
41
  }
42
42
 
43
- export { convertFileFromStream };
43
+ async function convertFileForSizeCategogy(stream, filterColumnNames = ["sizecategory"]) {
44
+ const toFilterValue = (x) => x.toLowerCase().replace(/\s+/g, '');
45
+ const sheets = await readXlsxFile(stream, { getSheets: true })
46
+ let dataRows = [];
47
+ let sizecategoryColumn;
48
+ let sheetsData = await Promise.all(sheets.map(async (sheet) => { return await readXlsxFile(stream, { sheet: sheet.name }) }));
49
+
50
+ let types = {};
51
+ sheetsData.forEach(sheetData => {
52
+ const firstRow = sheetData.shift().map(x => toFilterValue(x));
53
+ // Set up column for adding options
54
+ firstRow.forEach((col, i) => {
55
+ if (typeof types[col] === "undefined" && filterColumnNames.includes(col)) {
56
+ types[col] = [];
57
+ }
58
+ if(col === "sizecategory")
59
+ sizecategoryColumn = i;
60
+ });
61
+
62
+ sheetData.forEach((row, rowindex) => {
63
+ // read sizeCategory column of each row and split it to save data for each item
64
+ const firstColRow = row[sizecategoryColumn];
65
+ const sizeCatColumnValue = firstColRow.split('/');
66
+
67
+ sizeCatColumnValue.forEach((value, j) => {
68
+ const dataRow = {};
69
+
70
+ firstRow.forEach(async (col, i) => {
71
+ const rowVal = (i === sizecategoryColumn) ? value : row[i];
72
+ dataRow[col] = rowVal;
73
+
74
+ // Add to types options
75
+ if (filterColumnNames.includes(col)) {
76
+ const filterVal = toFilterValue(rowVal);
77
+ dataRow[col] = filterVal;
78
+
79
+ if (!types[col].includes(filterVal)) {
80
+ types[col].push(filterVal);
81
+ }
82
+ }
83
+ });
84
+ dataRows.push(dataRow);
85
+ });
86
+ });
87
+ });
88
+
89
+
90
+ const fileData = {
91
+ "types": types,
92
+ "data": dataRows
93
+ };
94
+ return fileData;
95
+ }
96
+
97
+ export { convertFileFromStream, convertFileForSizeCategogy };
@@ -32,6 +32,18 @@ export const PnFilterSearch: {
32
32
  new (): PnFilterSearch;
33
33
  };
34
34
 
35
+ interface PnFindPrice extends Components.PnFindPrice, HTMLElement {}
36
+ export const PnFindPrice: {
37
+ prototype: PnFindPrice;
38
+ new (): PnFindPrice;
39
+ };
40
+
41
+ interface PnFindPriceResult extends Components.PnFindPriceResult, HTMLElement {}
42
+ export const PnFindPriceResult: {
43
+ prototype: PnFindPriceResult;
44
+ new (): PnFindPriceResult;
45
+ };
46
+
35
47
  interface PnFindServiceAndPrice extends Components.PnFindServiceAndPrice, HTMLElement {}
36
48
  export const PnFindServiceAndPrice: {
37
49
  prototype: PnFindServiceAndPrice;