@saasquatch/mint-components 1.11.1-1 → 1.11.1-10
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/{ShadowViewAddon-2c6026c3.js → ShadowViewAddon-af975b90.js} +16 -7
- package/dist/cjs/{copy-text-view-a22ad7e7.js → copy-text-view-35a47e8d.js} +70 -24
- package/dist/cjs/sqm-big-stat_38.cjs.entry.js +2 -2
- package/dist/cjs/sqm-pagination_3.cjs.entry.js +12 -1
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +3 -3
- package/dist/collection/components/sqm-pagination/sqm-pagination.js +1 -0
- package/dist/collection/components/sqm-referral-code/useReferralCode.js +5 -1
- package/dist/collection/components/sqm-referral-codes/sqm-referral-codes.js +7 -1
- package/dist/collection/components/sqm-referral-codes/useReferralCodes.js +70 -25
- package/dist/collection/components/sqm-share-button/useShareButton.js +13 -8
- package/dist/collection/components/sqm-share-link/useShareLink.js +5 -1
- package/dist/esm/{ShadowViewAddon-5bb2b69a.js → ShadowViewAddon-faef41b7.js} +16 -7
- package/dist/esm/{copy-text-view-bf55abeb.js → copy-text-view-3fa5df7b.js} +71 -26
- package/dist/esm/sqm-big-stat_38.entry.js +2 -2
- package/dist/esm/sqm-pagination_3.entry.js +12 -1
- package/dist/esm/sqm-stencilbook.entry.js +3 -3
- package/dist/esm-es5/ShadowViewAddon-faef41b7.js +1 -0
- package/dist/esm-es5/copy-text-view-3fa5df7b.js +1 -0
- package/dist/esm-es5/sqm-big-stat_38.entry.js +1 -1
- package/dist/esm-es5/sqm-pagination_3.entry.js +1 -1
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/{p-73c6b26d.entry.js → p-3d6d95f0.entry.js} +1 -1
- package/dist/mint-components/p-56760017.entry.js +13 -0
- package/dist/mint-components/p-5fc8d87c.system.js +1 -1
- package/dist/mint-components/{p-b71c0e2d.system.entry.js → p-650f6529.system.entry.js} +1 -1
- package/dist/mint-components/p-7a974e40.system.js +1 -0
- package/dist/mint-components/{p-4856b234.system.entry.js → p-85e74fae.system.entry.js} +1 -1
- package/dist/mint-components/p-b80a5030.system.js +1 -0
- package/dist/mint-components/{p-fec0ac31.js → p-baaf39b8.js} +24 -24
- package/dist/mint-components/{p-b0ce005d.entry.js → p-e11adbe0.entry.js} +2 -2
- package/dist/mint-components/p-ee284980.system.entry.js +1 -0
- package/dist/mint-components/p-f5e1e208.js +48 -0
- package/dist/types/components/sqm-referral-codes/sqm-referral-codes-view.d.ts +2 -0
- package/dist/types/components/sqm-referral-codes/useReferralCodes.d.ts +3 -14
- package/dist/types/global/android.d.ts +7 -0
- package/dist/types/global/demo.d.ts +2 -0
- package/dist/types/stories/features.d.ts +4 -0
- package/dist/types/stories/templates.d.ts +4 -0
- package/docs/docs.docx +0 -0
- package/package.json +1 -1
- package/dist/esm-es5/ShadowViewAddon-5bb2b69a.js +0 -1
- package/dist/esm-es5/copy-text-view-bf55abeb.js +0 -1
- package/dist/mint-components/p-0161f5da.entry.js +0 -13
- package/dist/mint-components/p-646d302a.system.js +0 -1
- package/dist/mint-components/p-6628bc0e.system.js +0 -1
- package/dist/mint-components/p-c37137cd.js +0 -2
- package/dist/mint-components/p-eb4e9efb.system.entry.js +0 -1
|
@@ -6,7 +6,7 @@ const global = require('./global-02e50f09.js');
|
|
|
6
6
|
const index_module = require('./index.module-df530553.js');
|
|
7
7
|
const utils = require('./utils-6847bc06.js');
|
|
8
8
|
const JSS = require('./JSS-8503a151.js');
|
|
9
|
-
const copyTextView = require('./copy-text-view-
|
|
9
|
+
const copyTextView = require('./copy-text-view-35a47e8d.js');
|
|
10
10
|
const cjs = require('./cjs-1066ec21.js');
|
|
11
11
|
const mixins = require('./mixins-fe9d4112.js');
|
|
12
12
|
const useChildElements = require('./useChildElements-e0d44916.js');
|
|
@@ -381,11 +381,15 @@ function useShareLink(props) {
|
|
|
381
381
|
const contextData = index_module.In(copyTextView.REFERRAL_CODES_NAMESPACE);
|
|
382
382
|
const { data } = index_module.yn(MessageLinkQuery, { programId, engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt) || !!props.linkOverride || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
|
|
383
383
|
const [sendLoadEvent] = index_module.$e(WIDGET_ENGAGEMENT_EVENT);
|
|
384
|
+
const [setUsed, usedRes] = index_module.$e(copyTextView.SET_CODE_USED);
|
|
384
385
|
const copyString = (_b = ((contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) || ((_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.shareLink))) !== null && _b !== void 0 ? _b :
|
|
385
386
|
// Shown during loading
|
|
386
387
|
"...";
|
|
387
388
|
const [open, setOpen] = stencilHooks_module.useState(false);
|
|
388
389
|
function onClick() {
|
|
390
|
+
if (contextData) {
|
|
391
|
+
setUsed(true);
|
|
392
|
+
}
|
|
389
393
|
// Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
|
|
390
394
|
// Only if called from a user-initiated event
|
|
391
395
|
navigator.clipboard.writeText(copyString);
|
|
@@ -459,7 +463,7 @@ function GenericShare(messageLink, errorText) {
|
|
|
459
463
|
return messageLink ? window.open(messageLink) : alert(errorText);
|
|
460
464
|
}
|
|
461
465
|
function useShareButton(props) {
|
|
462
|
-
var _a, _b
|
|
466
|
+
var _a, _b;
|
|
463
467
|
const { sharetitle, sharetext, medium } = props;
|
|
464
468
|
const programId = props.programId ? props.programId : index_module.H();
|
|
465
469
|
const user = index_module.Q();
|
|
@@ -469,24 +473,29 @@ function useShareButton(props) {
|
|
|
469
473
|
shareMedium: medium.toUpperCase(),
|
|
470
474
|
};
|
|
471
475
|
const data = index_module.In(copyTextView.REFERRAL_CODES_NAMESPACE);
|
|
476
|
+
const overrideData = data === null || data === void 0 ? void 0 : data[medium];
|
|
472
477
|
// only queries if a programId is available
|
|
473
|
-
const res = index_module.yn(MessageLinkQuery$1, variables, !(user === null || user === void 0 ? void 0 : user.jwt) || !programId ||
|
|
474
|
-
const
|
|
478
|
+
const res = index_module.yn(MessageLinkQuery$1, variables, !(user === null || user === void 0 ? void 0 : user.jwt) || !programId || overrideData !== undefined);
|
|
479
|
+
const [setUsed, usedRes] = index_module.$e(copyTextView.SET_CODE_USED);
|
|
480
|
+
const directLink = (overrideData === null || overrideData === void 0 ? void 0 : overrideData.shareLink) || ((_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.viewer) === null || _b === void 0 ? void 0 : _b.shareLink);
|
|
475
481
|
const environment = index_module.getEnvironmentSDK();
|
|
476
482
|
const hide = (medium.toLocaleUpperCase() === "SMS" &&
|
|
477
483
|
window.orientation === undefined) ||
|
|
478
484
|
(medium.toLocaleUpperCase() === "DIRECT" && !window.navigator.share);
|
|
479
485
|
function onClick() {
|
|
480
|
-
var _a, _b, _c, _d
|
|
486
|
+
var _a, _b, _c, _d;
|
|
487
|
+
if (overrideData) {
|
|
488
|
+
setUsed(true);
|
|
489
|
+
}
|
|
481
490
|
if (medium.toLocaleUpperCase() === "FACEBOOK" &&
|
|
482
491
|
environment.type === "SquatchAndroid") {
|
|
483
|
-
FacebookShare(directLink, (
|
|
492
|
+
FacebookShare(directLink, (overrideData === null || overrideData === void 0 ? void 0 : overrideData.messageLink) || ((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.viewer) === null || _b === void 0 ? void 0 : _b.messageLink), props.errorText);
|
|
484
493
|
}
|
|
485
494
|
else if (medium.toLocaleUpperCase() === "DIRECT") {
|
|
486
495
|
NativeShare({ sharetitle, sharetext }, directLink, props.errorText, props.unsupportedPlatformText);
|
|
487
496
|
}
|
|
488
497
|
else {
|
|
489
|
-
GenericShare((
|
|
498
|
+
GenericShare((overrideData === null || overrideData === void 0 ? void 0 : overrideData.messageLink) || ((_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.viewer) === null || _d === void 0 ? void 0 : _d.messageLink), props.errorText);
|
|
490
499
|
}
|
|
491
500
|
}
|
|
492
501
|
return { ...props, loading: res.loading, onClick, hide };
|
|
@@ -6,17 +6,69 @@ const index_module = require('./index.module-df530553.js');
|
|
|
6
6
|
const JSS = require('./JSS-8503a151.js');
|
|
7
7
|
const mixins = require('./mixins-fe9d4112.js');
|
|
8
8
|
|
|
9
|
-
const GET_REFERRAL_CODES = index_module.dist.gql `
|
|
10
|
-
|
|
9
|
+
const GET_REFERRAL_CODES = index_module.dist.gql `
|
|
10
|
+
query getCodes(
|
|
11
|
+
$limit: Int!
|
|
12
|
+
$offset: Int!
|
|
13
|
+
$engagementMedium: UserEngagementMedium!
|
|
14
|
+
) {
|
|
15
|
+
viewer {
|
|
16
|
+
... on User {
|
|
17
|
+
referralCodeList(
|
|
18
|
+
limit: $limit
|
|
19
|
+
offset: $offset
|
|
20
|
+
filter: { fuelTank_eq: true }
|
|
21
|
+
) {
|
|
22
|
+
data {
|
|
23
|
+
code
|
|
24
|
+
dateUsed
|
|
25
|
+
dateCopied
|
|
26
|
+
shareLinkCodes(limit: $limit, offset: $offset) {
|
|
27
|
+
data {
|
|
28
|
+
linkCode
|
|
29
|
+
shareLink: shortUrl(
|
|
30
|
+
shareMedium: DIRECT
|
|
31
|
+
engagementMedium: EMBED
|
|
32
|
+
)
|
|
33
|
+
email: shortUrl(
|
|
34
|
+
shareMedium: EMAIL
|
|
35
|
+
engagementMedium: $engagementMedium
|
|
36
|
+
)
|
|
37
|
+
whatsApp: shortUrl(
|
|
38
|
+
shareMedium: WHATSAPP
|
|
39
|
+
engagementMedium: $engagementMedium
|
|
40
|
+
)
|
|
41
|
+
fbMessenger: shortUrl(
|
|
42
|
+
shareMedium: FBMESSENGER
|
|
43
|
+
engagementMedium: $engagementMedium
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
count
|
|
49
|
+
totalCount
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
11
55
|
const REFERRAL_CODES_NAMESPACE = "sq:referral-codes";
|
|
12
56
|
const REFERRAL_CODES_PAGINATION_CONTEXT = "sq:referral-codes-pagination";
|
|
57
|
+
const SET_CODE_USED = index_module.dist.gql `
|
|
58
|
+
mutation test {}
|
|
59
|
+
`;
|
|
13
60
|
function useReferralCodes(props) {
|
|
14
61
|
const user = index_module.Q();
|
|
62
|
+
const engagementMedium = index_module.B();
|
|
15
63
|
console.log({ props });
|
|
16
|
-
const { envelope: referralData, states, callbacks, } = index_module.kn(GET_REFERRAL_CODES, (data) => {
|
|
64
|
+
const { envelope: referralData, states, callbacks, } = index_module.kn(GET_REFERRAL_CODES, (data) => {
|
|
65
|
+
var _a;
|
|
66
|
+
console.log({ queryData: data });
|
|
67
|
+
return (_a = data === null || data === void 0 ? void 0 : data.viewer) === null || _a === void 0 ? void 0 : _a.referralCodeList;
|
|
68
|
+
}, {
|
|
17
69
|
limit: 1,
|
|
18
70
|
offset: 0,
|
|
19
|
-
}, {}, !(user === null || user === void 0 ? void 0 : user.jwt));
|
|
71
|
+
}, { engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt));
|
|
20
72
|
const [paginationContext, setPaginationContext] = index_module.Cn({
|
|
21
73
|
namespace: REFERRAL_CODES_PAGINATION_CONTEXT,
|
|
22
74
|
initialValue: { states, callbacks },
|
|
@@ -38,40 +90,33 @@ function useReferralCodes(props) {
|
|
|
38
90
|
},
|
|
39
91
|
});
|
|
40
92
|
stencilHooks_module.useEffect(() => {
|
|
41
|
-
|
|
93
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
94
|
+
if ((_a = referralData === null || referralData === void 0 ? void 0 : referralData.data) === null || _a === void 0 ? void 0 : _a.length) {
|
|
95
|
+
const data = referralData.data[0];
|
|
42
96
|
setReferralCodesContext({
|
|
43
|
-
referralCode:
|
|
44
|
-
shareLink:
|
|
97
|
+
referralCode: data.code,
|
|
98
|
+
shareLink: (_c = (_b = data.shareLinkCodes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.direct,
|
|
45
99
|
email: {
|
|
46
|
-
messageLink:
|
|
100
|
+
messageLink: (_e = (_d = data.shareLinkCodes) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.email,
|
|
47
101
|
},
|
|
48
102
|
fbMessenger: {
|
|
49
|
-
messageLink:
|
|
50
|
-
shareLink:
|
|
103
|
+
messageLink: (_g = (_f = data.shareLinkCodes) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.fbMessenger,
|
|
104
|
+
shareLink: (_j = (_h = data.shareLinkCodes) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.fbMessenger,
|
|
51
105
|
},
|
|
52
|
-
whatsApp: { messageLink:
|
|
106
|
+
whatsApp: { messageLink: (_l = (_k = data.shareLinkCodes) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.whatsApp },
|
|
53
107
|
});
|
|
108
|
+
}
|
|
54
109
|
}, [referralData]);
|
|
55
110
|
stencilHooks_module.useEffect(() => {
|
|
56
111
|
setPaginationContext({ states, callbacks });
|
|
57
|
-
}, [states]);
|
|
112
|
+
}, [states.loading]);
|
|
58
113
|
console.log({ referralData, states });
|
|
59
114
|
return {
|
|
60
115
|
states: {
|
|
61
116
|
...states,
|
|
117
|
+
noCodes: (referralData === null || referralData === void 0 ? void 0 : referralData.totalCount) === 0,
|
|
62
118
|
},
|
|
63
|
-
data:
|
|
64
|
-
referralCode: "EXAMPLECODE",
|
|
65
|
-
shareLink: "https://example.com",
|
|
66
|
-
email: {
|
|
67
|
-
messageLink: "https://example.com",
|
|
68
|
-
},
|
|
69
|
-
fbMessenger: {
|
|
70
|
-
messageLink: "https://example.com",
|
|
71
|
-
shareLink: "https://example.com",
|
|
72
|
-
},
|
|
73
|
-
whatsApp: { messageLink: "https://example.com" },
|
|
74
|
-
},
|
|
119
|
+
data: referralCodesContext,
|
|
75
120
|
callbacks: {
|
|
76
121
|
// onPrev: () => callbacks.setCurrentPage(states.currentPage - 1),
|
|
77
122
|
// onNext: () => callbacks.setCurrentPage(states.currentPage + 1),
|
|
@@ -170,4 +215,5 @@ function CopyTextView(props) {
|
|
|
170
215
|
exports.CopyTextView = CopyTextView;
|
|
171
216
|
exports.REFERRAL_CODES_NAMESPACE = REFERRAL_CODES_NAMESPACE;
|
|
172
217
|
exports.REFERRAL_CODES_PAGINATION_CONTEXT = REFERRAL_CODES_PAGINATION_CONTEXT;
|
|
218
|
+
exports.SET_CODE_USED = SET_CODE_USED;
|
|
173
219
|
exports.useReferralCodes = useReferralCodes;
|
|
@@ -9,7 +9,7 @@ const index_module = require('./index.module-df530553.js');
|
|
|
9
9
|
const jsonpointer = require('./jsonpointer-11327262.js');
|
|
10
10
|
const utils = require('./utils-6847bc06.js');
|
|
11
11
|
const JSS = require('./JSS-8503a151.js');
|
|
12
|
-
const copyTextView = require('./copy-text-view-
|
|
12
|
+
const copyTextView = require('./copy-text-view-35a47e8d.js');
|
|
13
13
|
const cjs = require('./cjs-1066ec21.js');
|
|
14
14
|
require('./mixins-fe9d4112.js');
|
|
15
15
|
const reRender = require('./re-render-1976e05e.js');
|
|
@@ -20,7 +20,7 @@ const index$1 = require('./index-8c6255f5.js');
|
|
|
20
20
|
const useRegistrationFormState = require('./useRegistrationFormState-876ed65d.js');
|
|
21
21
|
const utilities = require('./utilities-cec9dd36.js');
|
|
22
22
|
const AsYouType = require('./AsYouType-6788393a.js');
|
|
23
|
-
const ShadowViewAddon = require('./ShadowViewAddon-
|
|
23
|
+
const ShadowViewAddon = require('./ShadowViewAddon-af975b90.js');
|
|
24
24
|
require('./sqm-portal-container-view-990a85a3.js');
|
|
25
25
|
|
|
26
26
|
const BigStat = class {
|
|
@@ -7,7 +7,7 @@ const stencilHooks_module = require('./stencil-hooks.module-72742a0b.js');
|
|
|
7
7
|
const index_module = require('./index.module-df530553.js');
|
|
8
8
|
const utils = require('./utils-6847bc06.js');
|
|
9
9
|
const JSS = require('./JSS-8503a151.js');
|
|
10
|
-
const copyTextView = require('./copy-text-view-
|
|
10
|
+
const copyTextView = require('./copy-text-view-35a47e8d.js');
|
|
11
11
|
const cjs = require('./cjs-1066ec21.js');
|
|
12
12
|
require('./mixins-fe9d4112.js');
|
|
13
13
|
|
|
@@ -60,6 +60,7 @@ const Pagination = class {
|
|
|
60
60
|
const hookProps = index_module.isDemo()
|
|
61
61
|
? useDemoPagination(utils.getProps(this))
|
|
62
62
|
: usePagination();
|
|
63
|
+
console.log("pagination", { hookProps });
|
|
63
64
|
const props = {
|
|
64
65
|
currentPage: (_a = hookProps.states) === null || _a === void 0 ? void 0 : _a.currentPage,
|
|
65
66
|
totalPages: (_b = hookProps.states) === null || _b === void 0 ? void 0 : _b.pageCount,
|
|
@@ -110,11 +111,15 @@ function useReferralCode(props) {
|
|
|
110
111
|
const contextData = index_module.In(copyTextView.REFERRAL_CODES_NAMESPACE);
|
|
111
112
|
const { data } = index_module.yn(MessageLinkQuery, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || (contextData === null || contextData === void 0 ? void 0 : contextData.referralCode) !== undefined);
|
|
112
113
|
const [sendLoadEvent] = index_module.$e(WIDGET_ENGAGEMENT_EVENT);
|
|
114
|
+
const [setUsed, usedRes] = index_module.$e(copyTextView.SET_CODE_USED);
|
|
113
115
|
const copyString = (_b = ((contextData === null || contextData === void 0 ? void 0 : contextData.referralCode) || ((_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.referralCode))) !== null && _b !== void 0 ? _b :
|
|
114
116
|
// Shown during loading
|
|
115
117
|
"...";
|
|
116
118
|
const [open, setOpen] = stencilHooks_module.useState(false);
|
|
117
119
|
function onClick() {
|
|
120
|
+
if (contextData) {
|
|
121
|
+
setUsed(true);
|
|
122
|
+
}
|
|
118
123
|
// Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
|
|
119
124
|
// Only if called from a user-initiated event
|
|
120
125
|
navigator.clipboard.writeText(copyString);
|
|
@@ -301,6 +306,8 @@ const ReferralCodes = class {
|
|
|
301
306
|
const viewProps = {
|
|
302
307
|
slots,
|
|
303
308
|
...props,
|
|
309
|
+
loading: props.states.loading,
|
|
310
|
+
noCodes: props.states.noCodes,
|
|
304
311
|
};
|
|
305
312
|
return index.h(ReferralCodesView, Object.assign({}, viewProps));
|
|
306
313
|
}
|
|
@@ -308,6 +315,10 @@ const ReferralCodes = class {
|
|
|
308
315
|
function useDemoReferralCodes(props) {
|
|
309
316
|
return cjs.cjs({
|
|
310
317
|
titleText: props.titleText,
|
|
318
|
+
states: {
|
|
319
|
+
noCodes: false,
|
|
320
|
+
loading: false,
|
|
321
|
+
},
|
|
311
322
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
312
323
|
}
|
|
313
324
|
|
|
@@ -8,7 +8,7 @@ require('./global-02e50f09.js');
|
|
|
8
8
|
const index_module = require('./index.module-df530553.js');
|
|
9
9
|
require('./utils-6847bc06.js');
|
|
10
10
|
const JSS = require('./JSS-8503a151.js');
|
|
11
|
-
const copyTextView = require('./copy-text-view-
|
|
11
|
+
const copyTextView = require('./copy-text-view-35a47e8d.js');
|
|
12
12
|
require('./cjs-1066ec21.js');
|
|
13
13
|
require('./mixins-fe9d4112.js');
|
|
14
14
|
const GenericTableView = require('./GenericTableView-a3f48e15.js');
|
|
@@ -29,7 +29,7 @@ const sqmPortalProfileView = require('./sqm-portal-profile-view-fde54e35.js');
|
|
|
29
29
|
require('./utilities-cec9dd36.js');
|
|
30
30
|
const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-34771d2c.js');
|
|
31
31
|
const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-c8f91506.js');
|
|
32
|
-
const ShadowViewAddon = require('./ShadowViewAddon-
|
|
32
|
+
const ShadowViewAddon = require('./ShadowViewAddon-af975b90.js');
|
|
33
33
|
const sqmPortalContainerView = require('./sqm-portal-container-view-990a85a3.js');
|
|
34
34
|
const sqmInvoiceTableView = require('./sqm-invoice-table-view-e3b03a00.js');
|
|
35
35
|
|
|
@@ -15104,7 +15104,7 @@ const UseInvoiceTableCells = /*#__PURE__*/Object.freeze({
|
|
|
15104
15104
|
InvoiceTableDemoHook: InvoiceTableDemoHook
|
|
15105
15105
|
});
|
|
15106
15106
|
|
|
15107
|
-
const scenario$E = "@author: sam\n@owner: sam\n\nFeature: Referral Codes Component\n\n A paginated display of available and used promo codes for the user to share with others\n\n @motivating\n Scenario: Promo code can be shared using various share mediums\n Given an authenticated user\n And the program has promo codes configured\n When the promo code section is loaded\n Then the promo code can be copied directly\n And the promo code can be shared using <shareMedium>\n\n Examples:\n | shareMedium |\n | DIRECT |\n | EMAIL |\n | FBMESSENGER |\n | WHATSAPP |\n\n @minutia\n Scenario: User is notified if the currently viewed promo code has been used already\n Given an authenticated user\n And the program has promo codes configured\n When the promo code section is loaded\n And the code has not been used already\n Then no notification text is displayed\n When the code is changed to one that has been used\n Then the notification text is displayed\n\n @minutia\n Scenario Outline: Share
|
|
15107
|
+
const scenario$E = "@author: sam\n@owner: sam\n\nFeature: Referral Codes Component\n\n A paginated display of available and used promo codes for the user to share with others\n\n @motivating\n Scenario: Promo code can be shared using various share mediums\n Given an authenticated user\n And the program has promo codes configured\n When the promo code section is loaded\n Then the promo code can be copied directly\n And the promo code can be shared using <shareMedium>\n\n Examples:\n | shareMedium |\n | DIRECT |\n | EMAIL |\n | FBMESSENGER |\n | WHATSAPP |\n\n @minutia\n Scenario: User is notified if the currently viewed promo code has been used already\n Given an authenticated user\n And the program has promo codes configured\n When the promo code section is loaded\n And the code has not been used already\n Then no notification text is displayed\n When the code is changed to one that has been used\n Then the notification text is displayed\n\n @minutia\n Scenario Outline: Share buttons slots use the link from referral codes instead of the default query\n Given an authenticated user\n And the program has promo codes configured\n And a <shareMedium> button is a child of `<sqm-referral-codes>`\n Then the <shareMedium> button is shown\n And the link is <promoCode>\n Examples:\n | propName | shareMedium | promoCode |\n | hideSharelink | DIRECT | PROMOCODE1 |\n | hideEmail | EMAIL | PROMOCODE1 |\n | hideFbMessenger | FBMESSENGER | PROMOCODE1 |\n | hideWhatsApp | WHATSAPP | PROMOCODE1 |\n\n @minutia\n Scenario Outline: Number of codes is displayed in the pagination component\n Given an authenticated user\n And the program has promo codes configured\n When the promo code section is loaded\n And the user has <numCodes> available\n And the user is on <currentPage>\n Then the pagination text is <paginationText>\n Examples:\n | numCodes | currentPage | paginationText |\n | 5 | 1 | 1 of 5 |\n | 5 | 2 | 2 of 5 |\n | 5 | 3 | 3 of 5 |\n | 5 | 4 | 4 of 5 |\n | 5 | 5 | 5 of 5 |\n | 1 | 1 | 1 of 1 |\n | 0 | 0 | 0 of 0 |\n\n";
|
|
15108
15108
|
|
|
15109
15109
|
const ReferralCodes_stories = {
|
|
15110
15110
|
title: "Components/Referral Codes",
|
|
@@ -23,6 +23,7 @@ export class Pagination {
|
|
|
23
23
|
const hookProps = isDemo()
|
|
24
24
|
? useDemoPagination(getProps(this))
|
|
25
25
|
: usePagination();
|
|
26
|
+
console.log("pagination", { hookProps });
|
|
26
27
|
const props = {
|
|
27
28
|
currentPage: (_a = hookProps.states) === null || _a === void 0 ? void 0 : _a.currentPage,
|
|
28
29
|
totalPages: (_b = hookProps.states) === null || _b === void 0 ? void 0 : _b.pageCount,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEngagementMedium, useMutation, useParentValue, useProgramId, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
2
2
|
import { useState } from "@saasquatch/universal-hooks";
|
|
3
3
|
import { gql } from "graphql-request";
|
|
4
|
-
import { REFERRAL_CODES_NAMESPACE, } from "../sqm-referral-codes/useReferralCodes";
|
|
4
|
+
import { REFERRAL_CODES_NAMESPACE, SET_CODE_USED, } from "../sqm-referral-codes/useReferralCodes";
|
|
5
5
|
const MessageLinkQuery = gql `
|
|
6
6
|
query ($programId: ID) {
|
|
7
7
|
user: viewer {
|
|
@@ -24,11 +24,15 @@ export function useReferralCode(props) {
|
|
|
24
24
|
const contextData = useParentValue(REFERRAL_CODES_NAMESPACE);
|
|
25
25
|
const { data } = useQuery(MessageLinkQuery, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || (contextData === null || contextData === void 0 ? void 0 : contextData.referralCode) !== undefined);
|
|
26
26
|
const [sendLoadEvent] = useMutation(WIDGET_ENGAGEMENT_EVENT);
|
|
27
|
+
const [setUsed, usedRes] = useMutation(SET_CODE_USED);
|
|
27
28
|
const copyString = (_b = ((contextData === null || contextData === void 0 ? void 0 : contextData.referralCode) || ((_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.referralCode))) !== null && _b !== void 0 ? _b :
|
|
28
29
|
// Shown during loading
|
|
29
30
|
"...";
|
|
30
31
|
const [open, setOpen] = useState(false);
|
|
31
32
|
function onClick() {
|
|
33
|
+
if (contextData) {
|
|
34
|
+
setUsed(true);
|
|
35
|
+
}
|
|
32
36
|
// Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
|
|
33
37
|
// Only if called from a user-initiated event
|
|
34
38
|
navigator.clipboard.writeText(copyString);
|
|
@@ -33,6 +33,8 @@ export class ReferralCodes {
|
|
|
33
33
|
const viewProps = {
|
|
34
34
|
slots,
|
|
35
35
|
...props,
|
|
36
|
+
loading: props.states.loading,
|
|
37
|
+
noCodes: props.states.noCodes,
|
|
36
38
|
};
|
|
37
39
|
return h(ReferralCodesView, Object.assign({}, viewProps));
|
|
38
40
|
}
|
|
@@ -65,7 +67,7 @@ export class ReferralCodes {
|
|
|
65
67
|
"mutable": false,
|
|
66
68
|
"complexType": {
|
|
67
69
|
"original": "DemoData<ReferralCodesViewProps>",
|
|
68
|
-
"resolved": "{ slots?: { shareButtons: VNode; shareCodes: VNode; pagination: VNode; }; titleText?: string; }",
|
|
70
|
+
"resolved": "{ slots?: { shareButtons: VNode; shareCodes: VNode; pagination: VNode; }; loading?: boolean; titleText?: string; noCodes?: boolean; }",
|
|
69
71
|
"references": {
|
|
70
72
|
"DemoData": {
|
|
71
73
|
"location": "import",
|
|
@@ -95,5 +97,9 @@ export class ReferralCodes {
|
|
|
95
97
|
function useDemoReferralCodes(props) {
|
|
96
98
|
return deepmerge({
|
|
97
99
|
titleText: props.titleText,
|
|
100
|
+
states: {
|
|
101
|
+
noCodes: false,
|
|
102
|
+
loading: false,
|
|
103
|
+
},
|
|
98
104
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
99
105
|
}
|
|
@@ -1,17 +1,69 @@
|
|
|
1
|
-
import { usePaginatedQuery, useParentState, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
1
|
+
import { useEngagementMedium, usePaginatedQuery, useParentState, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
2
2
|
import { gql } from "graphql-request";
|
|
3
3
|
import { useEffect } from "@saasquatch/universal-hooks";
|
|
4
|
-
const GET_REFERRAL_CODES = gql `
|
|
5
|
-
|
|
4
|
+
const GET_REFERRAL_CODES = gql `
|
|
5
|
+
query getCodes(
|
|
6
|
+
$limit: Int!
|
|
7
|
+
$offset: Int!
|
|
8
|
+
$engagementMedium: UserEngagementMedium!
|
|
9
|
+
) {
|
|
10
|
+
viewer {
|
|
11
|
+
... on User {
|
|
12
|
+
referralCodeList(
|
|
13
|
+
limit: $limit
|
|
14
|
+
offset: $offset
|
|
15
|
+
filter: { fuelTank_eq: true }
|
|
16
|
+
) {
|
|
17
|
+
data {
|
|
18
|
+
code
|
|
19
|
+
dateUsed
|
|
20
|
+
dateCopied
|
|
21
|
+
shareLinkCodes(limit: $limit, offset: $offset) {
|
|
22
|
+
data {
|
|
23
|
+
linkCode
|
|
24
|
+
shareLink: shortUrl(
|
|
25
|
+
shareMedium: DIRECT
|
|
26
|
+
engagementMedium: EMBED
|
|
27
|
+
)
|
|
28
|
+
email: shortUrl(
|
|
29
|
+
shareMedium: EMAIL
|
|
30
|
+
engagementMedium: $engagementMedium
|
|
31
|
+
)
|
|
32
|
+
whatsApp: shortUrl(
|
|
33
|
+
shareMedium: WHATSAPP
|
|
34
|
+
engagementMedium: $engagementMedium
|
|
35
|
+
)
|
|
36
|
+
fbMessenger: shortUrl(
|
|
37
|
+
shareMedium: FBMESSENGER
|
|
38
|
+
engagementMedium: $engagementMedium
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
count
|
|
44
|
+
totalCount
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
6
50
|
export const REFERRAL_CODES_NAMESPACE = "sq:referral-codes";
|
|
7
51
|
export const REFERRAL_CODES_PAGINATION_CONTEXT = "sq:referral-codes-pagination";
|
|
52
|
+
export const SET_CODE_USED = gql `
|
|
53
|
+
mutation test {}
|
|
54
|
+
`;
|
|
8
55
|
export function useReferralCodes(props) {
|
|
9
56
|
const user = useUserIdentity();
|
|
57
|
+
const engagementMedium = useEngagementMedium();
|
|
10
58
|
console.log({ props });
|
|
11
|
-
const { envelope: referralData, states, callbacks, } = usePaginatedQuery(GET_REFERRAL_CODES, (data) => {
|
|
59
|
+
const { envelope: referralData, states, callbacks, } = usePaginatedQuery(GET_REFERRAL_CODES, (data) => {
|
|
60
|
+
var _a;
|
|
61
|
+
console.log({ queryData: data });
|
|
62
|
+
return (_a = data === null || data === void 0 ? void 0 : data.viewer) === null || _a === void 0 ? void 0 : _a.referralCodeList;
|
|
63
|
+
}, {
|
|
12
64
|
limit: 1,
|
|
13
65
|
offset: 0,
|
|
14
|
-
}, {}, !(user === null || user === void 0 ? void 0 : user.jwt));
|
|
66
|
+
}, { engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt));
|
|
15
67
|
const [paginationContext, setPaginationContext] = useParentState({
|
|
16
68
|
namespace: REFERRAL_CODES_PAGINATION_CONTEXT,
|
|
17
69
|
initialValue: { states, callbacks },
|
|
@@ -33,40 +85,33 @@ export function useReferralCodes(props) {
|
|
|
33
85
|
},
|
|
34
86
|
});
|
|
35
87
|
useEffect(() => {
|
|
36
|
-
|
|
88
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
89
|
+
if ((_a = referralData === null || referralData === void 0 ? void 0 : referralData.data) === null || _a === void 0 ? void 0 : _a.length) {
|
|
90
|
+
const data = referralData.data[0];
|
|
37
91
|
setReferralCodesContext({
|
|
38
|
-
referralCode:
|
|
39
|
-
shareLink:
|
|
92
|
+
referralCode: data.code,
|
|
93
|
+
shareLink: (_c = (_b = data.shareLinkCodes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.direct,
|
|
40
94
|
email: {
|
|
41
|
-
messageLink:
|
|
95
|
+
messageLink: (_e = (_d = data.shareLinkCodes) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.email,
|
|
42
96
|
},
|
|
43
97
|
fbMessenger: {
|
|
44
|
-
messageLink:
|
|
45
|
-
shareLink:
|
|
98
|
+
messageLink: (_g = (_f = data.shareLinkCodes) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.fbMessenger,
|
|
99
|
+
shareLink: (_j = (_h = data.shareLinkCodes) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.fbMessenger,
|
|
46
100
|
},
|
|
47
|
-
whatsApp: { messageLink:
|
|
101
|
+
whatsApp: { messageLink: (_l = (_k = data.shareLinkCodes) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.whatsApp },
|
|
48
102
|
});
|
|
103
|
+
}
|
|
49
104
|
}, [referralData]);
|
|
50
105
|
useEffect(() => {
|
|
51
106
|
setPaginationContext({ states, callbacks });
|
|
52
|
-
}, [states]);
|
|
107
|
+
}, [states.loading]);
|
|
53
108
|
console.log({ referralData, states });
|
|
54
109
|
return {
|
|
55
110
|
states: {
|
|
56
111
|
...states,
|
|
112
|
+
noCodes: (referralData === null || referralData === void 0 ? void 0 : referralData.totalCount) === 0,
|
|
57
113
|
},
|
|
58
|
-
data:
|
|
59
|
-
referralCode: "EXAMPLECODE",
|
|
60
|
-
shareLink: "https://example.com",
|
|
61
|
-
email: {
|
|
62
|
-
messageLink: "https://example.com",
|
|
63
|
-
},
|
|
64
|
-
fbMessenger: {
|
|
65
|
-
messageLink: "https://example.com",
|
|
66
|
-
shareLink: "https://example.com",
|
|
67
|
-
},
|
|
68
|
-
whatsApp: { messageLink: "https://example.com" },
|
|
69
|
-
},
|
|
114
|
+
data: referralCodesContext,
|
|
70
115
|
callbacks: {
|
|
71
116
|
// onPrev: () => callbacks.setCurrentPage(states.currentPage - 1),
|
|
72
117
|
// onNext: () => callbacks.setCurrentPage(states.currentPage + 1),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useEngagementMedium, useUserIdentity, useQuery, useParentValue, } from "@saasquatch/component-boilerplate";
|
|
1
|
+
import { useEngagementMedium, useUserIdentity, useQuery, useParentValue, useMutation, } from "@saasquatch/component-boilerplate";
|
|
2
2
|
import { gql } from "graphql-request";
|
|
3
3
|
import { useProgramId, getEnvironmentSDK, } from "@saasquatch/component-boilerplate";
|
|
4
|
-
import { REFERRAL_CODES_NAMESPACE, } from "../sqm-referral-codes/useReferralCodes";
|
|
4
|
+
import { REFERRAL_CODES_NAMESPACE, SET_CODE_USED, } from "../sqm-referral-codes/useReferralCodes";
|
|
5
5
|
const MessageLinkQuery = gql `
|
|
6
6
|
query (
|
|
7
7
|
$programId: ID
|
|
@@ -54,7 +54,7 @@ function GenericShare(messageLink, errorText) {
|
|
|
54
54
|
return messageLink ? window.open(messageLink) : alert(errorText);
|
|
55
55
|
}
|
|
56
56
|
export function useShareButton(props) {
|
|
57
|
-
var _a, _b
|
|
57
|
+
var _a, _b;
|
|
58
58
|
const { sharetitle, sharetext, medium } = props;
|
|
59
59
|
const programId = props.programId ? props.programId : useProgramId();
|
|
60
60
|
const user = useUserIdentity();
|
|
@@ -64,24 +64,29 @@ export function useShareButton(props) {
|
|
|
64
64
|
shareMedium: medium.toUpperCase(),
|
|
65
65
|
};
|
|
66
66
|
const data = useParentValue(REFERRAL_CODES_NAMESPACE);
|
|
67
|
+
const overrideData = data === null || data === void 0 ? void 0 : data[medium];
|
|
67
68
|
// only queries if a programId is available
|
|
68
|
-
const res = useQuery(MessageLinkQuery, variables, !(user === null || user === void 0 ? void 0 : user.jwt) || !programId ||
|
|
69
|
-
const
|
|
69
|
+
const res = useQuery(MessageLinkQuery, variables, !(user === null || user === void 0 ? void 0 : user.jwt) || !programId || overrideData !== undefined);
|
|
70
|
+
const [setUsed, usedRes] = useMutation(SET_CODE_USED);
|
|
71
|
+
const directLink = (overrideData === null || overrideData === void 0 ? void 0 : overrideData.shareLink) || ((_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.viewer) === null || _b === void 0 ? void 0 : _b.shareLink);
|
|
70
72
|
const environment = getEnvironmentSDK();
|
|
71
73
|
const hide = (medium.toLocaleUpperCase() === "SMS" &&
|
|
72
74
|
window.orientation === undefined) ||
|
|
73
75
|
(medium.toLocaleUpperCase() === "DIRECT" && !window.navigator.share);
|
|
74
76
|
function onClick() {
|
|
75
|
-
var _a, _b, _c, _d
|
|
77
|
+
var _a, _b, _c, _d;
|
|
78
|
+
if (overrideData) {
|
|
79
|
+
setUsed(true);
|
|
80
|
+
}
|
|
76
81
|
if (medium.toLocaleUpperCase() === "FACEBOOK" &&
|
|
77
82
|
environment.type === "SquatchAndroid") {
|
|
78
|
-
FacebookShare(directLink, (
|
|
83
|
+
FacebookShare(directLink, (overrideData === null || overrideData === void 0 ? void 0 : overrideData.messageLink) || ((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.viewer) === null || _b === void 0 ? void 0 : _b.messageLink), props.errorText);
|
|
79
84
|
}
|
|
80
85
|
else if (medium.toLocaleUpperCase() === "DIRECT") {
|
|
81
86
|
NativeShare({ sharetitle, sharetext }, directLink, props.errorText, props.unsupportedPlatformText);
|
|
82
87
|
}
|
|
83
88
|
else {
|
|
84
|
-
GenericShare((
|
|
89
|
+
GenericShare((overrideData === null || overrideData === void 0 ? void 0 : overrideData.messageLink) || ((_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.viewer) === null || _d === void 0 ? void 0 : _d.messageLink), props.errorText);
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
return { ...props, loading: res.loading, onClick, hide };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEngagementMedium, useMutation, useParentValue, useProgramId, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
2
2
|
import { useState } from "@saasquatch/universal-hooks";
|
|
3
3
|
import { gql } from "graphql-request";
|
|
4
|
-
import { REFERRAL_CODES_NAMESPACE, } from "../sqm-referral-codes/useReferralCodes";
|
|
4
|
+
import { REFERRAL_CODES_NAMESPACE, SET_CODE_USED, } from "../sqm-referral-codes/useReferralCodes";
|
|
5
5
|
const MessageLinkQuery = gql `
|
|
6
6
|
query ($programId: ID, $engagementMedium: UserEngagementMedium!) {
|
|
7
7
|
user: viewer {
|
|
@@ -28,11 +28,15 @@ export function useShareLink(props) {
|
|
|
28
28
|
const contextData = useParentValue(REFERRAL_CODES_NAMESPACE);
|
|
29
29
|
const { data } = useQuery(MessageLinkQuery, { programId, engagementMedium }, !(user === null || user === void 0 ? void 0 : user.jwt) || !!props.linkOverride || (contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) !== undefined);
|
|
30
30
|
const [sendLoadEvent] = useMutation(WIDGET_ENGAGEMENT_EVENT);
|
|
31
|
+
const [setUsed, usedRes] = useMutation(SET_CODE_USED);
|
|
31
32
|
const copyString = (_b = ((contextData === null || contextData === void 0 ? void 0 : contextData.shareLink) || ((_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.shareLink))) !== null && _b !== void 0 ? _b :
|
|
32
33
|
// Shown during loading
|
|
33
34
|
"...";
|
|
34
35
|
const [open, setOpen] = useState(false);
|
|
35
36
|
function onClick() {
|
|
37
|
+
if (contextData) {
|
|
38
|
+
setUsed(true);
|
|
39
|
+
}
|
|
36
40
|
// Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
|
|
37
41
|
// Only if called from a user-initiated event
|
|
38
42
|
navigator.clipboard.writeText(copyString);
|