@postnord/pn-marketweb-components 1.0.7 → 1.0.8
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/cjs/loader.cjs.js +1 -1
- package/cjs/pn-choice-button_2.cjs.entry.js +2 -2
- package/cjs/{pn-find-service-and-price-store-7ced0e29.js → pn-find-service-and-price-store-56d8b760.js} +3 -1
- package/cjs/pn-find-service-and-price.cjs.entry.js +37 -20
- package/cjs/pn-market-web-components.cjs.js +1 -1
- package/cjs/pn-product-pricelist-result.cjs.entry.js +13 -2
- package/cjs/{pn-product-pricelist-store-ffd73312.js → pn-product-pricelist-store-e4f8503b.js} +5 -1
- package/cjs/pn-product-pricelist.cjs.entry.js +114 -5
- package/cjs/pn-product-tile_3.cjs.entry.js +4 -4
- package/collection/components/widgets/pn-find-service-and-price/find-service-and-price.stories.js +1 -1
- package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price-result.js +4 -4
- package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price-store.js +3 -1
- package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price-translations.js +10 -0
- package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price.css +5 -1
- package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price.js +25 -18
- package/collection/components/widgets/pn-product-pricelist/data.js +17 -15
- package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-result.js +22 -7
- package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-store.js +5 -1
- package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-translations.js +20 -0
- package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist.css +50 -1
- package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist.js +76 -2
- package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist.stories.js +1 -1
- package/collection/components/widgets/pn-product-tile/pn-product-tile-price.css +5 -3
- package/collection/components/widgets/pn-product-tile/pn-product-tile-price.js +6 -11
- package/collection/components/widgets/pn-product-tile/pn-product-tile.css +4 -4
- package/collection/components/widgets/pn-product-tile/pn-product-tile.js +3 -3
- package/custom-elements/index.js +184 -41
- package/esm/loader.js +1 -1
- package/esm/pn-choice-button_2.entry.js +2 -2
- package/esm/{pn-find-service-and-price-store-0c7083bd.js → pn-find-service-and-price-store-d02cbfe1.js} +3 -1
- package/esm/pn-find-service-and-price.entry.js +37 -20
- package/esm/pn-market-web-components.js +1 -1
- package/esm/pn-product-pricelist-result.entry.js +13 -2
- package/esm/{pn-product-pricelist-store-82211c4a.js → pn-product-pricelist-store-6259b354.js} +5 -1
- package/esm/pn-product-pricelist.entry.js +114 -5
- package/esm/pn-product-tile_3.entry.js +4 -4
- package/esm-es5/loader.js +1 -1
- package/esm-es5/pn-choice-button_2.entry.js +1 -1
- package/esm-es5/{pn-find-service-and-price-store-0c7083bd.js → pn-find-service-and-price-store-d02cbfe1.js} +1 -1
- package/esm-es5/pn-find-service-and-price.entry.js +1 -1
- package/esm-es5/pn-market-web-components.js +1 -1
- package/esm-es5/pn-product-pricelist-result.entry.js +1 -1
- package/esm-es5/pn-product-pricelist-store-6259b354.js +1 -0
- package/esm-es5/pn-product-pricelist.entry.js +1 -1
- package/esm-es5/pn-product-tile_3.entry.js +1 -1
- package/package.json +1 -1
- package/pn-market-web-components/p-3ae134bf.system.entry.js +1 -0
- package/pn-market-web-components/{p-d0e7e65c.system.js → p-43bb8707.system.js} +1 -1
- package/pn-market-web-components/p-4b4ee8d5.system.entry.js +1 -0
- package/pn-market-web-components/p-57a1db89.system.entry.js +1 -0
- package/pn-market-web-components/p-62700d6e.system.js +1 -1
- package/pn-market-web-components/{p-f37be6ee.system.entry.js → p-80fd4dd9.system.entry.js} +1 -1
- package/pn-market-web-components/p-926fc962.js +1 -0
- package/pn-market-web-components/p-a04d0ba4.entry.js +1 -0
- package/pn-market-web-components/{p-64a6c2fb.js → p-af861bb5.js} +1 -1
- package/pn-market-web-components/p-b129cc27.system.js +1 -0
- package/pn-market-web-components/p-b4904bdb.system.entry.js +1 -0
- package/pn-market-web-components/p-ba704cbf.entry.js +1 -0
- package/pn-market-web-components/p-ba8e9dfe.entry.js +1 -0
- package/pn-market-web-components/{p-dc5ff15f.entry.js → p-d3590589.entry.js} +1 -1
- package/pn-market-web-components/p-e377410f.entry.js +1 -0
- package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
- package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price-store.d.ts +4 -0
- package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price-translations.d.ts +10 -0
- package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price-types.d.ts +2 -0
- package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-result.d.ts +2 -0
- package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-store.d.ts +8 -0
- package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-translations.d.ts +20 -0
- package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-types.d.ts +9 -0
- package/types/components/widgets/pn-product-pricelist/pn-product-pricelist.d.ts +4 -0
- package/esm-es5/pn-product-pricelist-store-82211c4a.js +0 -1
- package/pn-market-web-components/p-1905c548.entry.js +0 -1
- package/pn-market-web-components/p-1fe6de09.entry.js +0 -1
- package/pn-market-web-components/p-23743bec.system.entry.js +0 -1
- package/pn-market-web-components/p-23d34c82.system.entry.js +0 -1
- package/pn-market-web-components/p-2fa246f1.system.js +0 -1
- package/pn-market-web-components/p-44f74289.system.entry.js +0 -1
- package/pn-market-web-components/p-4f283190.js +0 -1
- package/pn-market-web-components/p-c06b37c7.entry.js +0 -1
- package/pn-market-web-components/p-c9af6ced.entry.js +0 -1
- package/pn-market-web-components/p-ea9afb95.system.entry.js +0 -1
package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price.css
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
pn-find-service-and-price .findprice-form {
|
|
2
|
+
max-width: 50em;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
}
|
|
1
5
|
pn-find-service-and-price h2,
|
|
2
6
|
pn-find-service-and-price .heading {
|
|
3
7
|
text-align: center;
|
|
@@ -29,7 +33,7 @@ pn-find-service-and-price .weightoption-input-abbreviation {
|
|
|
29
33
|
top: 50%;
|
|
30
34
|
transform: translateY(-50%);
|
|
31
35
|
right: 1.2em;
|
|
32
|
-
margin-top:
|
|
36
|
+
margin-top: 1.55rem;
|
|
33
37
|
font-weight: 500;
|
|
34
38
|
}
|
|
35
39
|
pn-find-service-and-price .weightoption-range {
|
package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price.js
CHANGED
|
@@ -18,20 +18,21 @@ export class PnfindServiceAndPrice {
|
|
|
18
18
|
componentWillLoad() {
|
|
19
19
|
this.setState();
|
|
20
20
|
this.getDataSource();
|
|
21
|
-
window.setTimeout(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, 500)
|
|
27
|
-
// this.filterItems();
|
|
21
|
+
// window.setTimeout(() => {
|
|
22
|
+
// this.postagetype = postagetypes[0];
|
|
23
|
+
// this.deliveryscope = deliveryscopes[this.postagetype.value][0];
|
|
24
|
+
// this.weight = weights[this.postagetype.value][0];
|
|
25
|
+
// this.weightvalue = this.weight.value;
|
|
26
|
+
// }, 500)
|
|
28
27
|
}
|
|
29
28
|
async getDataSource() {
|
|
30
|
-
const
|
|
29
|
+
const cacheBusting = `?cache=${Math.floor(Math.random() * (10000 - 1) + 1)}`;
|
|
30
|
+
const req = await fetch(this.source + cacheBusting);
|
|
31
31
|
const reqbody = await req.blob();
|
|
32
32
|
try {
|
|
33
33
|
const convertedData = await convertFileFromStream(reqbody);
|
|
34
34
|
this.sourceData = convertedData;
|
|
35
|
+
this.filterItems();
|
|
35
36
|
}
|
|
36
37
|
catch (e) {
|
|
37
38
|
console.log('Unable to parse data');
|
|
@@ -65,27 +66,29 @@ export class PnfindServiceAndPrice {
|
|
|
65
66
|
}
|
|
66
67
|
// For letters we use grams. Otherwise we use KG
|
|
67
68
|
const comparisonWeight = (this.weight.abbreviation.toLocaleLowerCase() === "kg" && this.postagetype.value === 'letter') ? this.weight.value * 1000 : this.weight.value;
|
|
68
|
-
let
|
|
69
|
+
let weightFilteredData = deliveryScopeData.filter(x => x.maxweight === comparisonWeight);
|
|
69
70
|
// In parcels the maxwidths don't necessarily start at 1kg so we fetch any type below the user selected value
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
if (
|
|
71
|
+
if (weightFilteredData.length === 0) {
|
|
72
|
+
weightFilteredData = deliveryScopeData.filter(x => x.maxweight >= comparisonWeight);
|
|
73
|
+
if (weightFilteredData.length > 0) {
|
|
73
74
|
// We reverse the result array since the map will take the last unique item instead of the first
|
|
74
|
-
const uniqueWeightOptions = [...new Map(
|
|
75
|
+
const uniqueWeightOptions = [...new Map(weightFilteredData.reverse().map(item => [item["id"], item])).values()];
|
|
75
76
|
if (uniqueWeightOptions.length > 0) {
|
|
76
|
-
|
|
77
|
+
weightFilteredData = uniqueWeightOptions;
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
console.log('weightFilteredData', weightFilteredData);
|
|
82
|
+
this.filteredItems = weightFilteredData;
|
|
81
83
|
}
|
|
82
84
|
render() {
|
|
83
85
|
return (h("div", null,
|
|
84
|
-
h("div", { class: "form" },
|
|
86
|
+
h("div", { class: "findprice-form" },
|
|
85
87
|
(state.i18n.componentheading) ? (h("h2", null, state.i18n.componentheading)) : null,
|
|
86
88
|
h("div", { class: "postagetypes" }, postagetypes.map((postagetype) => (h("pn-choice-button", { choiceid: postagetype.value, value: postagetype.value, name: "postagetype", type: "radio", checked: postagetype.value === this.postagetype.value, onChange: () => {
|
|
87
89
|
this.postagetype = postagetypes.filter(x => x.value === postagetype.value)[0];
|
|
88
|
-
this.
|
|
90
|
+
this.deliveryscope = { value: "", name: "", icon: "" };
|
|
91
|
+
this.weight = { value: 0, name: "" };
|
|
89
92
|
this.weightvalue = this.weight.value;
|
|
90
93
|
} },
|
|
91
94
|
h("pn-illustration", { illustration: postagetype.illustration }),
|
|
@@ -95,6 +98,10 @@ export class PnfindServiceAndPrice {
|
|
|
95
98
|
(state.i18n.deliveryscopeheading) ? (h("div", { class: "heading" }, state.i18n.deliveryscopeheading)) : null,
|
|
96
99
|
h("div", { class: "deliveryscope" }, deliveryscopes[this.postagetype.value].map((deliveryscope) => (h("pn-choice-button", { choiceid: this.postagetype.value + deliveryscope.value, value: deliveryscope.value, name: "deliveryscope", type: "radio", checked: deliveryscope.value === this.deliveryscope.value, onChange: () => {
|
|
97
100
|
this.deliveryscope = deliveryscopes[this.postagetype.value].filter(x => x.value === deliveryscope.value)[0];
|
|
101
|
+
if (this.weight.value === 0) {
|
|
102
|
+
this.weight = weights[this.postagetype.value][0];
|
|
103
|
+
this.weightvalue = this.weight.value;
|
|
104
|
+
}
|
|
98
105
|
} },
|
|
99
106
|
h("pn-illustration", { illustration: deliveryscope.illustration }),
|
|
100
107
|
" ",
|
|
@@ -134,7 +141,7 @@ export class PnfindServiceAndPrice {
|
|
|
134
141
|
}
|
|
135
142
|
return (h("option", Object.assign({ value: weightindex }, (labelText ? { label: labelText } : {}))));
|
|
136
143
|
})))))) : null),
|
|
137
|
-
(this.filteredItems) ? (h("div", { class: "resultlist" },
|
|
144
|
+
(this.filteredItems && this.filteredItems.length > 0) ? (h("div", { class: "resultlist" },
|
|
138
145
|
(state.i18n.resultlistheading) ? (h("div", { class: "heading" }, state.i18n.resultlistheading)) : null,
|
|
139
146
|
this.filteredItems.map((item) => (h("div", null,
|
|
140
147
|
h("pn-find-service-and-price-result", { item: item })))))) : null));
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
const postagetypes = [
|
|
2
|
-
{ name: "Brev", value: "letter",
|
|
3
|
-
{ name: "Paket", value: "parcel",
|
|
4
|
-
]
|
|
2
|
+
{ name: "Brev", value: "letter", illustration: "letterbox-reply-letter-plants" },
|
|
3
|
+
{ name: "Paket", value: "parcel", illustration: "tracking" }
|
|
4
|
+
];
|
|
5
|
+
|
|
6
|
+
const deliveryscopes = {
|
|
7
|
+
"letter": [
|
|
8
|
+
{ name: "Sweden", value: "sweden", illustration: "letterboxes" },
|
|
9
|
+
{ name: "Abroad", value: "abroad", illustration: "character-box-letters-globe" },
|
|
10
|
+
|
|
11
|
+
],
|
|
12
|
+
"parcel": [
|
|
13
|
+
{ name: "Sweden", value: "sweden", illustration: "letterboxes" },
|
|
14
|
+
{ name: "Within Europe", value:"withineurope", illustration: "character-box-letters-globe" },
|
|
15
|
+
{ name: "Outside Europe", value:"outsideeurope", illustration: "discover" },
|
|
16
|
+
]
|
|
17
|
+
};
|
|
5
18
|
|
|
6
19
|
const weights = {
|
|
7
20
|
"letter": [
|
|
@@ -35,17 +48,6 @@ const weights = {
|
|
|
35
48
|
]
|
|
36
49
|
};
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
"letter": [
|
|
40
|
-
{ name: "Sweden", value: "sweden", icon: "home" },
|
|
41
|
-
{ name: "Abroad", value: "abroad", icon: "globe" },
|
|
42
|
-
|
|
43
|
-
],
|
|
44
|
-
"parcel": [
|
|
45
|
-
{ name: "Sweden", value: "sweden", icon: "home" },
|
|
46
|
-
{ name: "Within Europe", value:"withineurope", icon: "compass" },
|
|
47
|
-
{ name: "Outside Europe", value:"outsideeurope", icon: "globe" },
|
|
48
|
-
]
|
|
49
|
-
};
|
|
51
|
+
|
|
50
52
|
|
|
51
53
|
export { postagetypes, weights, deliveryscopes};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { Component, h, Prop, Host } from "@stencil/core";
|
|
1
|
+
import { Component, h, Prop, Host, State, Watch } from "@stencil/core";
|
|
2
2
|
import { state } from "./pn-product-pricelist-store";
|
|
3
3
|
export class PnFindProductPricelistResult {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.item = null;
|
|
6
6
|
this.shownitems = [];
|
|
7
|
+
this.weightText = "";
|
|
7
8
|
}
|
|
8
9
|
componentWillLoad() {
|
|
10
|
+
this.composeItems();
|
|
11
|
+
}
|
|
12
|
+
composeItems() {
|
|
13
|
+
this.shownitems = [];
|
|
9
14
|
if (this.item.pricestamps) {
|
|
10
15
|
this.shownitems.push(Object.assign(Object.assign({}, this.item), { priceagent: null, pricesenddirect: null }));
|
|
11
16
|
}
|
|
@@ -15,6 +20,9 @@ export class PnFindProductPricelistResult {
|
|
|
15
20
|
if (this.item.pricesenddirect) {
|
|
16
21
|
this.shownitems.push(Object.assign(Object.assign({}, this.item), { pricestamps: null, priceagent: null }));
|
|
17
22
|
}
|
|
23
|
+
// Parcels are always in KG. Letter KG must be converted from grams
|
|
24
|
+
this.weightText = (this.item.what === "parcel") ? this.item.maxweight + 'kg' :
|
|
25
|
+
(this.item.what === "letter" && this.item.maxweight > 999) ? Math.round(this.item.maxweight / 1000) + " kg" : this.item.maxweight + " g";
|
|
18
26
|
}
|
|
19
27
|
render() {
|
|
20
28
|
return (h(Host, null, this.shownitems.map((item) => (h("pn-product-tile", null,
|
|
@@ -24,12 +32,12 @@ export class PnFindProductPricelistResult {
|
|
|
24
32
|
h("h3", null, item.name),
|
|
25
33
|
(item.description) ? (h("div", { class: "description" }, item.description)) : null,
|
|
26
34
|
(item.info) ? (h("div", { class: "description" }, item.info)) : null)),
|
|
27
|
-
item.maxweight ? (h("pn-product-tile-info", { label: state.i18n.maxweightlabel, text:
|
|
35
|
+
item.maxweight ? (h("pn-product-tile-info", { label: state.i18n.maxweightlabel, text: this.weightText })) : null,
|
|
28
36
|
item.maximummeasurements ? (h("pn-product-tile-info", { label: state.i18n.maxmeasurementlabel, text: item.maximummeasurements })) : null,
|
|
29
|
-
item.pricestamps ? (h("pn-product-tile-price", { slot: "price", label:
|
|
30
|
-
item.priceagent ? (h("pn-product-tile-price", { slot: "price", label: "
|
|
31
|
-
item.pricesenddirect ? (h("pn-product-tile-price", { slot: "price", label:
|
|
32
|
-
item.
|
|
37
|
+
item.pricestamps ? (h("pn-product-tile-price", { slot: "price", label: state.i18n.stampshopcta, amount: item.pricestamps + '', currency: state.market.currency })) : 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.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,
|
|
40
|
+
item.note ? (h("small", { slot: "note" },
|
|
33
41
|
h("p", null, item.note))) : null)))));
|
|
34
42
|
}
|
|
35
43
|
static get is() { return "pn-product-pricelist-result"; }
|
|
@@ -42,7 +50,7 @@ export class PnFindProductPricelistResult {
|
|
|
42
50
|
static get properties() { return {
|
|
43
51
|
"item": {
|
|
44
52
|
"type": "unknown",
|
|
45
|
-
"mutable":
|
|
53
|
+
"mutable": true,
|
|
46
54
|
"complexType": {
|
|
47
55
|
"original": "ProductPriceItem",
|
|
48
56
|
"resolved": "ProductPriceItem",
|
|
@@ -83,4 +91,11 @@ export class PnFindProductPricelistResult {
|
|
|
83
91
|
"defaultValue": "[]"
|
|
84
92
|
}
|
|
85
93
|
}; }
|
|
94
|
+
static get states() { return {
|
|
95
|
+
"weightText": {}
|
|
96
|
+
}; }
|
|
97
|
+
static get watchers() { return [{
|
|
98
|
+
"propName": "item",
|
|
99
|
+
"methodName": "composeItems"
|
|
100
|
+
}]; }
|
|
86
101
|
}
|
|
@@ -3,7 +3,11 @@ import { createStore } from "@stencil/store";
|
|
|
3
3
|
const { state, onChange } = createStore({
|
|
4
4
|
i18n: {
|
|
5
5
|
maxweightlabel: '',
|
|
6
|
-
|
|
6
|
+
weightlabel: '',
|
|
7
|
+
maxmeasurementlabel: '',
|
|
8
|
+
sizeheading: '',
|
|
9
|
+
senddirectcta: '',
|
|
10
|
+
stampshopcta: '',
|
|
7
11
|
},
|
|
8
12
|
market: {
|
|
9
13
|
currency: ""
|
package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-translations.js
CHANGED
|
@@ -1,23 +1,43 @@
|
|
|
1
1
|
export const translations = {
|
|
2
2
|
'sv': {
|
|
3
3
|
'maxweightlabel': 'Maxvikt',
|
|
4
|
+
'weightlabel': 'Vikt',
|
|
4
5
|
'maxmeasurementlabel': 'Maxvolym',
|
|
6
|
+
'sizeheading': 'Hur mycket väger det?',
|
|
7
|
+
'senddirectcta': 'Köp frakt via Skicka Direkt',
|
|
8
|
+
'stampshopcta': 'Köp frimärken via vår webshop',
|
|
5
9
|
},
|
|
6
10
|
'en': {
|
|
7
11
|
'maxweightlabel': 'Max weight',
|
|
12
|
+
'weightlabel': 'Weight',
|
|
8
13
|
'maxmeasurementlabel': 'Maximum measurement',
|
|
14
|
+
'sizeheading': 'How much does it weigh?',
|
|
15
|
+
'senddirectcta': 'Buy shipping in Send Direct',
|
|
16
|
+
'stampshopcta': 'Order home stamps from the webshop',
|
|
9
17
|
},
|
|
10
18
|
'da': {
|
|
11
19
|
'maxweightlabel': 'Max vægt',
|
|
20
|
+
'weightlabel': 'Vægt',
|
|
12
21
|
'maxmeasurementlabel': 'Maks. Volumen',
|
|
22
|
+
'sizeheading': 'How much does it weigh?',
|
|
23
|
+
'senddirectcta': 'Buy shipping in Send Direct',
|
|
24
|
+
'stampshopcta': 'Order home stamps from the webshop',
|
|
13
25
|
},
|
|
14
26
|
'no': {
|
|
15
27
|
'maxweightlabel': 'Maks vekt',
|
|
28
|
+
'weightlabel': 'Vekt',
|
|
16
29
|
'maxmeasurementlabel': 'Maks volum',
|
|
30
|
+
'sizeheading': 'How much does it weigh?',
|
|
31
|
+
'senddirectcta': 'Buy shipping in Send Direct',
|
|
32
|
+
'stampshopcta': 'Order home stamps from the webshop',
|
|
17
33
|
},
|
|
18
34
|
'fi': {
|
|
19
35
|
'maxweightlabel': 'Max paino',
|
|
36
|
+
'weightlabel': 'Piano',
|
|
20
37
|
'maxmeasurementlabel': 'Max äänenvoimakkuus',
|
|
38
|
+
'sizeheading': 'How much does it weigh?',
|
|
39
|
+
'senddirectcta': 'Buy shipping in Send Direct',
|
|
40
|
+
'stampshopcta': 'Order home stamps from the webshop',
|
|
21
41
|
}
|
|
22
42
|
};
|
|
23
43
|
export const markets = {
|
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
pn-product-pricelist pn-spinner {
|
|
2
2
|
margin: 1em auto;
|
|
3
3
|
}
|
|
4
|
+
pn-product-pricelist h2,
|
|
5
|
+
pn-product-pricelist .heading {
|
|
6
|
+
text-align: center;
|
|
7
|
+
font-size: 1.5em;
|
|
8
|
+
line-height: 1.1;
|
|
9
|
+
font-weight: bold;
|
|
10
|
+
margin-bottom: 1rem;
|
|
11
|
+
}
|
|
12
|
+
pn-product-pricelist .content,
|
|
13
|
+
pn-product-pricelist .weightselection {
|
|
14
|
+
max-width: 50em;
|
|
15
|
+
margin: 0 auto 1em;
|
|
16
|
+
}
|
|
17
|
+
pn-product-pricelist .weightoption {
|
|
18
|
+
display: flex;
|
|
19
|
+
gap: 1em;
|
|
20
|
+
}
|
|
21
|
+
pn-product-pricelist .weightoption-input {
|
|
22
|
+
width: 5em;
|
|
23
|
+
position: relative;
|
|
24
|
+
}
|
|
25
|
+
pn-product-pricelist .weightoption-input input::-webkit-outer-spin-button,
|
|
26
|
+
pn-product-pricelist .weightoption-input input::-webkit-inner-spin-button {
|
|
27
|
+
-webkit-appearance: none;
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
pn-product-pricelist .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-product-pricelist .weightoption-range {
|
|
39
|
+
flex-grow: 1;
|
|
40
|
+
align-self: flex-end;
|
|
41
|
+
position: relative;
|
|
42
|
+
top: 0.5em;
|
|
43
|
+
}
|
|
44
|
+
pn-product-pricelist .weightoption-range input {
|
|
45
|
+
width: calc(100% - 1.5em);
|
|
46
|
+
}
|
|
47
|
+
pn-product-pricelist .weightoption-range datalist {
|
|
48
|
+
width: 100%;
|
|
49
|
+
display: flex;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
font-size: 0.75em;
|
|
52
|
+
}
|
|
4
53
|
pn-product-pricelist .resultlist:not([data-list-count="0"]) {
|
|
5
|
-
margin-top:
|
|
54
|
+
margin-top: 2em;
|
|
6
55
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component, h, Prop, State, Host, Watch } from "@stencil/core";
|
|
2
2
|
import { translations, markets } from "./pn-product-pricelist-translations";
|
|
3
|
+
import { weights } from "./data.js";
|
|
3
4
|
import { convertFileFromStream } from "../../../globals/shared/productprice/convert.js";
|
|
4
5
|
import { state } from "./pn-product-pricelist-store";
|
|
5
6
|
export class PnFindProductPricelist {
|
|
@@ -12,6 +13,9 @@ export class PnFindProductPricelist {
|
|
|
12
13
|
this.sourceData = { types: [], data: [] };
|
|
13
14
|
this.gotData = false;
|
|
14
15
|
this.loading = false;
|
|
16
|
+
this.postagetype = { value: "" };
|
|
17
|
+
this.weight = { value: 0, name: "" };
|
|
18
|
+
this.weightvalue = 0;
|
|
15
19
|
}
|
|
16
20
|
componentWillLoad() {
|
|
17
21
|
this.setState();
|
|
@@ -49,7 +53,33 @@ export class PnFindProductPricelist {
|
|
|
49
53
|
return;
|
|
50
54
|
}
|
|
51
55
|
this.loading = false;
|
|
52
|
-
|
|
56
|
+
const productIdItems = this.sourceData.data.filter(x => x.id === this.productid);
|
|
57
|
+
if (productIdItems.length === 0) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.postagetype.value = productIdItems[0].what;
|
|
61
|
+
if (!weights[this.postagetype.value] || weights[this.postagetype.value].length === 0) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (this.weightvalue === 0) {
|
|
65
|
+
this.weight = weights[this.postagetype.value][0];
|
|
66
|
+
this.weightvalue = this.weight.value;
|
|
67
|
+
}
|
|
68
|
+
// For letters we use grams. Otherwise we use KG
|
|
69
|
+
const comparisonWeight = (this.weight.abbreviation.toLocaleLowerCase() === "kg" && this.postagetype.value === 'letter') ? this.weight.value * 1000 : this.weight.value;
|
|
70
|
+
let weightFilteredData = productIdItems.filter(x => x.maxweight === comparisonWeight);
|
|
71
|
+
// In parcels the maxwidths don't necessarily start at 1kg so we fetch any type below the user selected value
|
|
72
|
+
if (weightFilteredData.length === 0) {
|
|
73
|
+
weightFilteredData = productIdItems.filter(x => x.maxweight >= comparisonWeight);
|
|
74
|
+
if (weightFilteredData.length > 0) {
|
|
75
|
+
// We reverse the result array since the map will take the last unique item instead of the first
|
|
76
|
+
const uniqueWeightOptions = [...new Map(weightFilteredData.reverse().map(item => [item["id"], item])).values()];
|
|
77
|
+
if (uniqueWeightOptions.length > 0) {
|
|
78
|
+
weightFilteredData = uniqueWeightOptions;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
this.filteredItems = weightFilteredData;
|
|
53
83
|
this.gotData = this.filteredItems.length > 0;
|
|
54
84
|
}
|
|
55
85
|
render() {
|
|
@@ -57,6 +87,41 @@ export class PnFindProductPricelist {
|
|
|
57
87
|
h("div", { class: "content" },
|
|
58
88
|
h("slot", null)),
|
|
59
89
|
this.loading ? (h("pn-spinner", null)) : null,
|
|
90
|
+
(this.postagetype.value && weights[this.postagetype.value]) ? (h("div", { class: "weightselection" },
|
|
91
|
+
(state.i18n.sizeheading) ? (h("div", { class: "heading" }, state.i18n.sizeheading)) : null,
|
|
92
|
+
h("div", { class: "weightoption" },
|
|
93
|
+
h("div", { class: "weightoption-input" },
|
|
94
|
+
h("pn-input", { inputid: "weightvalue", name: "weightvalue", type: "number", label: state.i18n.weightlabel, value: this.weightvalue, onChange: (e) => {
|
|
95
|
+
if (e && e.target && e.target.value) {
|
|
96
|
+
const weightNum = parseInt(e.target.value, 10);
|
|
97
|
+
if (!isNaN(weightNum)) {
|
|
98
|
+
let matchingWeights = weights[this.postagetype.value].filter((x) => {
|
|
99
|
+
let weightInGrams = (x.abbreviation === "kg") ? x.value * 1000 : x.value;
|
|
100
|
+
return weightInGrams >= weightNum;
|
|
101
|
+
});
|
|
102
|
+
if (matchingWeights && matchingWeights.length > 0) {
|
|
103
|
+
this.weight = matchingWeights[0];
|
|
104
|
+
this.weightvalue = this.weight.value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} }),
|
|
109
|
+
h("span", { class: "weightoption-input-abbreviation" }, this.weight.abbreviation)),
|
|
110
|
+
h("div", { class: "weightoption-range" },
|
|
111
|
+
h("input", { type: "range", id: "weightrange", name: "weightrange", list: "weightlist", value: (!this.weight.value) ? 0 : weights[this.postagetype.value].findIndex((x) => x.value === this.weightvalue), onChange: (e) => {
|
|
112
|
+
const value = e.target.value;
|
|
113
|
+
this.weight = weights[this.postagetype.value][value];
|
|
114
|
+
this.weightvalue = this.weight.value;
|
|
115
|
+
}, min: "0",
|
|
116
|
+
// max={ weights[this.postagetype.value][weights[this.postagetype.value].length - 1].value }
|
|
117
|
+
max: weights[this.postagetype.value].length - 1 }),
|
|
118
|
+
h("datalist", { id: "weightlist" }, weights[this.postagetype.value].map((weight, weightindex) => {
|
|
119
|
+
let labelText = weight.name;
|
|
120
|
+
if (weights[this.postagetype.value].length > 6) {
|
|
121
|
+
labelText = (weightindex % 5 === 0 || weightindex === 0 || weightindex === weights[this.postagetype.value].length - 1) ? weight.name : '';
|
|
122
|
+
}
|
|
123
|
+
return (h("option", Object.assign({ value: weightindex }, (labelText ? { label: labelText } : {}))));
|
|
124
|
+
})))))) : null,
|
|
60
125
|
h("div", { class: "resultlist", "data-list-count": this.filteredItems.length }, this.filteredItems.map((item) => (h("div", null,
|
|
61
126
|
h("pn-product-pricelist-result", { item: item })))))));
|
|
62
127
|
}
|
|
@@ -145,7 +210,10 @@ export class PnFindProductPricelist {
|
|
|
145
210
|
"filteredItems": {},
|
|
146
211
|
"sourceData": {},
|
|
147
212
|
"gotData": {},
|
|
148
|
-
"loading": {}
|
|
213
|
+
"loading": {},
|
|
214
|
+
"postagetype": {},
|
|
215
|
+
"weight": {},
|
|
216
|
+
"weightvalue": {}
|
|
149
217
|
}; }
|
|
150
218
|
static get watchers() { return [{
|
|
151
219
|
"propName": "market",
|
|
@@ -153,5 +221,11 @@ export class PnFindProductPricelist {
|
|
|
153
221
|
}, {
|
|
154
222
|
"propName": "language",
|
|
155
223
|
"methodName": "setState"
|
|
224
|
+
}, {
|
|
225
|
+
"propName": "postagetype",
|
|
226
|
+
"methodName": "filterItems"
|
|
227
|
+
}, {
|
|
228
|
+
"propName": "weightvalue",
|
|
229
|
+
"methodName": "filterItems"
|
|
156
230
|
}]; }
|
|
157
231
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
pn-product-tile-price {
|
|
2
|
+
margin-top: 1em;
|
|
3
|
+
white-space: nowrap;
|
|
4
|
+
text-align: right;
|
|
5
|
+
}
|
|
1
6
|
pn-product-tile-price span:last-child {
|
|
2
7
|
display: inline-block;
|
|
3
8
|
margin-left: 0.2em;
|
|
@@ -5,9 +10,6 @@ pn-product-tile-price span:last-child {
|
|
|
5
10
|
pn-product-tile-price + pn-product-tile-price {
|
|
6
11
|
margin-left: 1.5em;
|
|
7
12
|
}
|
|
8
|
-
pn-product-tile-price small {
|
|
9
|
-
display: flex;
|
|
10
|
-
}
|
|
11
13
|
pn-product-tile-price pn-icon {
|
|
12
14
|
display: inline-block;
|
|
13
15
|
align-self: center;
|
|
@@ -5,19 +5,14 @@ export class PnProductTilePrice {
|
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
7
|
return (this.url) ? (h(Host, null,
|
|
8
|
-
h("a", { href: this.url },
|
|
9
|
-
(this.label) ? (h("p", null,
|
|
10
|
-
h("small", null,
|
|
11
|
-
this.label,
|
|
12
|
-
h("pn-icon", { symbol: "open-in-new", small: "true", color: "blue700" })))) : null,
|
|
13
|
-
h("h3", null,
|
|
14
|
-
(this.amount) ? (h("span", { class: "pn-2xl" }, this.amount)) : null,
|
|
15
|
-
(this.currency) ? (h("span", null, this.currency)) : null)))) : (h(Host, null,
|
|
16
|
-
(this.label) ? (h("p", null,
|
|
17
|
-
h("small", null, this.label))) : null,
|
|
18
8
|
h("h3", null,
|
|
19
9
|
(this.amount) ? (h("span", { class: "pn-2xl" }, this.amount)) : null,
|
|
20
|
-
(this.currency) ? (h("span",
|
|
10
|
+
(this.currency) ? (h("span", { class: "pn-2xl" }, this.currency)) : null),
|
|
11
|
+
(this.label) ? (h("a", { href: this.url },
|
|
12
|
+
h("pn-button", { small: "true", icon: "arrow-right" }, this.label))) : null)) : (h(Host, null,
|
|
13
|
+
h("h3", null,
|
|
14
|
+
(this.amount) ? (h("span", { class: "pn-2xl" }, this.amount)) : null,
|
|
15
|
+
(this.currency) ? (h("span", { class: "pn-2xl" }, this.currency)) : null)));
|
|
21
16
|
}
|
|
22
17
|
static get is() { return "pn-product-tile-price"; }
|
|
23
18
|
static get originalStyleUrls() { return {
|
|
@@ -24,16 +24,16 @@ pn-product-tile > pn-illustration {
|
|
|
24
24
|
align-self: center;
|
|
25
25
|
}
|
|
26
26
|
pn-product-tile .tilecontent {
|
|
27
|
-
|
|
28
|
-
flex-direction:
|
|
29
|
-
align-items: flex-start;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: row;
|
|
30
29
|
justify-content: center;
|
|
30
|
+
flex-grow: 1;
|
|
31
31
|
}
|
|
32
32
|
pn-product-tile .details {
|
|
33
33
|
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
34
35
|
justify-content: space-between;
|
|
35
36
|
width: 100%;
|
|
36
|
-
align-items: center;
|
|
37
37
|
}
|
|
38
38
|
pn-product-tile .info {
|
|
39
39
|
display: flex;
|
|
@@ -4,12 +4,12 @@ export class PnProductTile {
|
|
|
4
4
|
return (h(Host, null,
|
|
5
5
|
h("slot", { name: "illustration" }),
|
|
6
6
|
h("div", { class: "tilecontent" },
|
|
7
|
-
h("slot", { name: "content" }),
|
|
8
7
|
h("div", { class: "details" },
|
|
8
|
+
h("slot", { name: "content" }),
|
|
9
9
|
h("div", { class: "info" },
|
|
10
10
|
h("slot", null)),
|
|
11
|
-
h("slot", { name: "
|
|
12
|
-
h("slot", { name: "
|
|
11
|
+
h("slot", { name: "note" })),
|
|
12
|
+
h("slot", { name: "price" }))));
|
|
13
13
|
}
|
|
14
14
|
static get is() { return "pn-product-tile"; }
|
|
15
15
|
static get originalStyleUrls() { return {
|