@saasquatch/mint-components 1.3.2-0 → 1.3.2-4
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/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/sqm-divided-layout_27.cjs.entry.js +373 -206
- package/dist/cjs/{sqm-task-card-view-cb11e56f.js → sqm-task-card-view-791797ac.js} +20 -17
- package/dist/cjs/sqm-task-card.cjs.entry.js +25 -4
- package/dist/collection/components/sqm-reward-exchange-list/SVGs.js +17 -0
- package/dist/collection/components/sqm-reward-exchange-list/progressBar.js +23 -34
- package/dist/collection/components/sqm-reward-exchange-list/sqm-reward-exchange-list-view.js +44 -27
- package/dist/collection/components/sqm-reward-exchange-list/sqm-reward-exchange-list.js +21 -21
- package/dist/collection/components/sqm-reward-exchange-list/useRewardExchangeList.js +6 -3
- package/dist/collection/components/sqm-task-card/TaskCard.stories.js +270 -62
- package/dist/collection/components/sqm-task-card/sqm-task-card-view.js +20 -16
- package/dist/collection/components/sqm-task-card/sqm-task-card.js +130 -22
- package/dist/collection/components/sqm-task-card/useTaskCard.js +0 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-divided-layout_27.entry.js +373 -206
- package/dist/esm/{sqm-task-card-view-6a082a21.js → sqm-task-card-view-5cce0847.js} +21 -17
- package/dist/esm/sqm-task-card.entry.js +25 -4
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mint-components.js +1 -1
- package/dist/esm-es5/sqm-divided-layout_27.entry.js +1 -1
- package/dist/esm-es5/sqm-task-card-view-5cce0847.js +1 -0
- package/dist/esm-es5/sqm-task-card.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-2b3a99df.js +1 -0
- package/dist/mint-components/{p-86cd9f79.entry.js → p-32918497.entry.js} +14 -12
- package/dist/mint-components/p-4e5a2105.system.entry.js +1 -0
- package/dist/mint-components/p-6198d500.system.entry.js +1 -0
- package/dist/mint-components/p-6932204f.system.js +1 -0
- package/dist/mint-components/p-91d39961.system.js +1 -1
- package/dist/mint-components/p-bbdafe3b.entry.js +1 -0
- package/dist/types/components/sqm-reward-exchange-list/SVGs.d.ts +2 -0
- package/dist/types/components/sqm-reward-exchange-list/progressBar.d.ts +3 -2
- package/dist/types/components/sqm-reward-exchange-list/sqm-reward-exchange-list-view.d.ts +3 -0
- package/dist/types/components/sqm-reward-exchange-list/sqm-reward-exchange-list.d.ts +2 -3
- package/dist/types/components/sqm-reward-exchange-list/useRewardExchangeList.d.ts +4 -7
- package/dist/types/components/sqm-task-card/TaskCard.stories.d.ts +1 -1
- package/dist/types/components/sqm-task-card/sqm-task-card-view.d.ts +10 -8
- package/dist/types/components/sqm-task-card/sqm-task-card.d.ts +24 -8
- package/dist/types/components/sqm-task-card/useTaskCard.d.ts +0 -0
- package/dist/types/components.d.ts +58 -28
- package/dist/types/global/android.d.ts +7 -0
- package/dist/types/global/demo.d.ts +1 -0
- package/dist/types/stories/features.d.ts +4 -0
- package/dist/types/stories/templates.d.ts +4 -0
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +1 -1
- package/dist/collection/components/sqm-reward-exchange-list/assets/Leftward Arrow.svg +0 -3
- package/dist/esm-es5/sqm-task-card-view-6a082a21.js +0 -1
- package/dist/mint-components/assets/Leftward Arrow.svg +0 -3
- package/dist/mint-components/p-12fb9197.entry.js +0 -1
- package/dist/mint-components/p-2ae9c535.js +0 -1
- package/dist/mint-components/p-550b4579.system.entry.js +0 -1
- package/dist/mint-components/p-795a7259.system.entry.js +0 -1
- package/dist/mint-components/p-d0913f8d.system.js +0 -1
|
@@ -21,7 +21,7 @@ const gift = () => {
|
|
|
21
21
|
|
|
22
22
|
// @ts-expect-error -- unused
|
|
23
23
|
function TaskCardView(props, children) {
|
|
24
|
-
const { points = 0, cardTitle, description,
|
|
24
|
+
const { points = 0, cardTitle = "Title Text", description = "Description Text", showProgressBar = false, progress = 0, goal = 1, repeatable = false, expire = false, dateExpire = "", buttonText = "Button Text", buttonLink = "www.example.com", } = props;
|
|
25
25
|
const checkmark_circle$1 = checkmark_circle();
|
|
26
26
|
const arrow_left_right$1 = arrow_left_right();
|
|
27
27
|
const style = {
|
|
@@ -64,6 +64,7 @@ function TaskCardView(props, children) {
|
|
|
64
64
|
},
|
|
65
65
|
"& .text": {
|
|
66
66
|
alignSelf: "end",
|
|
67
|
+
textTransform: "uppercase",
|
|
67
68
|
color: "var(--sl-color-gray-600)",
|
|
68
69
|
fontSize: "var(--sl-font-size-x-small)",
|
|
69
70
|
lineHeight: "var(--sl-font-size-medium)",
|
|
@@ -76,11 +77,7 @@ function TaskCardView(props, children) {
|
|
|
76
77
|
},
|
|
77
78
|
Footer: {
|
|
78
79
|
display: "flex",
|
|
79
|
-
"& span": {
|
|
80
|
-
verticalAlign: "text-bottom",
|
|
81
|
-
},
|
|
82
80
|
"& .icon": {
|
|
83
|
-
verticalAlign: "bottom",
|
|
84
81
|
fontSize: "var(--sl-font-size-xx-small)",
|
|
85
82
|
marginRight: "var(--sl-spacing-xx-small)",
|
|
86
83
|
},
|
|
@@ -104,21 +101,23 @@ function TaskCardView(props, children) {
|
|
|
104
101
|
jssPresetDefault_esm.jss.setup(jssPresetDefault_esm.create());
|
|
105
102
|
const sheet = jssPresetDefault_esm.jss.createStyleSheet(style);
|
|
106
103
|
const styleString = sheet.toString();
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
// if showProgressBar is false: progress >= goal
|
|
105
|
+
// if true
|
|
106
|
+
const showComplete = progress >= goal;
|
|
107
|
+
const repetitions = showProgressBar ? Math.floor(progress / goal) : progress;
|
|
109
108
|
return (index.h("div", { class: sheet.classes.TaskCard },
|
|
110
109
|
index.h("div", { class: showComplete ? "main complete" : "main" },
|
|
111
110
|
index.h("style", { type: "text/css" }, styleString),
|
|
112
111
|
index.h("div", { class: sheet.classes.Header },
|
|
113
112
|
showComplete && (index.h("span", { class: "icon" }, checkmark_circle$1)),
|
|
114
113
|
index.h("span", { class: "value" }, points),
|
|
115
|
-
index.h("span", { class: "text" }, "
|
|
114
|
+
index.h("span", { class: "text" }, "saasquatch points")),
|
|
116
115
|
index.h("div", { class: sheet.classes.Title }, cardTitle),
|
|
117
|
-
index.h(ProgressBar, Object.assign({}, props)),
|
|
116
|
+
showProgressBar && index.h(ProgressBar, Object.assign({}, props)),
|
|
118
117
|
index.h(Details, { description: description }),
|
|
119
118
|
index.h("div", { class: sheet.classes.Footer },
|
|
120
119
|
index.h("span", { class: "text" },
|
|
121
|
-
|
|
120
|
+
repeatable && (index.h("div", null,
|
|
122
121
|
index.h("span", { class: "icon" }, arrow_left_right$1),
|
|
123
122
|
index.h("span", null,
|
|
124
123
|
"Completed ",
|
|
@@ -133,8 +132,8 @@ function TaskCardView(props, children) {
|
|
|
133
132
|
index.h("br", null),
|
|
134
133
|
"Ends ",
|
|
135
134
|
" ",
|
|
136
|
-
|
|
137
|
-
index.h("sl-button", { class: "action", size: "small", onClick:
|
|
135
|
+
dateExpire))),
|
|
136
|
+
index.h("sl-button", { class: "action", size: "small", onClick: () => alert(buttonLink), disabled: showComplete }, showComplete ? "Complete" : buttonText)))));
|
|
138
137
|
}
|
|
139
138
|
function Details(props) {
|
|
140
139
|
const style = {
|
|
@@ -190,8 +189,7 @@ function ProgressBar(props) {
|
|
|
190
189
|
const gift2 = gift();
|
|
191
190
|
const gift3 = gift();
|
|
192
191
|
// if progress and goal are not provided, there cannot be a progress bar
|
|
193
|
-
if (!
|
|
194
|
-
return;
|
|
192
|
+
// if (!showProgressBar) return;
|
|
195
193
|
const items = [];
|
|
196
194
|
var columns = "";
|
|
197
195
|
var repetitions = Math.floor(progress / goal);
|
|
@@ -303,6 +301,8 @@ function ProgressBar(props) {
|
|
|
303
301
|
marginLeft: "-100px",
|
|
304
302
|
marginRight: "-100px",
|
|
305
303
|
position: "relative",
|
|
304
|
+
display: "list-item",
|
|
305
|
+
listStyleType: "none",
|
|
306
306
|
top: "-18px",
|
|
307
307
|
filter: goal <= progress ? "" : "grayscale(100%)",
|
|
308
308
|
zIndex: "1",
|
|
@@ -316,7 +316,11 @@ function ProgressBar(props) {
|
|
|
316
316
|
index.h("style", { type: "text/css" }, styleString),
|
|
317
317
|
index.h("div", { class: repetitions > 1 ? "progress-bar repeatable-steps" : "progress-bar" }, items)));
|
|
318
318
|
function addLinear() {
|
|
319
|
-
columns =
|
|
319
|
+
columns =
|
|
320
|
+
Math.min(Math.max(progress / goal, 0), 1) +
|
|
321
|
+
"fr 0fr " +
|
|
322
|
+
Math.min(Math.max(1 - progress / goal, 0), 1) +
|
|
323
|
+
"fr 0fr";
|
|
320
324
|
items.push(index.h("div", { class: "filled" }));
|
|
321
325
|
items.push(index.h("div", { class: progress == goal ? "progress bg" : "progress" }, unit + progress));
|
|
322
326
|
items.push(index.h("div", { class: "remain" }));
|
|
@@ -406,7 +410,7 @@ function ProgressBar(props) {
|
|
|
406
410
|
else if (i == goal * 2) {
|
|
407
411
|
columns += "0fr 0fr";
|
|
408
412
|
items.push(index.h("div", { class: "remain" }));
|
|
409
|
-
items.push(index.h("div", { class: "empty bg" }, unit + (
|
|
413
|
+
items.push(index.h("div", { class: "empty bg" }, unit + (goal * 2)));
|
|
410
414
|
items.push(index.h("div", { class: "end bw" }, gift2));
|
|
411
415
|
}
|
|
412
416
|
else {
|
|
@@ -468,5 +472,4 @@ function ProgressBar(props) {
|
|
|
468
472
|
}
|
|
469
473
|
}
|
|
470
474
|
|
|
471
|
-
exports.ProgressBar = ProgressBar;
|
|
472
475
|
exports.TaskCardView = TaskCardView;
|
|
@@ -7,24 +7,45 @@ const _extends = require('./extends-0302d27d.js');
|
|
|
7
7
|
require('./jss-preset-default.esm-6304d24f.js');
|
|
8
8
|
const utils = require('./utils-95e5317c.js');
|
|
9
9
|
require('./mixins-7b7c59fe.js');
|
|
10
|
-
const sqmTaskCardView = require('./sqm-task-card-view-
|
|
10
|
+
const sqmTaskCardView = require('./sqm-task-card-view-791797ac.js');
|
|
11
11
|
|
|
12
12
|
const TaskCard = class {
|
|
13
13
|
constructor(hostRef) {
|
|
14
14
|
index.registerInstance(this, hostRef);
|
|
15
15
|
this.ignored = true;
|
|
16
16
|
/**
|
|
17
|
-
* @uiName
|
|
17
|
+
* @uiName Reward Points
|
|
18
18
|
*/
|
|
19
19
|
this.points = 0;
|
|
20
20
|
/**
|
|
21
|
-
* @uiName
|
|
21
|
+
* @uiName Title Text
|
|
22
22
|
*/
|
|
23
|
-
this.
|
|
23
|
+
this.cardTitle = "Title Text";
|
|
24
|
+
/**
|
|
25
|
+
* @uiName Description Text
|
|
26
|
+
*/
|
|
27
|
+
this.description = "Description Text";
|
|
28
|
+
/**
|
|
29
|
+
* @uiName Set Repeatable
|
|
30
|
+
*/
|
|
31
|
+
this.repeatable = false;
|
|
32
|
+
/**
|
|
33
|
+
* @uiName Show Progress Bar
|
|
34
|
+
*/
|
|
35
|
+
this.showProgressBar = false;
|
|
36
|
+
/**
|
|
37
|
+
* @uiName Progress Bar Goal
|
|
38
|
+
*/
|
|
39
|
+
this.goal = 1;
|
|
40
|
+
/**
|
|
41
|
+
* @uiName Show Expiry
|
|
42
|
+
*/
|
|
43
|
+
this.expire = false;
|
|
24
44
|
_extends.h$1(this);
|
|
25
45
|
}
|
|
26
46
|
disconnectedCallback() { }
|
|
27
47
|
render() {
|
|
48
|
+
//const progress = useTaskCard(); progress={progress}
|
|
28
49
|
return index.h(sqmTaskCardView.TaskCardView, Object.assign({}, utils.getProps(this)));
|
|
29
50
|
}
|
|
30
51
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
export const LeftArrow = () => (h("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: { marginBottom: "-2px", marginRight: "5px" } },
|
|
3
|
+
h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M7.34655 1.90573C7.75405 2.31323 7.75405 2.97392 7.34655 3.38143L3.56266 7.16531H14.9565C15.5328 7.16531 16 7.6325 16 8.20879C16 8.78509 15.5328 9.25227 14.9565 9.25227H3.56266L7.69437 13.384C8.10188 13.7915 8.10188 14.4522 7.69437 14.8597C7.28687 15.2672 6.62617 15.2672 6.21867 14.8597L0.305628 8.94664C-0.101876 8.53914 -0.101876 7.87845 0.305628 7.47094L5.87084 1.90573C6.27835 1.49822 6.93904 1.49822 7.34655 1.90573Z", fill: "#858585" })));
|
|
4
|
+
export const ExchangeArrows = () => (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "42", height: "42", viewBox: "0 0 42 42", fill: "none" },
|
|
5
|
+
h("g", { filter: "url(#filter0_d_428_4515)" },
|
|
6
|
+
h("circle", { cx: "21", cy: "21", r: "15", fill: "white" })),
|
|
7
|
+
h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M16.6255 27.783C16.5129 27.8963 16.3597 27.96 16.2 27.96C16.0402 27.96 15.887 27.8963 15.7744 27.783L11.8744 23.8597C11.6408 23.6247 11.6419 23.2448 11.877 23.0112C12.112 22.7775 12.4919 22.7787 12.7255 23.0137L15.6 25.9054V14.52C15.6 14.1886 15.8686 13.92 16.2 13.92C16.5313 13.92 16.8 14.1886 16.8 14.52V25.9054L19.6744 23.0137C19.908 22.7787 20.2879 22.7775 20.5229 23.0112C20.758 23.2448 20.7591 23.6247 20.5255 23.8597L16.6255 27.783ZM26.2255 14.0971C26.1129 13.9838 25.9597 13.9201 25.8 13.9201C25.6402 13.9201 25.487 13.9838 25.3744 14.0971L21.4744 18.0204C21.2408 18.2554 21.2419 18.6353 21.477 18.8689C21.712 19.1025 22.0919 19.1014 22.3255 18.8664L25.2 15.9747V27.3601C25.2 27.6914 25.4686 27.9601 25.8 27.9601C26.1313 27.9601 26.4 27.6914 26.4 27.3601V15.9747L29.2744 18.8664C29.508 19.1014 29.8879 19.1025 30.1229 18.8689C30.358 18.6353 30.3591 18.2554 30.1255 18.0204L26.2255 14.0971Z", fill: "#333333" }),
|
|
8
|
+
h("defs", null,
|
|
9
|
+
h("filter", { id: "filter0_d_428_4515", x: "0", y: "0", width: "42", height: "42", filterUnits: "userSpaceOnUse", "color-interpolation-filters": "sRGB" },
|
|
10
|
+
h("feFlood", { "flood-opacity": "0", result: "BackgroundImageFix" }),
|
|
11
|
+
h("feColorMatrix", { in: "SourceAlpha", type: "matrix", values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0", result: "hardAlpha" }),
|
|
12
|
+
h("feOffset", null),
|
|
13
|
+
h("feGaussianBlur", { stdDeviation: "3" }),
|
|
14
|
+
h("feComposite", { in2: "hardAlpha", operator: "out" }),
|
|
15
|
+
h("feColorMatrix", { type: "matrix", values: "0 0 0 0 0.670833 0 0 0 0 0.670833 0 0 0 0 0.670833 0 0 0 0.2 0" }),
|
|
16
|
+
h("feBlend", { mode: "normal", in2: "BackgroundImageFix", result: "effect1_dropShadow_428_4515" }),
|
|
17
|
+
h("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect1_dropShadow_428_4515", result: "shape" })))));
|
|
@@ -13,6 +13,7 @@ function Dot({ active, completed, incomplete, }) {
|
|
|
13
13
|
justifyContent: "center",
|
|
14
14
|
columnGap: "50px",
|
|
15
15
|
marginRight: "-2px",
|
|
16
|
+
boxSizing: "content-box",
|
|
16
17
|
} },
|
|
17
18
|
h("div", { style: {
|
|
18
19
|
backgroundColor: completed ? "#9E9E9E" : "#FFF",
|
|
@@ -26,45 +27,33 @@ function Dot({ active, completed, incomplete, }) {
|
|
|
26
27
|
height: completed ? "12px" : "8px",
|
|
27
28
|
margin: "-4px auto 0px",
|
|
28
29
|
zIndex: "1",
|
|
30
|
+
boxSizing: "content-box",
|
|
29
31
|
} })));
|
|
30
32
|
}
|
|
33
|
+
function ProgressLine({ incomplete = false, active = false }) {
|
|
34
|
+
return (h("div", { style: {
|
|
35
|
+
content: "''",
|
|
36
|
+
flex: "0.5 0.5 0",
|
|
37
|
+
height: "4px",
|
|
38
|
+
borderRadius: "4px",
|
|
39
|
+
background: incomplete || active ? "#E5E5E5" : "#9E9E9E",
|
|
40
|
+
position: "relative",
|
|
41
|
+
bottom: "0",
|
|
42
|
+
left: "0",
|
|
43
|
+
display: "flex",
|
|
44
|
+
justifyContent: "center",
|
|
45
|
+
columnGap: "50px",
|
|
46
|
+
marginRight: "-2px",
|
|
47
|
+
boxSizing: "content-box",
|
|
48
|
+
} }));
|
|
49
|
+
}
|
|
31
50
|
function Progress({ active, completed, incomplete }) {
|
|
32
51
|
return [
|
|
33
|
-
h(
|
|
34
|
-
content: "''",
|
|
35
|
-
flex: "0.5 0.5 0",
|
|
36
|
-
height: "4px",
|
|
37
|
-
borderRadius: "4px",
|
|
38
|
-
background: incomplete ? "#E5E5E5" : "#9E9E9E",
|
|
39
|
-
position: "relative",
|
|
40
|
-
bottom: "0",
|
|
41
|
-
left: "0",
|
|
42
|
-
display: "flex",
|
|
43
|
-
justifyContent: "center",
|
|
44
|
-
columnGap: "50px",
|
|
45
|
-
marginRight: "-2px",
|
|
46
|
-
} }),
|
|
52
|
+
h(ProgressLine, { incomplete: incomplete }),
|
|
47
53
|
h(Dot, { active: active, completed: completed, incomplete: incomplete }),
|
|
48
|
-
h(
|
|
49
|
-
content: "''",
|
|
50
|
-
flex: "0.5 0.5 0",
|
|
51
|
-
height: "4px",
|
|
52
|
-
borderRadius: "4px",
|
|
53
|
-
background: incomplete || active ? "#E5E5E5" : "#9E9E9E",
|
|
54
|
-
position: "relative",
|
|
55
|
-
bottom: "0",
|
|
56
|
-
left: "0",
|
|
57
|
-
display: "flex",
|
|
58
|
-
justifyContent: "center",
|
|
59
|
-
columnGap: "50px",
|
|
60
|
-
marginRight: "-2px",
|
|
61
|
-
} }),
|
|
54
|
+
h(ProgressLine, { incomplete: incomplete, active: active }),
|
|
62
55
|
];
|
|
63
56
|
}
|
|
64
|
-
export function ProgressBar({
|
|
65
|
-
|
|
66
|
-
return (h("div", { style: { display: "flex", columnGap: "-2px" } },
|
|
67
|
-
h(Progress, { active: stage === 0, completed: stage > 0, incomplete: stage < 0 }),
|
|
68
|
-
h(Progress, { active: stage === 1, completed: stage > 1, incomplete: stage < 1 }),
|
|
69
|
-
h(Progress, { active: stage === 2, completed: stage > 2, incomplete: stage < 2 })));
|
|
57
|
+
export function ProgressBar({ stageCount, currentStage, }) {
|
|
58
|
+
return (h("div", { style: { display: "flex", columnGap: "-2px" } }, Array.from(Array(stageCount).keys()).map((stage) => (h(Progress, { active: currentStage === stage, completed: currentStage > stage, incomplete: currentStage < stage })))));
|
|
70
59
|
}
|
package/dist/collection/components/sqm-reward-exchange-list/sqm-reward-exchange-list-view.js
CHANGED
|
@@ -2,6 +2,7 @@ import { getAssetPath, h } from "@stencil/core";
|
|
|
2
2
|
import jss from "jss";
|
|
3
3
|
import preset from "jss-preset-default";
|
|
4
4
|
import { ProgressBar } from "./progressBar";
|
|
5
|
+
import { LeftArrow, ExchangeArrows } from "./SVGs";
|
|
5
6
|
const stageList = ["chooseReward", "chooseAmount", "confirmation", "success"];
|
|
6
7
|
const stageProgressList = {
|
|
7
8
|
chooseReward: "Choose reward",
|
|
@@ -69,6 +70,7 @@ export function RewardExchangeView(props) {
|
|
|
69
70
|
},
|
|
70
71
|
Buttons: {
|
|
71
72
|
bottom: "0",
|
|
73
|
+
width: "100%",
|
|
72
74
|
},
|
|
73
75
|
Button: {
|
|
74
76
|
margin: "10px 0",
|
|
@@ -84,19 +86,26 @@ export function RewardExchangeView(props) {
|
|
|
84
86
|
const { states, data, callbacks, refs } = props;
|
|
85
87
|
const { selectedItem, selectedStep } = states;
|
|
86
88
|
function getInput() {
|
|
87
|
-
var _a;
|
|
89
|
+
var _a, _b;
|
|
88
90
|
const item = states.selectedItem;
|
|
89
91
|
if (!item || (item === null || item === void 0 ? void 0 : item.ruleType) === "FIXED_GLOBAL_REWARD")
|
|
90
92
|
return h("span", null);
|
|
93
|
+
if (!((_a = item.steps) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
94
|
+
return h("p", null,
|
|
95
|
+
"Not enough ",
|
|
96
|
+
item.sourceUnit,
|
|
97
|
+
" to redeem for this reward.");
|
|
98
|
+
}
|
|
91
99
|
return (h("sl-select", { style: { width: "auto" }, label: "Select amount to receive", class: sheet.classes.Select, value: states.selectedStep, "onSl-select": (e) => {
|
|
92
100
|
var _a, _b, _c, _d, _e;
|
|
93
101
|
return callbacks.setExchangeState({
|
|
94
102
|
amount: (_c = (_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.item) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.sourceValue,
|
|
95
103
|
selectedStep: (_e = (_d = e.detail) === null || _d === void 0 ? void 0 : _d.item) === null || _e === void 0 ? void 0 : _e.value,
|
|
96
104
|
});
|
|
97
|
-
} }, (
|
|
105
|
+
} }, (_b = item.steps) === null || _b === void 0 ? void 0 : _b.map((step) => (h("sl-menu-item", { value: step, disabled: !step.available },
|
|
98
106
|
step.prettyDestinationValue,
|
|
99
|
-
h("
|
|
107
|
+
h("div", { slot: "suffix", style: { fontSize: "75%", float: "right" } }, step.prettySourceValue),
|
|
108
|
+
step.unavailableReasonCode && (h("p", { style: { fontSize: "70%", color: "#F2994A" } }, step.unavailableReasonCode)))))));
|
|
100
109
|
}
|
|
101
110
|
function chooseReward() {
|
|
102
111
|
var _a;
|
|
@@ -117,12 +126,24 @@ export function RewardExchangeView(props) {
|
|
|
117
126
|
boxShadow: item.key === (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.key) ? "0 1px 8px #87ceeb" : "none",
|
|
118
127
|
marginBottom: "10px 0",
|
|
119
128
|
flex: "1",
|
|
120
|
-
minWidth: "
|
|
129
|
+
minWidth: "100%",
|
|
130
|
+
color: !item.available && "#eee",
|
|
131
|
+
"&:hover": {
|
|
132
|
+
boxShadow: !item.available && "none",
|
|
133
|
+
},
|
|
121
134
|
};
|
|
122
|
-
return (h("div", { key: item.key, class: sheet.classes.CardContainer,
|
|
123
|
-
|
|
135
|
+
return (h("div", { key: item.key, class: sheet.classes.CardContainer,
|
|
136
|
+
//@ts-ignore
|
|
137
|
+
style: style },
|
|
138
|
+
h("sl-card", { class: sheet.classes.Base, onClick: () => item.available &&
|
|
139
|
+
callbacks.setExchangeState({ selectedItem: item }) },
|
|
124
140
|
h("img", { class: sheet.classes.PreviewImage, src: (item === null || item === void 0 ? void 0 : item.imageUrl) || getAssetPath("./assets/Reward-icon.png") }),
|
|
125
|
-
h("p",
|
|
141
|
+
h("p", { style: { marginBottom: "0" } }, item.description),
|
|
142
|
+
item.unavailableReasonCode && (h("p", { style: {
|
|
143
|
+
fontSize: "70%",
|
|
144
|
+
color: "#F2994A",
|
|
145
|
+
marginTop: "0",
|
|
146
|
+
} }, item.unavailableReasonCode)))));
|
|
126
147
|
}),
|
|
127
148
|
h("div", { class: sheet.classes.Buttons },
|
|
128
149
|
h("sl-button", { onClick: () => callbacks.setStage(nextStage), style: { display: "block" }, class: sheet.classes.Button, disabled: !states.selectedItem }, "Continue"),
|
|
@@ -132,6 +153,7 @@ export function RewardExchangeView(props) {
|
|
|
132
153
|
const input = getInput();
|
|
133
154
|
return (h("div", null,
|
|
134
155
|
h("div", { style: { width: "50%", margin: "0 auto" } }, (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.imageUrl) && (h("img", { class: sheet.classes.FullImage, src: selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.imageUrl }))),
|
|
156
|
+
h("p", null, selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.description),
|
|
135
157
|
h("div", { class: sheet.classes.InputBox }, input),
|
|
136
158
|
h("div", { class: sheet.classes.Buttons },
|
|
137
159
|
h("sl-button", { onClick: () => callbacks.setStage("confirmation"), disabled: input && !states.amount, style: { display: "block" }, class: sheet.classes.Button }, "Continue"),
|
|
@@ -139,24 +161,20 @@ export function RewardExchangeView(props) {
|
|
|
139
161
|
}
|
|
140
162
|
console.log({ selectedItem, selectedStep });
|
|
141
163
|
function confirmation() {
|
|
142
|
-
console.log("confirmation:", { selectedItem });
|
|
143
|
-
const redemptionAmount = () => {
|
|
144
|
-
var _a;
|
|
145
|
-
if ((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.ruleType) === "FIXED_GLOBAL_REWARD") {
|
|
146
|
-
return `Redeem ${selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.sourceValue} ${selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.sourceUnit} for ${selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.globalRewardKey}`;
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
const amount = states.amount;
|
|
150
|
-
const reward = (_a = selectedStep === null || selectedStep === void 0 ? void 0 : selectedStep.prettyDestinationValue) !== null && _a !== void 0 ? _a : `${amount} ${selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.destinationUnit}`;
|
|
151
|
-
return `Redeem ${amount} ${selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.sourceUnit} for ${reward}`;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
164
|
const previousStage = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.ruleType) === "FIXED_GLOBAL_REWARD"
|
|
155
165
|
? "chooseReward"
|
|
156
166
|
: "chooseAmount";
|
|
157
167
|
return (h("div", null,
|
|
158
|
-
h("h2", null, "Confirm
|
|
159
|
-
|
|
168
|
+
h("h2", null, "Confirm and redeem"),
|
|
169
|
+
h("div", { style: { textAlign: "center" } },
|
|
170
|
+
h("p", null,
|
|
171
|
+
h("b", null, selectedStep === null || selectedStep === void 0 ? void 0 : selectedStep.sourceValue)),
|
|
172
|
+
h("p", null,
|
|
173
|
+
h("b", null, selectedStep === null || selectedStep === void 0 ? void 0 : selectedStep.prettySourceValue)),
|
|
174
|
+
h("p", null,
|
|
175
|
+
h(ExchangeArrows, null)),
|
|
176
|
+
h("p", null, selectedStep === null || selectedStep === void 0 ? void 0 : selectedStep.destinationValue),
|
|
177
|
+
h("p", null, selectedStep === null || selectedStep === void 0 ? void 0 : selectedStep.prettyDestinationValue)),
|
|
160
178
|
h("div", { class: sheet.classes.Buttons },
|
|
161
179
|
h("sl-button", { onClick: callbacks.exchangeReward, style: { display: "block" }, class: sheet.classes.Button }, "Redeem"),
|
|
162
180
|
h("a", { onClick: () => callbacks.setStage(previousStage), style: { display: "block" }, class: sheet.classes.Button }, "Back"))));
|
|
@@ -178,7 +196,7 @@ export function RewardExchangeView(props) {
|
|
|
178
196
|
function stageMap() {
|
|
179
197
|
const stageNumber = stageList.indexOf(states.redeemStage);
|
|
180
198
|
return (h("div", { style: { fontSize: "80%" } },
|
|
181
|
-
h(ProgressBar, {
|
|
199
|
+
h(ProgressBar, { stageCount: 3, currentStage: stageNumber }),
|
|
182
200
|
h("div", { style: {
|
|
183
201
|
marginTop: "5px",
|
|
184
202
|
display: "flex",
|
|
@@ -194,7 +212,7 @@ export function RewardExchangeView(props) {
|
|
|
194
212
|
return h("i", { style: { flex: "1 1 0" } }, stageProgressList[stage]);
|
|
195
213
|
}))));
|
|
196
214
|
}
|
|
197
|
-
const
|
|
215
|
+
const BackButton = () => {
|
|
198
216
|
if (states.redeemStage === "success")
|
|
199
217
|
return "";
|
|
200
218
|
let previousStage = "";
|
|
@@ -207,8 +225,6 @@ export function RewardExchangeView(props) {
|
|
|
207
225
|
else if (states.redeemStage === "chooseAmount") {
|
|
208
226
|
previousStage = "chooseReward";
|
|
209
227
|
}
|
|
210
|
-
const LeftArrow = () => (h("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: { marginBottom: "-2px", marginRight: "5px" } },
|
|
211
|
-
h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M7.34655 1.90573C7.75405 2.31323 7.75405 2.97392 7.34655 3.38143L3.56266 7.16531H14.9565C15.5328 7.16531 16 7.6325 16 8.20879C16 8.78509 15.5328 9.25227 14.9565 9.25227H3.56266L7.69437 13.384C8.10188 13.7915 8.10188 14.4522 7.69437 14.8597C7.28687 15.2672 6.62617 15.2672 6.21867 14.8597L0.305628 8.94664C-0.101876 8.53914 -0.101876 7.87845 0.305628 7.47094L5.87084 1.90573C6.27835 1.49822 6.93904 1.49822 7.34655 1.90573Z", fill: "#858585" })));
|
|
212
228
|
return (h("div", { slot: "label" },
|
|
213
229
|
h("a", { style: { cursor: "pointer", fontSize: "80%", color: "#858585" }, onClick: () => callbacks.setStage(previousStage) },
|
|
214
230
|
h(LeftArrow, null),
|
|
@@ -218,9 +234,10 @@ export function RewardExchangeView(props) {
|
|
|
218
234
|
h("style", { type: "text/css" }, styleString),
|
|
219
235
|
h("div", null,
|
|
220
236
|
h("sl-drawer", { ref: (ref) => (refs.drawerRef.current = ref), placement: "right", class: sheet.classes.Drawer, open: stageList.indexOf(states.redeemStage) >= 0 },
|
|
221
|
-
h(
|
|
237
|
+
h(BackButton, null),
|
|
222
238
|
stageMap(),
|
|
223
239
|
currentStage && currentStage(),
|
|
224
|
-
states.exchangeError &&
|
|
240
|
+
states.exchangeError &&
|
|
241
|
+
"Something went wrong. Please contact support or try again."),
|
|
225
242
|
h("sl-button", { onClick: () => callbacks.openDrawer() }, "Redeem Rewards"))));
|
|
226
243
|
}
|
|
@@ -4,27 +4,30 @@ import { useRewardExchangeList, } from "./useRewardExchangeList";
|
|
|
4
4
|
import { RewardExchangeView, } from "./sqm-reward-exchange-list-view";
|
|
5
5
|
import { isDemo } from "@saasquatch/component-boilerplate";
|
|
6
6
|
import deepmerge from "deepmerge";
|
|
7
|
-
import {
|
|
8
|
-
import { RequiredPropsError } from "../../utils/RequiredPropsError";
|
|
7
|
+
import { getProps } from "../../utils/utils";
|
|
9
8
|
/**
|
|
10
9
|
* @uiName Reward Exchange List
|
|
11
10
|
*/
|
|
12
11
|
export class SqmRewardExchangeList {
|
|
13
12
|
constructor() {
|
|
14
13
|
this.ignored = true;
|
|
14
|
+
/**
|
|
15
|
+
* @uiName Exchange button text
|
|
16
|
+
*/
|
|
17
|
+
this.buttonText = "Exchange Rewards";
|
|
15
18
|
withHooks(this);
|
|
16
19
|
}
|
|
17
20
|
disconnectedCallback() { }
|
|
18
21
|
render() {
|
|
19
|
-
const missingProps = getMissingProps([
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
]);
|
|
25
|
-
if (missingProps) {
|
|
26
|
-
|
|
27
|
-
}
|
|
22
|
+
// const missingProps = getMissingProps([
|
|
23
|
+
// {
|
|
24
|
+
// attribute: "listType",
|
|
25
|
+
// value: this.listType,
|
|
26
|
+
// },
|
|
27
|
+
// ]);
|
|
28
|
+
// if (missingProps) {
|
|
29
|
+
// return <RequiredPropsError missingProps={missingProps} />;
|
|
30
|
+
// }
|
|
28
31
|
const { states, data, callbacks, refs } = isDemo()
|
|
29
32
|
? useRewardExchangeListDemo(getProps(this))
|
|
30
33
|
: useRewardExchangeList(getProps(this));
|
|
@@ -34,7 +37,7 @@ export class SqmRewardExchangeList {
|
|
|
34
37
|
static get is() { return "sqm-reward-exchange-list"; }
|
|
35
38
|
static get assetsDirs() { return ["assets"]; }
|
|
36
39
|
static get properties() { return {
|
|
37
|
-
"
|
|
40
|
+
"buttonText": {
|
|
38
41
|
"type": "string",
|
|
39
42
|
"mutable": false,
|
|
40
43
|
"complexType": {
|
|
@@ -46,23 +49,21 @@ export class SqmRewardExchangeList {
|
|
|
46
49
|
"optional": false,
|
|
47
50
|
"docs": {
|
|
48
51
|
"tags": [{
|
|
49
|
-
"text": "
|
|
52
|
+
"text": "Exchange button text",
|
|
50
53
|
"name": "uiName"
|
|
51
|
-
}, {
|
|
52
|
-
"text": undefined,
|
|
53
|
-
"name": "uiRequired"
|
|
54
54
|
}],
|
|
55
55
|
"text": ""
|
|
56
56
|
},
|
|
57
|
-
"attribute": "
|
|
58
|
-
"reflect": false
|
|
57
|
+
"attribute": "button-text",
|
|
58
|
+
"reflect": false,
|
|
59
|
+
"defaultValue": "\"Exchange Rewards\""
|
|
59
60
|
},
|
|
60
61
|
"demoData": {
|
|
61
62
|
"type": "unknown",
|
|
62
63
|
"mutable": false,
|
|
63
64
|
"complexType": {
|
|
64
65
|
"original": "DemoData<RewardExchangeViewProps>",
|
|
65
|
-
"resolved": "{ states?: { selectedItem: ExchangeItem; selectedStep: ExchangeStep; redeemStage: string; amount: number; exchangeError?: boolean; }; data?: { exchangeList: any; }; refs?: { drawerRef: any; }; }",
|
|
66
|
+
"resolved": "{ states?: { selectedItem: ExchangeItem; selectedStep: ExchangeStep; redeemStage: string; amount: number; exchangeError?: boolean; content: { text: any; }; }; data?: { exchangeList: any; }; refs?: { drawerRef: any; }; }",
|
|
66
67
|
"references": {
|
|
67
68
|
"DemoData": {
|
|
68
69
|
"location": "import",
|
|
@@ -96,8 +97,7 @@ function useRewardExchangeListDemo(props) {
|
|
|
96
97
|
return deepmerge({
|
|
97
98
|
states: {
|
|
98
99
|
content: {
|
|
99
|
-
|
|
100
|
-
...props,
|
|
100
|
+
text: props,
|
|
101
101
|
},
|
|
102
102
|
redeemStage: "",
|
|
103
103
|
amount: 0,
|
|
@@ -33,6 +33,8 @@ const GET_EXCHANGE_LIST = gql `
|
|
|
33
33
|
prettySourceValue
|
|
34
34
|
destinationValue
|
|
35
35
|
prettyDestinationValue
|
|
36
|
+
available
|
|
37
|
+
unavailableReasonCode
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
totalCount
|
|
@@ -51,7 +53,7 @@ const EXCHANGE = gql `
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
`;
|
|
54
|
-
export function useRewardExchangeList(
|
|
56
|
+
export function useRewardExchangeList(props) {
|
|
55
57
|
var _a, _b, _c, _d;
|
|
56
58
|
const drawerRef = useRef();
|
|
57
59
|
const [exchangeState, setExchangeState] = useReducer((state, next) => ({
|
|
@@ -138,7 +140,6 @@ export function useRewardExchangeList(_) {
|
|
|
138
140
|
globalRewardKey: selectedItem.globalRewardKey,
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
|
-
console.log(exchangeVariables);
|
|
142
143
|
exchange({ exchangeRewardInput: exchangeVariables });
|
|
143
144
|
}
|
|
144
145
|
const resetState = useCallback((e) => {
|
|
@@ -167,9 +168,11 @@ export function useRewardExchangeList(_) {
|
|
|
167
168
|
function setStage(stage) {
|
|
168
169
|
setExchangeState({ redeemStage: stage });
|
|
169
170
|
}
|
|
170
|
-
console.log(exchangeResponse, exchangeResponse === null || exchangeResponse === void 0 ? void 0 : exchangeResponse.data, errors);
|
|
171
171
|
return {
|
|
172
172
|
states: {
|
|
173
|
+
content: {
|
|
174
|
+
text: props,
|
|
175
|
+
},
|
|
173
176
|
selectedItem,
|
|
174
177
|
redeemStage,
|
|
175
178
|
amount,
|