@saasquatch/vanilla-components 1.2.4-9 → 1.2.5-1
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/{WidgetHost-cee741d8.js → WidgetHost-fce29ef5.js} +420 -577
- package/dist/cjs/{en-3a7cb52e.js → en-a49a5ef5.js} +2 -2
- package/dist/cjs/{index-09a04159.js → index-deb40352.js} +3 -54
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/sqh-close-button.cjs.entry.js +26 -26
- package/dist/cjs/{sqh-copy-button_14.cjs.entry.js → sqh-copy-button_12.cjs.entry.js} +976 -2246
- package/dist/cjs/sqh-referral-code.cjs.entry.js +23 -23
- package/dist/cjs/sqh-rewards-actions.cjs.entry.js +27 -27
- package/dist/cjs/widget-components.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +0 -2
- package/dist/collection/components/close-button/close-button.js +68 -70
- package/dist/collection/components/copy-button/copy-button.js +358 -367
- package/dist/collection/components/copy-link-button/copy-link-button.js +215 -221
- package/dist/collection/components/global-container/global-container.js +151 -165
- package/dist/collection/components/image-component/image-component.js +165 -168
- package/dist/collection/components/partner-stat-component/partner-stat-component.js +194 -197
- package/dist/collection/components/referral-code/referral-code.js +36 -36
- package/dist/collection/components/referral-component/referral-component.js +255 -255
- package/dist/collection/components/referral-list/referral-list.js +860 -884
- package/dist/collection/components/rewards-actions/rewards-actions.js +105 -105
- package/dist/collection/components/share-button/share-button.js +282 -291
- package/dist/collection/components/share-button-container/share-button-container.js +2384 -2439
- package/dist/collection/components/stat-component/stat-component.js +194 -198
- package/dist/collection/components/stats-container/stats-container.js +206 -206
- package/dist/collection/components/text-component/text-component.js +294 -294
- package/dist/collection/entrypoint.js +19 -17
- package/dist/collection/global/global.js +4 -4
- package/dist/collection/services/FormatJs.js +15 -15
- package/dist/collection/services/WidgetHost.js +426 -583
- package/dist/collection/utilities.js +81 -81
- package/dist/esm/{WidgetHost-6cd6c29a.js → WidgetHost-903fb7cc.js} +420 -577
- package/dist/esm/{en-a652ab83.js → en-be593af0.js} +1 -1
- package/dist/esm/{index-342d7c26.js → index-8ea8b6d8.js} +3 -54
- package/dist/esm/loader.mjs +3 -3
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/sqh-close-button.entry.js +26 -26
- package/dist/esm/{sqh-copy-button_14.entry.js → sqh-copy-button_12.entry.js} +977 -2245
- package/dist/esm/sqh-referral-code.entry.js +23 -23
- package/dist/esm/sqh-rewards-actions.entry.js +27 -27
- package/dist/esm/widget-components.mjs +3 -3
- package/dist/esm-es5/{WidgetHost-6cd6c29a.js → WidgetHost-903fb7cc.js} +9432 -9524
- package/dist/esm-es5/_commonjsHelpers-1d681858.js +17 -17
- package/dist/esm-es5/css-shim-a659079f.js +122 -122
- package/dist/esm-es5/dom-4061ceba.js +468 -468
- package/dist/esm-es5/{en-a652ab83.js → en-be593af0.js} +1471 -1471
- package/dist/esm-es5/{index-342d7c26.js → index-8ea8b6d8.js} +1758 -1808
- package/dist/esm-es5/loader.mjs +11 -11
- package/dist/esm-es5/sqh-close-button.entry.js +35 -35
- package/dist/esm-es5/{sqh-copy-button_14.entry.js → sqh-copy-button_12.entry.js} +9535 -10669
- package/dist/esm-es5/sqh-referral-code.entry.js +29 -29
- package/dist/esm-es5/sqh-rewards-actions.entry.js +31 -31
- package/dist/esm-es5/widget-components.mjs +6 -6
- package/dist/types/components/close-button/close-button.d.ts +16 -18
- package/dist/types/components/copy-button/copy-button.d.ts +90 -93
- package/dist/types/components/copy-link-button/copy-link-button.d.ts +53 -55
- package/dist/types/components/global-container/global-container.d.ts +39 -43
- package/dist/types/components/image-component/image-component.d.ts +45 -46
- package/dist/types/components/partner-stat-component/partner-stat-component.d.ts +51 -52
- package/dist/types/components/referral-code/referral-code.d.ts +12 -12
- package/dist/types/components/referral-component/referral-component.d.ts +46 -46
- package/dist/types/components/referral-list/referral-list.d.ts +234 -242
- package/dist/types/components/rewards-actions/rewards-actions.d.ts +25 -25
- package/dist/types/components/share-button/share-button.d.ts +77 -80
- package/dist/types/components/share-button-container/share-button-container.d.ts +593 -611
- package/dist/types/components/stat-component/stat-component.d.ts +48 -50
- package/dist/types/components/stats-container/stats-container.d.ts +47 -47
- package/dist/types/components/text-component/text-component.d.ts +74 -74
- package/dist/types/components.d.ts +218 -498
- package/dist/types/global/global.d.ts +4 -4
- package/dist/types/services/FormatJs.d.ts +7 -7
- package/dist/types/services/WidgetHost.d.ts +45 -51
- package/dist/types/utilities.d.ts +7 -7
- package/dist/widget-components/entrypoint.js +19 -17
- package/dist/widget-components/{p-1dfd20e2.entry.js → p-131a5c4a.entry.js} +1 -1
- package/dist/widget-components/p-1b8f2cfc.system.entry.js +8 -0
- package/dist/widget-components/p-24fc4ba9.js +1 -1
- package/dist/widget-components/{p-17d80384.js → p-44a6559d.js} +1 -1
- package/dist/widget-components/p-46109683.js +3 -3
- package/dist/widget-components/p-485eaf44.js +1 -0
- package/dist/widget-components/{p-9ffe6e46.entry.js → p-50ae8f2b.entry.js} +1 -1
- package/dist/widget-components/{p-e82def83.system.js → p-58be1132.system.js} +1 -1
- package/dist/widget-components/p-8baa34a0.entry.js +149 -0
- package/dist/widget-components/{p-fb528be6.entry.js → p-9746ae26.entry.js} +1 -1
- package/dist/widget-components/{p-aaf44379.system.js → p-a846f503.system.js} +1 -1
- package/dist/widget-components/{p-599e6d35.system.entry.js → p-b9fcb846.system.entry.js} +1 -1
- package/dist/widget-components/p-da180bcd.system.entry.js +1 -0
- package/dist/widget-components/{p-665b8d42.system.entry.js → p-e2b4739f.system.entry.js} +1 -1
- package/dist/widget-components/p-e61a8100.system.js +1 -0
- package/dist/widget-components/{p-b67d3319.system.js → p-e692beaf.system.js} +2 -2
- package/dist/widget-components/{p-4b1ab75c.js → p-ffeb02d1.js} +3 -68
- package/dist/widget-components/widget-components.esm.js +1 -1
- package/dist/widget-components/widget-components.js +1 -1
- package/docs/raisins.json +1 -1
- package/package.json +4 -4
- package/dist/collection/components/cta-component/cta-component.css +0 -6
- package/dist/collection/components/cta-component/cta-component.js +0 -396
- package/dist/collection/components/progress-indicator/progress-indicator.css +0 -73
- package/dist/collection/components/progress-indicator/progress-indicator.js +0 -493
- package/dist/types/components/cta-component/cta-component.d.ts +0 -86
- package/dist/types/components/progress-indicator/progress-indicator.d.ts +0 -42
- package/dist/widget-components/p-7d98ea96.entry.js +0 -233
- package/dist/widget-components/p-8ca0fd41.system.entry.js +0 -10
- package/dist/widget-components/p-ad5121cf.system.js +0 -1
- package/dist/widget-components/p-eeb2bfd4.system.entry.js +0 -1
- package/dist/widget-components/p-fbf0c7fe.js +0 -1
|
@@ -1,294 +1,294 @@
|
|
|
1
|
-
import { ApolloClient } from "apollo-client";
|
|
2
|
-
import { HttpLink } from "apollo-link-http";
|
|
3
|
-
import { InMemoryCache } from "apollo-cache-inmemory";
|
|
4
|
-
import gql from "graphql-tag";
|
|
5
|
-
if (!window["widgetIdent"]) {
|
|
6
|
-
window["widgetIdent"] = {
|
|
7
|
-
env: "demo",
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export function widgetIdent() {
|
|
11
|
-
//@ts-ignore
|
|
12
|
-
return window.widgetIdent;
|
|
13
|
-
}
|
|
14
|
-
const today = new Date();
|
|
15
|
-
const demoUser = {
|
|
16
|
-
shareLink: "http://ssqt.co",
|
|
17
|
-
fueltankCode: "12AS3F",
|
|
18
|
-
referralcode: "RIDDIKULUS",
|
|
19
|
-
locale: "en_US",
|
|
20
|
-
messageLink: {
|
|
21
|
-
EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
|
|
22
|
-
FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
23
|
-
TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
24
|
-
SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
25
|
-
WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
26
|
-
LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
27
|
-
PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
28
|
-
FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
29
|
-
},
|
|
30
|
-
referrals: {
|
|
31
|
-
totalCount: 9,
|
|
32
|
-
data: [
|
|
33
|
-
{
|
|
34
|
-
dateReferralStarted: today.setDate(today.getDate() - 2),
|
|
35
|
-
referredUser: { firstName: "Remus", lastName: "Lupin" },
|
|
36
|
-
rewards: [
|
|
37
|
-
{
|
|
38
|
-
prettyValue: "$20.00",
|
|
39
|
-
dateExpires: today.setDate(today.getDate() + 4),
|
|
40
|
-
statuses: ["EXPIRED"],
|
|
41
|
-
meta: { message: "Applied to Invoice #1234" },
|
|
42
|
-
},
|
|
43
|
-
{ prettyValue: "$10.00", statuses: ["AVAILABLE"] },
|
|
44
|
-
{ prettyValue: "$5.00", statuses: ["AVAILABLE"] },
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
dateReferralStarted: today.setDate(today.getDate() - 1),
|
|
49
|
-
referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
|
|
50
|
-
rewards: [],
|
|
51
|
-
},
|
|
52
|
-
// Blank string becomes an unknown user, which is editable
|
|
53
|
-
{
|
|
54
|
-
dateReferralStarted: today.setDate(today.getDate() - 1),
|
|
55
|
-
referredUser: { firstName: "", lastName: "" },
|
|
56
|
-
rewards: [
|
|
57
|
-
{
|
|
58
|
-
prettyValue: "$20.00",
|
|
59
|
-
dateExpires: today.setDate(today.getDate() - 2),
|
|
60
|
-
statuses: ["EXPIRED"],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
dateReferralStarted: today.setDate(today.getDate() - 5),
|
|
66
|
-
referredUser: { firstName: "Lavender", lastName: "Brown" },
|
|
67
|
-
rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
dateReferralStarted: today.setDate(today.getDate() - 4),
|
|
71
|
-
referredUser: { firstName: "Blaise", lastName: "Zabini" },
|
|
72
|
-
rewards: [
|
|
73
|
-
{ prettyValue: "$20.00", statuses: ["AVAILABLE"] },
|
|
74
|
-
{ prettyValue: "$10.00", statuses: ["AVAILABLE"] },
|
|
75
|
-
],
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
dateReferralStarted: today.setDate(today.getDate() - 10),
|
|
79
|
-
referredUser: { firstName: "Argus", lastName: "Filch" },
|
|
80
|
-
rewards: [],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
dateReferralStarted: today.setDate(today.getDate() - 15),
|
|
84
|
-
referredUser: { firstName: "Ron", lastName: "Weasley" },
|
|
85
|
-
rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
dateReferralStarted: today.setDate(today.getDate() - 2),
|
|
89
|
-
referredUser: { firstName: "Hermione", lastName: "Granger" },
|
|
90
|
-
rewards: [
|
|
91
|
-
{ prettyValue: "$20.00", statuses: ["AVAILABLE"] },
|
|
92
|
-
{ prettyValue: "$10.00", statuses: ["AVAILABLE"] },
|
|
93
|
-
{ prettyValue: "$5.00", statuses: ["AVAILABLE"] },
|
|
94
|
-
{ prettyValue: "5%", statuses: ["AVAILABLE"] },
|
|
95
|
-
{ prettyValue: "5%", statuses: ["AVAILABLE"] },
|
|
96
|
-
{ prettyValue: "5%", statuses: ["AVAILABLE"] },
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
dateConverted: 1606943971468,
|
|
101
|
-
dateReferralStarted: 1606943971468,
|
|
102
|
-
referredUser: {
|
|
103
|
-
imageUrl: "",
|
|
104
|
-
firstName: "Seamus",
|
|
105
|
-
lastName: "Finnigan",
|
|
106
|
-
},
|
|
107
|
-
rewards: [],
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
referredByReferral: {
|
|
112
|
-
dateReferralStarted: today.setDate(today.getDate() - 2),
|
|
113
|
-
referrerUser: {
|
|
114
|
-
firstName: "Rubeus",
|
|
115
|
-
lastName: "Hagrid",
|
|
116
|
-
referralCode: "RUBEUSHAGRID12",
|
|
117
|
-
},
|
|
118
|
-
rewards: [
|
|
119
|
-
{
|
|
120
|
-
fuelTankCode: "CODE1234",
|
|
121
|
-
prettyValue: "$10.00",
|
|
122
|
-
statuses: ["AVAILABLE"],
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
},
|
|
126
|
-
referralsMonth: { totalCount: 6 },
|
|
127
|
-
referralsWeek: { totalCount: 3 },
|
|
128
|
-
rewardsCount: { totalCount: 14 },
|
|
129
|
-
rewardsMonth: { totalCount: 7 },
|
|
130
|
-
rewardsWeek: { totalCount: 4 },
|
|
131
|
-
rewardBalancesGlobal: [
|
|
132
|
-
{
|
|
133
|
-
type: "CREDIT",
|
|
134
|
-
unit: "CENTS",
|
|
135
|
-
value: 17000,
|
|
136
|
-
prettyValue: "$170.00",
|
|
137
|
-
totalAssignedCredit: "17000",
|
|
138
|
-
totalRedeemedCredit: "1500",
|
|
139
|
-
prettyAssignedCredit: "$1000.00",
|
|
140
|
-
prettyRedeemedCredit: "$15.00",
|
|
141
|
-
},
|
|
142
|
-
{ type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
|
|
143
|
-
{
|
|
144
|
-
type: "CREDIT",
|
|
145
|
-
unit: "CASH/CAD",
|
|
146
|
-
count: 3,
|
|
147
|
-
totalPendingCredit: 20000,
|
|
148
|
-
totalAssignedCredit: 30000,
|
|
149
|
-
totalRedeemedCredit: 10000,
|
|
150
|
-
totalExpiredCredit: 0,
|
|
151
|
-
totalCancelledCredit: 0,
|
|
152
|
-
prettyPendingCredit: "$200.00",
|
|
153
|
-
prettyAssignedCredit: "$300.00",
|
|
154
|
-
prettyRedeemedCredit: "$100.00",
|
|
155
|
-
value: 30000,
|
|
156
|
-
prettyValue: "$300.00",
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
type: "CREDIT",
|
|
160
|
-
unit: "CASH/USD",
|
|
161
|
-
count: 6,
|
|
162
|
-
totalPendingCredit: 25000,
|
|
163
|
-
totalAssignedCredit: 40000,
|
|
164
|
-
totalRedeemedCredit: 10000,
|
|
165
|
-
totalExpiredCredit: 15000,
|
|
166
|
-
totalCancelledCredit: 10000,
|
|
167
|
-
prettyPendingCredit: "USD250.00",
|
|
168
|
-
prettyAssignedCredit: "USD400.00",
|
|
169
|
-
prettyRedeemedCredit: "USD150.00",
|
|
170
|
-
value: 40000,
|
|
171
|
-
prettyValue: "USD400.00",
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
rewardBalances: [
|
|
175
|
-
{
|
|
176
|
-
type: "CREDIT",
|
|
177
|
-
unit: "CENTS",
|
|
178
|
-
value: 17000,
|
|
179
|
-
prettyValue: "$170.00",
|
|
180
|
-
totalAssignedCredit: "17000",
|
|
181
|
-
totalRedeemedCredit: "1500",
|
|
182
|
-
prettyAssignedCredit: "$170.00",
|
|
183
|
-
prettyRedeemedCredit: "$15.00",
|
|
184
|
-
},
|
|
185
|
-
{ type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
|
|
186
|
-
{
|
|
187
|
-
type: "CREDIT",
|
|
188
|
-
unit: "CASH/CAD",
|
|
189
|
-
count: 3,
|
|
190
|
-
totalPendingCredit: 20000,
|
|
191
|
-
totalAssignedCredit: 30000,
|
|
192
|
-
totalRedeemedCredit: 10000,
|
|
193
|
-
totalExpiredCredit: 0,
|
|
194
|
-
totalCancelledCredit: 0,
|
|
195
|
-
prettyPendingCredit: "$200.00",
|
|
196
|
-
prettyAssignedCredit: "$300.00",
|
|
197
|
-
prettyRedeemedCredit: "$100.00",
|
|
198
|
-
value: 30000,
|
|
199
|
-
prettyValue: "$300.00",
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
type: "CREDIT",
|
|
203
|
-
unit: "CASH/USD",
|
|
204
|
-
count: 6,
|
|
205
|
-
totalPendingCredit: 25000,
|
|
206
|
-
totalAssignedCredit: 40000,
|
|
207
|
-
totalRedeemedCredit: 10000,
|
|
208
|
-
totalExpiredCredit: 15000,
|
|
209
|
-
totalCancelledCredit: 10000,
|
|
210
|
-
prettyPendingCredit: "USD250.00",
|
|
211
|
-
prettyAssignedCredit: "USD400.00",
|
|
212
|
-
prettyRedeemedCredit: "USD150.00",
|
|
213
|
-
value: 40000,
|
|
214
|
-
prettyValue: "USD400.00",
|
|
215
|
-
},
|
|
216
|
-
],
|
|
217
|
-
rewardBalanceDetails: [
|
|
218
|
-
{
|
|
219
|
-
prettyAvailableValue: "$5.00",
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
prettyAvailableValue: "18%",
|
|
223
|
-
},
|
|
224
|
-
],
|
|
225
|
-
};
|
|
226
|
-
//@ts-ignore
|
|
227
|
-
const squatchJsApi = window.frameElement
|
|
228
|
-
? window.frameElement.squatchJsApi
|
|
229
|
-
: {};
|
|
230
|
-
const apolloClient = () => {
|
|
231
|
-
const { tenantAlias, appDomain, token } = widgetIdent();
|
|
232
|
-
const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
|
|
233
|
-
const headers = {
|
|
234
|
-
Authorization: `Bearer ${token}`,
|
|
235
|
-
};
|
|
236
|
-
const client = new ApolloClient({
|
|
237
|
-
link: new HttpLink({ uri, headers }),
|
|
238
|
-
cache: new InMemoryCache(),
|
|
239
|
-
});
|
|
240
|
-
return client;
|
|
241
|
-
};
|
|
242
|
-
const API = {
|
|
243
|
-
version: "Welcome to widget-host",
|
|
244
|
-
analytics: {
|
|
245
|
-
shareEvent(shareMedium) {
|
|
246
|
-
const widgetId = widgetIdent();
|
|
247
|
-
if (widgetId["env"] === "demo" || !widgetId)
|
|
248
|
-
return Promise.resolve({});
|
|
249
|
-
const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
|
|
250
|
-
const variables = {
|
|
251
|
-
eventMeta: {
|
|
252
|
-
id: userId,
|
|
253
|
-
accountId,
|
|
254
|
-
programId,
|
|
255
|
-
type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
|
|
256
|
-
meta: {
|
|
257
|
-
engagementMedium,
|
|
258
|
-
shareMedium,
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
};
|
|
262
|
-
return apolloClient()
|
|
263
|
-
.mutate({
|
|
1
|
+
import { ApolloClient } from "apollo-client";
|
|
2
|
+
import { HttpLink } from "apollo-link-http";
|
|
3
|
+
import { InMemoryCache } from "apollo-cache-inmemory";
|
|
4
|
+
import gql from "graphql-tag";
|
|
5
|
+
if (!window["widgetIdent"]) {
|
|
6
|
+
window["widgetIdent"] = {
|
|
7
|
+
env: "demo",
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function widgetIdent() {
|
|
11
|
+
//@ts-ignore
|
|
12
|
+
return window.widgetIdent;
|
|
13
|
+
}
|
|
14
|
+
const today = new Date();
|
|
15
|
+
const demoUser = {
|
|
16
|
+
shareLink: "http://ssqt.co",
|
|
17
|
+
fueltankCode: "12AS3F",
|
|
18
|
+
referralcode: "RIDDIKULUS",
|
|
19
|
+
locale: "en_US",
|
|
20
|
+
messageLink: {
|
|
21
|
+
EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
|
|
22
|
+
FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
23
|
+
TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
24
|
+
SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
25
|
+
WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
26
|
+
LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
27
|
+
PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
28
|
+
FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
|
|
29
|
+
},
|
|
30
|
+
referrals: {
|
|
31
|
+
totalCount: 9,
|
|
32
|
+
data: [
|
|
33
|
+
{
|
|
34
|
+
dateReferralStarted: today.setDate(today.getDate() - 2),
|
|
35
|
+
referredUser: { firstName: "Remus", lastName: "Lupin" },
|
|
36
|
+
rewards: [
|
|
37
|
+
{
|
|
38
|
+
prettyValue: "$20.00",
|
|
39
|
+
dateExpires: today.setDate(today.getDate() + 4),
|
|
40
|
+
statuses: ["EXPIRED"],
|
|
41
|
+
meta: { message: "Applied to Invoice #1234" },
|
|
42
|
+
},
|
|
43
|
+
{ prettyValue: "$10.00", statuses: ["AVAILABLE"] },
|
|
44
|
+
{ prettyValue: "$5.00", statuses: ["AVAILABLE"] },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
dateReferralStarted: today.setDate(today.getDate() - 1),
|
|
49
|
+
referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
|
|
50
|
+
rewards: [],
|
|
51
|
+
},
|
|
52
|
+
// Blank string becomes an unknown user, which is editable
|
|
53
|
+
{
|
|
54
|
+
dateReferralStarted: today.setDate(today.getDate() - 1),
|
|
55
|
+
referredUser: { firstName: "", lastName: "" },
|
|
56
|
+
rewards: [
|
|
57
|
+
{
|
|
58
|
+
prettyValue: "$20.00",
|
|
59
|
+
dateExpires: today.setDate(today.getDate() - 2),
|
|
60
|
+
statuses: ["EXPIRED"],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
dateReferralStarted: today.setDate(today.getDate() - 5),
|
|
66
|
+
referredUser: { firstName: "Lavender", lastName: "Brown" },
|
|
67
|
+
rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
dateReferralStarted: today.setDate(today.getDate() - 4),
|
|
71
|
+
referredUser: { firstName: "Blaise", lastName: "Zabini" },
|
|
72
|
+
rewards: [
|
|
73
|
+
{ prettyValue: "$20.00", statuses: ["AVAILABLE"] },
|
|
74
|
+
{ prettyValue: "$10.00", statuses: ["AVAILABLE"] },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
dateReferralStarted: today.setDate(today.getDate() - 10),
|
|
79
|
+
referredUser: { firstName: "Argus", lastName: "Filch" },
|
|
80
|
+
rewards: [],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
dateReferralStarted: today.setDate(today.getDate() - 15),
|
|
84
|
+
referredUser: { firstName: "Ron", lastName: "Weasley" },
|
|
85
|
+
rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
dateReferralStarted: today.setDate(today.getDate() - 2),
|
|
89
|
+
referredUser: { firstName: "Hermione", lastName: "Granger" },
|
|
90
|
+
rewards: [
|
|
91
|
+
{ prettyValue: "$20.00", statuses: ["AVAILABLE"] },
|
|
92
|
+
{ prettyValue: "$10.00", statuses: ["AVAILABLE"] },
|
|
93
|
+
{ prettyValue: "$5.00", statuses: ["AVAILABLE"] },
|
|
94
|
+
{ prettyValue: "5%", statuses: ["AVAILABLE"] },
|
|
95
|
+
{ prettyValue: "5%", statuses: ["AVAILABLE"] },
|
|
96
|
+
{ prettyValue: "5%", statuses: ["AVAILABLE"] },
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
dateConverted: 1606943971468,
|
|
101
|
+
dateReferralStarted: 1606943971468,
|
|
102
|
+
referredUser: {
|
|
103
|
+
imageUrl: "",
|
|
104
|
+
firstName: "Seamus",
|
|
105
|
+
lastName: "Finnigan",
|
|
106
|
+
},
|
|
107
|
+
rewards: [],
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
referredByReferral: {
|
|
112
|
+
dateReferralStarted: today.setDate(today.getDate() - 2),
|
|
113
|
+
referrerUser: {
|
|
114
|
+
firstName: "Rubeus",
|
|
115
|
+
lastName: "Hagrid",
|
|
116
|
+
referralCode: "RUBEUSHAGRID12",
|
|
117
|
+
},
|
|
118
|
+
rewards: [
|
|
119
|
+
{
|
|
120
|
+
fuelTankCode: "CODE1234",
|
|
121
|
+
prettyValue: "$10.00",
|
|
122
|
+
statuses: ["AVAILABLE"],
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
referralsMonth: { totalCount: 6 },
|
|
127
|
+
referralsWeek: { totalCount: 3 },
|
|
128
|
+
rewardsCount: { totalCount: 14 },
|
|
129
|
+
rewardsMonth: { totalCount: 7 },
|
|
130
|
+
rewardsWeek: { totalCount: 4 },
|
|
131
|
+
rewardBalancesGlobal: [
|
|
132
|
+
{
|
|
133
|
+
type: "CREDIT",
|
|
134
|
+
unit: "CENTS",
|
|
135
|
+
value: 17000,
|
|
136
|
+
prettyValue: "$170.00",
|
|
137
|
+
totalAssignedCredit: "17000",
|
|
138
|
+
totalRedeemedCredit: "1500",
|
|
139
|
+
prettyAssignedCredit: "$1000.00",
|
|
140
|
+
prettyRedeemedCredit: "$15.00",
|
|
141
|
+
},
|
|
142
|
+
{ type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
|
|
143
|
+
{
|
|
144
|
+
type: "CREDIT",
|
|
145
|
+
unit: "CASH/CAD",
|
|
146
|
+
count: 3,
|
|
147
|
+
totalPendingCredit: 20000,
|
|
148
|
+
totalAssignedCredit: 30000,
|
|
149
|
+
totalRedeemedCredit: 10000,
|
|
150
|
+
totalExpiredCredit: 0,
|
|
151
|
+
totalCancelledCredit: 0,
|
|
152
|
+
prettyPendingCredit: "$200.00",
|
|
153
|
+
prettyAssignedCredit: "$300.00",
|
|
154
|
+
prettyRedeemedCredit: "$100.00",
|
|
155
|
+
value: 30000,
|
|
156
|
+
prettyValue: "$300.00",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
type: "CREDIT",
|
|
160
|
+
unit: "CASH/USD",
|
|
161
|
+
count: 6,
|
|
162
|
+
totalPendingCredit: 25000,
|
|
163
|
+
totalAssignedCredit: 40000,
|
|
164
|
+
totalRedeemedCredit: 10000,
|
|
165
|
+
totalExpiredCredit: 15000,
|
|
166
|
+
totalCancelledCredit: 10000,
|
|
167
|
+
prettyPendingCredit: "USD250.00",
|
|
168
|
+
prettyAssignedCredit: "USD400.00",
|
|
169
|
+
prettyRedeemedCredit: "USD150.00",
|
|
170
|
+
value: 40000,
|
|
171
|
+
prettyValue: "USD400.00",
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
rewardBalances: [
|
|
175
|
+
{
|
|
176
|
+
type: "CREDIT",
|
|
177
|
+
unit: "CENTS",
|
|
178
|
+
value: 17000,
|
|
179
|
+
prettyValue: "$170.00",
|
|
180
|
+
totalAssignedCredit: "17000",
|
|
181
|
+
totalRedeemedCredit: "1500",
|
|
182
|
+
prettyAssignedCredit: "$170.00",
|
|
183
|
+
prettyRedeemedCredit: "$15.00",
|
|
184
|
+
},
|
|
185
|
+
{ type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
|
|
186
|
+
{
|
|
187
|
+
type: "CREDIT",
|
|
188
|
+
unit: "CASH/CAD",
|
|
189
|
+
count: 3,
|
|
190
|
+
totalPendingCredit: 20000,
|
|
191
|
+
totalAssignedCredit: 30000,
|
|
192
|
+
totalRedeemedCredit: 10000,
|
|
193
|
+
totalExpiredCredit: 0,
|
|
194
|
+
totalCancelledCredit: 0,
|
|
195
|
+
prettyPendingCredit: "$200.00",
|
|
196
|
+
prettyAssignedCredit: "$300.00",
|
|
197
|
+
prettyRedeemedCredit: "$100.00",
|
|
198
|
+
value: 30000,
|
|
199
|
+
prettyValue: "$300.00",
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
type: "CREDIT",
|
|
203
|
+
unit: "CASH/USD",
|
|
204
|
+
count: 6,
|
|
205
|
+
totalPendingCredit: 25000,
|
|
206
|
+
totalAssignedCredit: 40000,
|
|
207
|
+
totalRedeemedCredit: 10000,
|
|
208
|
+
totalExpiredCredit: 15000,
|
|
209
|
+
totalCancelledCredit: 10000,
|
|
210
|
+
prettyPendingCredit: "USD250.00",
|
|
211
|
+
prettyAssignedCredit: "USD400.00",
|
|
212
|
+
prettyRedeemedCredit: "USD150.00",
|
|
213
|
+
value: 40000,
|
|
214
|
+
prettyValue: "USD400.00",
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
rewardBalanceDetails: [
|
|
218
|
+
{
|
|
219
|
+
prettyAvailableValue: "$5.00",
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
prettyAvailableValue: "18%",
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
};
|
|
226
|
+
//@ts-ignore
|
|
227
|
+
const squatchJsApi = window.frameElement
|
|
228
|
+
? window.frameElement.squatchJsApi
|
|
229
|
+
: {};
|
|
230
|
+
const apolloClient = () => {
|
|
231
|
+
const { tenantAlias, appDomain, token } = widgetIdent();
|
|
232
|
+
const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
|
|
233
|
+
const headers = {
|
|
234
|
+
Authorization: `Bearer ${token}`,
|
|
235
|
+
};
|
|
236
|
+
const client = new ApolloClient({
|
|
237
|
+
link: new HttpLink({ uri, headers }),
|
|
238
|
+
cache: new InMemoryCache(),
|
|
239
|
+
});
|
|
240
|
+
return client;
|
|
241
|
+
};
|
|
242
|
+
const API = {
|
|
243
|
+
version: "Welcome to widget-host",
|
|
244
|
+
analytics: {
|
|
245
|
+
shareEvent(shareMedium) {
|
|
246
|
+
const widgetId = widgetIdent();
|
|
247
|
+
if (widgetId["env"] === "demo" || !widgetId)
|
|
248
|
+
return Promise.resolve({});
|
|
249
|
+
const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
|
|
250
|
+
const variables = {
|
|
251
|
+
eventMeta: {
|
|
252
|
+
id: userId,
|
|
253
|
+
accountId,
|
|
254
|
+
programId,
|
|
255
|
+
type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
|
|
256
|
+
meta: {
|
|
257
|
+
engagementMedium,
|
|
258
|
+
shareMedium,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
return apolloClient()
|
|
263
|
+
.mutate({
|
|
264
264
|
mutation: gql `
|
|
265
265
|
mutation ($eventMeta: UserAnalyticsEvent!) {
|
|
266
266
|
createUserAnalyticsEvent(eventMeta: $eventMeta)
|
|
267
267
|
}
|
|
268
|
-
`,
|
|
269
|
-
variables,
|
|
270
|
-
})
|
|
271
|
-
.then((result) => {
|
|
272
|
-
return result.data.createUserAnalyticsEvent;
|
|
273
|
-
});
|
|
274
|
-
},
|
|
275
|
-
loadEvent() {
|
|
276
|
-
return Promise.resolve({ event: "loadEvent" });
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
graphql: {
|
|
280
|
-
getClient() {
|
|
281
|
-
return apolloClient();
|
|
282
|
-
},
|
|
283
|
-
getUserFragment(userFragment, fragmentVariables) {
|
|
268
|
+
`,
|
|
269
|
+
variables,
|
|
270
|
+
})
|
|
271
|
+
.then((result) => {
|
|
272
|
+
return result.data.createUserAnalyticsEvent;
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
loadEvent() {
|
|
276
|
+
return Promise.resolve({ event: "loadEvent" });
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
graphql: {
|
|
280
|
+
getClient() {
|
|
281
|
+
return apolloClient();
|
|
282
|
+
},
|
|
283
|
+
getUserFragment(userFragment, fragmentVariables) {
|
|
284
284
|
const fragment = gql `
|
|
285
285
|
fragment UserFragment on User {
|
|
286
286
|
${userFragment}
|
|
287
|
-
}`;
|
|
288
|
-
const { userId, accountId } = widgetIdent();
|
|
289
|
-
const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
|
|
290
|
-
accountId });
|
|
291
|
-
return this.getClient().query({
|
|
287
|
+
}`;
|
|
288
|
+
const { userId, accountId } = widgetIdent();
|
|
289
|
+
const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
|
|
290
|
+
accountId });
|
|
291
|
+
return this.getClient().query({
|
|
292
292
|
query: gql `
|
|
293
293
|
query ($userId: String!, $accountId: String!, $offset: Int) {
|
|
294
294
|
user(id: $userId, accountId: $accountId) {
|
|
@@ -296,23 +296,23 @@ const API = {
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
${fragment}
|
|
299
|
-
`,
|
|
300
|
-
variables,
|
|
301
|
-
});
|
|
302
|
-
},
|
|
303
|
-
getShareLink() {
|
|
304
|
-
const widgetId = widgetIdent();
|
|
305
|
-
if (widgetId["env"] === "demo" || !widgetId)
|
|
306
|
-
return Promise.resolve(demoUser.shareLink);
|
|
307
|
-
const { userId, accountId, programId = null, engagementMedium, } = widgetId;
|
|
308
|
-
const variables = {
|
|
309
|
-
userId,
|
|
310
|
-
accountId,
|
|
311
|
-
programId,
|
|
312
|
-
engagementMedium,
|
|
313
|
-
};
|
|
314
|
-
return this.getClient()
|
|
315
|
-
.query({
|
|
299
|
+
`,
|
|
300
|
+
variables,
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
getShareLink() {
|
|
304
|
+
const widgetId = widgetIdent();
|
|
305
|
+
if (widgetId["env"] === "demo" || !widgetId)
|
|
306
|
+
return Promise.resolve(demoUser.shareLink);
|
|
307
|
+
const { userId, accountId, programId = null, engagementMedium, } = widgetId;
|
|
308
|
+
const variables = {
|
|
309
|
+
userId,
|
|
310
|
+
accountId,
|
|
311
|
+
programId,
|
|
312
|
+
engagementMedium,
|
|
313
|
+
};
|
|
314
|
+
return this.getClient()
|
|
315
|
+
.query({
|
|
316
316
|
query: gql `
|
|
317
317
|
query (
|
|
318
318
|
$userId: String!
|
|
@@ -329,33 +329,33 @@ const API = {
|
|
|
329
329
|
)
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
`,
|
|
333
|
-
variables,
|
|
334
|
-
})
|
|
335
|
-
.then((res) => res.data.user.shareLink);
|
|
336
|
-
},
|
|
337
|
-
getReferrals(showReferrer, offset = 0, limit = 3) {
|
|
338
|
-
const widgetId = widgetIdent();
|
|
339
|
-
if (widgetId["env"] === "demo" || !widgetId) {
|
|
340
|
-
const { referrals: refs, referredByReferral, locale } = demoUser;
|
|
341
|
-
const referrals = {
|
|
342
|
-
totalCount: refs.totalCount,
|
|
343
|
-
data: refs.data.slice(offset, offset + limit),
|
|
344
|
-
};
|
|
345
|
-
const user = { referrals, referredByReferral, locale };
|
|
346
|
-
return Promise.resolve(user);
|
|
347
|
-
}
|
|
348
|
-
const { userId, accountId, programId = null } = widgetId;
|
|
349
|
-
const variables = {
|
|
350
|
-
limit,
|
|
351
|
-
offset,
|
|
352
|
-
userId,
|
|
353
|
-
accountId,
|
|
354
|
-
programId,
|
|
355
|
-
programId_exists: programId ? true : false,
|
|
356
|
-
};
|
|
357
|
-
return this.getClient()
|
|
358
|
-
.query({
|
|
332
|
+
`,
|
|
333
|
+
variables,
|
|
334
|
+
})
|
|
335
|
+
.then((res) => res.data.user.shareLink);
|
|
336
|
+
},
|
|
337
|
+
getReferrals(showReferrer, offset = 0, limit = 3) {
|
|
338
|
+
const widgetId = widgetIdent();
|
|
339
|
+
if (widgetId["env"] === "demo" || !widgetId) {
|
|
340
|
+
const { referrals: refs, referredByReferral, locale } = demoUser;
|
|
341
|
+
const referrals = {
|
|
342
|
+
totalCount: refs.totalCount,
|
|
343
|
+
data: refs.data.slice(offset, offset + limit),
|
|
344
|
+
};
|
|
345
|
+
const user = { referrals, referredByReferral, locale };
|
|
346
|
+
return Promise.resolve(user);
|
|
347
|
+
}
|
|
348
|
+
const { userId, accountId, programId = null } = widgetId;
|
|
349
|
+
const variables = {
|
|
350
|
+
limit,
|
|
351
|
+
offset,
|
|
352
|
+
userId,
|
|
353
|
+
accountId,
|
|
354
|
+
programId,
|
|
355
|
+
programId_exists: programId ? true : false,
|
|
356
|
+
};
|
|
357
|
+
return this.getClient()
|
|
358
|
+
.query({
|
|
359
359
|
query: gql `
|
|
360
360
|
query (
|
|
361
361
|
$userId: String!
|
|
@@ -395,7 +395,7 @@ const API = {
|
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
${showReferrer
|
|
398
|
+
${showReferrer
|
|
399
399
|
? `referredByReferral(programId: $programId) {
|
|
400
400
|
referrerUser {
|
|
401
401
|
firstName
|
|
@@ -408,40 +408,40 @@ const API = {
|
|
|
408
408
|
prettyValue
|
|
409
409
|
statuses
|
|
410
410
|
}
|
|
411
|
-
}`
|
|
411
|
+
}`
|
|
412
412
|
: ""}
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
|
-
`,
|
|
416
|
-
variables,
|
|
417
|
-
})
|
|
418
|
-
.then((res) => res.data.user);
|
|
419
|
-
},
|
|
420
|
-
getStats() {
|
|
421
|
-
const widgetId = widgetIdent();
|
|
422
|
-
if (widgetId["env"] === "demo" || !widgetId) {
|
|
423
|
-
const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
|
|
424
|
-
const user = {
|
|
425
|
-
referralsCount,
|
|
426
|
-
referralsMonth,
|
|
427
|
-
referralsWeek,
|
|
428
|
-
rewardsCount,
|
|
429
|
-
rewardsMonth,
|
|
430
|
-
rewardsWeek,
|
|
431
|
-
rewardBalances,
|
|
432
|
-
rewardBalancesGlobal,
|
|
433
|
-
};
|
|
434
|
-
return Promise.resolve(user);
|
|
435
|
-
}
|
|
436
|
-
const { userId, accountId, programId = null } = widgetId;
|
|
437
|
-
const variables = {
|
|
438
|
-
userId,
|
|
439
|
-
accountId,
|
|
440
|
-
programId,
|
|
441
|
-
programId_exists: programId ? true : false,
|
|
442
|
-
};
|
|
443
|
-
return this.getClient()
|
|
444
|
-
.query({
|
|
415
|
+
`,
|
|
416
|
+
variables,
|
|
417
|
+
})
|
|
418
|
+
.then((res) => res.data.user);
|
|
419
|
+
},
|
|
420
|
+
getStats() {
|
|
421
|
+
const widgetId = widgetIdent();
|
|
422
|
+
if (widgetId["env"] === "demo" || !widgetId) {
|
|
423
|
+
const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
|
|
424
|
+
const user = {
|
|
425
|
+
referralsCount,
|
|
426
|
+
referralsMonth,
|
|
427
|
+
referralsWeek,
|
|
428
|
+
rewardsCount,
|
|
429
|
+
rewardsMonth,
|
|
430
|
+
rewardsWeek,
|
|
431
|
+
rewardBalances,
|
|
432
|
+
rewardBalancesGlobal,
|
|
433
|
+
};
|
|
434
|
+
return Promise.resolve(user);
|
|
435
|
+
}
|
|
436
|
+
const { userId, accountId, programId = null } = widgetId;
|
|
437
|
+
const variables = {
|
|
438
|
+
userId,
|
|
439
|
+
accountId,
|
|
440
|
+
programId,
|
|
441
|
+
programId_exists: programId ? true : false,
|
|
442
|
+
};
|
|
443
|
+
return this.getClient()
|
|
444
|
+
.query({
|
|
445
445
|
query: gql `
|
|
446
446
|
query (
|
|
447
447
|
$userId: String!
|
|
@@ -506,137 +506,51 @@ const API = {
|
|
|
506
506
|
rewardBalancesGlobal: rewardBalances
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
|
-
`,
|
|
510
|
-
variables,
|
|
511
|
-
})
|
|
512
|
-
.then((res) => res.data.user);
|
|
513
|
-
},
|
|
514
|
-
|
|
515
|
-
const widgetId = widgetIdent();
|
|
516
|
-
if (widgetId["env"] === "demo" || !widgetId)
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
accountId,
|
|
527
|
-
programId,
|
|
528
|
-
locale
|
|
529
|
-
};
|
|
530
|
-
return this.getClient().query({
|
|
531
|
-
query: gql `
|
|
532
|
-
query(
|
|
533
|
-
$userId: String!,
|
|
534
|
-
$accountId: String!,
|
|
535
|
-
$programId: ID,
|
|
536
|
-
$locale: String!
|
|
537
|
-
) {
|
|
538
|
-
user(id: $userId, accountId: $accountId) {
|
|
539
|
-
rewardBalanceDetails(programId: $programId) {
|
|
540
|
-
prettyAvailableValue
|
|
541
|
-
unit
|
|
542
|
-
... on CreditRewardBalance {
|
|
543
|
-
prettyAssignedCredit
|
|
544
|
-
prettyRedeemedCredit
|
|
545
|
-
rewardUnit {
|
|
546
|
-
currency {
|
|
547
|
-
displayName(locale: $locale)
|
|
548
|
-
symbol(locale: $locale)
|
|
549
|
-
currencyCode
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
`,
|
|
557
|
-
variables
|
|
558
|
-
}).then(res => res.data.user);
|
|
559
|
-
},
|
|
560
|
-
getRewardExpiries() {
|
|
561
|
-
const widgetId = widgetIdent();
|
|
562
|
-
if (widgetId["env"] === "demo" || !widgetId) {
|
|
563
|
-
const { rewardBalanceDetails } = demoUser;
|
|
564
|
-
const user = {
|
|
565
|
-
rewardBalanceDetails
|
|
566
|
-
};
|
|
567
|
-
return Promise.resolve(user);
|
|
568
|
-
}
|
|
569
|
-
const { userId, accountId, programId = null, locale } = widgetId;
|
|
570
|
-
const variables = {
|
|
571
|
-
userId,
|
|
572
|
-
accountId,
|
|
573
|
-
programId,
|
|
574
|
-
locale
|
|
575
|
-
};
|
|
576
|
-
return this.getClient().query({
|
|
577
|
-
query: gql `
|
|
578
|
-
query(
|
|
579
|
-
$userId: String!,
|
|
580
|
-
$accountId: String!,
|
|
581
|
-
$programId: ID,
|
|
582
|
-
$locale: String!
|
|
583
|
-
) {
|
|
584
|
-
user(id: $userId, accountId: $accountId) {
|
|
585
|
-
rewards(programId_eq: $programId) {
|
|
586
|
-
data {
|
|
587
|
-
dateCreated
|
|
588
|
-
dateScheduledFor
|
|
589
|
-
dateExpires
|
|
590
|
-
prettyValue
|
|
591
|
-
unit
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
`,
|
|
597
|
-
variables
|
|
598
|
-
}).then(res => res.data.user);
|
|
599
|
-
},
|
|
600
|
-
async getReferralCode() {
|
|
601
|
-
const widgetId = widgetIdent();
|
|
602
|
-
if (widgetId["env"] === "demo" || !widgetId)
|
|
603
|
-
return demoUser.referralcode;
|
|
604
|
-
const { userId, accountId, programId } = widgetId;
|
|
605
|
-
const variables = {
|
|
606
|
-
userId,
|
|
607
|
-
accountId,
|
|
608
|
-
programId,
|
|
609
|
-
};
|
|
610
|
-
return this.getClient()
|
|
611
|
-
.query({
|
|
509
|
+
`,
|
|
510
|
+
variables,
|
|
511
|
+
})
|
|
512
|
+
.then((res) => res.data.user);
|
|
513
|
+
},
|
|
514
|
+
async getReferralCode() {
|
|
515
|
+
const widgetId = widgetIdent();
|
|
516
|
+
if (widgetId["env"] === "demo" || !widgetId)
|
|
517
|
+
return demoUser.referralcode;
|
|
518
|
+
const { userId, accountId, programId } = widgetId;
|
|
519
|
+
const variables = {
|
|
520
|
+
userId,
|
|
521
|
+
accountId,
|
|
522
|
+
programId,
|
|
523
|
+
};
|
|
524
|
+
return this.getClient()
|
|
525
|
+
.query({
|
|
612
526
|
query: gql `
|
|
613
527
|
query ($userId: String!, $accountId: String!, $programId: ID!) {
|
|
614
528
|
user(id: $userId, accountId: $accountId) {
|
|
615
529
|
referralCode(programId: $programId)
|
|
616
530
|
}
|
|
617
531
|
}
|
|
618
|
-
`,
|
|
619
|
-
variables,
|
|
620
|
-
})
|
|
621
|
-
.then((res) => res.data.user.referralCode);
|
|
622
|
-
},
|
|
623
|
-
async getFueltankCode(rewardKey) {
|
|
624
|
-
const widgetId = widgetIdent();
|
|
625
|
-
if (widgetId["env"] === "demo" || !widgetId) {
|
|
626
|
-
return {
|
|
627
|
-
referredByReferral: demoUser.referredByReferral,
|
|
628
|
-
rewards: { data: demoUser.referredByReferral.rewards },
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
const { userId, accountId, programId } = widgetId;
|
|
632
|
-
const variables = {
|
|
633
|
-
userId,
|
|
634
|
-
accountId,
|
|
635
|
-
programId,
|
|
636
|
-
rewardKey,
|
|
637
|
-
};
|
|
638
|
-
return this.getClient()
|
|
639
|
-
.query({
|
|
532
|
+
`,
|
|
533
|
+
variables,
|
|
534
|
+
})
|
|
535
|
+
.then((res) => res.data.user.referralCode);
|
|
536
|
+
},
|
|
537
|
+
async getFueltankCode(rewardKey) {
|
|
538
|
+
const widgetId = widgetIdent();
|
|
539
|
+
if (widgetId["env"] === "demo" || !widgetId) {
|
|
540
|
+
return {
|
|
541
|
+
referredByReferral: demoUser.referredByReferral,
|
|
542
|
+
rewards: { data: demoUser.referredByReferral.rewards },
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
const { userId, accountId, programId } = widgetId;
|
|
546
|
+
const variables = {
|
|
547
|
+
userId,
|
|
548
|
+
accountId,
|
|
549
|
+
programId,
|
|
550
|
+
rewardKey,
|
|
551
|
+
};
|
|
552
|
+
return this.getClient()
|
|
553
|
+
.query({
|
|
640
554
|
query: gql `
|
|
641
555
|
query (
|
|
642
556
|
$userId: String!
|
|
@@ -664,24 +578,24 @@ const API = {
|
|
|
664
578
|
}
|
|
665
579
|
}
|
|
666
580
|
}
|
|
667
|
-
`,
|
|
668
|
-
variables,
|
|
669
|
-
})
|
|
670
|
-
.then((res) => res.data.user);
|
|
671
|
-
},
|
|
672
|
-
getMessageLinks(mediums) {
|
|
673
|
-
const widgetId = widgetIdent();
|
|
674
|
-
if (widgetId["env"] === "demo" || !widgetId)
|
|
675
|
-
return Promise.resolve(demoUser.messageLink);
|
|
676
|
-
const { userId, accountId, programId = null, engagementMedium, } = widgetId;
|
|
677
|
-
const variables = {
|
|
678
|
-
userId,
|
|
679
|
-
accountId,
|
|
680
|
-
programId,
|
|
681
|
-
engagementMedium,
|
|
682
|
-
};
|
|
683
|
-
return this.getClient()
|
|
684
|
-
.query({
|
|
581
|
+
`,
|
|
582
|
+
variables,
|
|
583
|
+
})
|
|
584
|
+
.then((res) => res.data.user);
|
|
585
|
+
},
|
|
586
|
+
getMessageLinks(mediums) {
|
|
587
|
+
const widgetId = widgetIdent();
|
|
588
|
+
if (widgetId["env"] === "demo" || !widgetId)
|
|
589
|
+
return Promise.resolve(demoUser.messageLink);
|
|
590
|
+
const { userId, accountId, programId = null, engagementMedium, } = widgetId;
|
|
591
|
+
const variables = {
|
|
592
|
+
userId,
|
|
593
|
+
accountId,
|
|
594
|
+
programId,
|
|
595
|
+
engagementMedium,
|
|
596
|
+
};
|
|
597
|
+
return this.getClient()
|
|
598
|
+
.query({
|
|
685
599
|
query: gql `
|
|
686
600
|
query($userId: String!, $accountId: String!, $programId: ID, $engagementMedium: UserEngagementMedium!) {
|
|
687
601
|
user(id: $userId, accountId: $accountId) {
|
|
@@ -696,83 +610,12 @@ const API = {
|
|
|
696
610
|
${mediums[8]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[8]})
|
|
697
611
|
}
|
|
698
612
|
}
|
|
699
|
-
`,
|
|
700
|
-
variables,
|
|
701
|
-
})
|
|
702
|
-
.then((res) => res.data.user);
|
|
703
|
-
},
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
customFields: { demo_totalValue: 16 },
|
|
709
|
-
rewardBalanceDetails: [{
|
|
710
|
-
prettyAvailableValue: "$10.00"
|
|
711
|
-
}],
|
|
712
|
-
rewards: { count: 1 }
|
|
713
|
-
};
|
|
714
|
-
return Promise.resolve(demoData);
|
|
715
|
-
}
|
|
716
|
-
const { userId, accountId, programId } = widgetId;
|
|
717
|
-
const variables = {
|
|
718
|
-
userId,
|
|
719
|
-
accountId,
|
|
720
|
-
programId,
|
|
721
|
-
};
|
|
722
|
-
return this.getClient().query({
|
|
723
|
-
query: gql `
|
|
724
|
-
query($userId: String!, $accountId: String!, $programId: ID) {
|
|
725
|
-
user(id: $userId, accountId: $accountId){
|
|
726
|
-
customFields
|
|
727
|
-
locale
|
|
728
|
-
rewardBalanceDetails(programId: $programId) {
|
|
729
|
-
prettyAvailableValue(formatType:UNIT_FORMATTED)
|
|
730
|
-
}
|
|
731
|
-
rewards(limit:1000,offset:0, filter:{programId_eq: $programId}){
|
|
732
|
-
count
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
`,
|
|
737
|
-
variables
|
|
738
|
-
}).then(res => res.data.user);
|
|
739
|
-
},
|
|
740
|
-
getProgramRules() {
|
|
741
|
-
const widgetId = widgetIdent();
|
|
742
|
-
if (widgetId["env"] === "demo" || !widgetId) {
|
|
743
|
-
const demoData = {
|
|
744
|
-
id: "demo",
|
|
745
|
-
name: "Demo Program",
|
|
746
|
-
rules: {
|
|
747
|
-
programWindow: "",
|
|
748
|
-
rewardRules: {
|
|
749
|
-
rewardRulesType: 1,
|
|
750
|
-
rewardGoal: 24,
|
|
751
|
-
isRecurring: 1,
|
|
752
|
-
defaultCurrency: "CAD"
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
return Promise.resolve(demoData);
|
|
757
|
-
}
|
|
758
|
-
const { programId } = widgetId;
|
|
759
|
-
const variables = {
|
|
760
|
-
programId
|
|
761
|
-
};
|
|
762
|
-
return this.getClient().query({
|
|
763
|
-
query: gql `
|
|
764
|
-
query($programId: ID!) {
|
|
765
|
-
program(id:$programId){
|
|
766
|
-
id
|
|
767
|
-
name
|
|
768
|
-
rules
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
`,
|
|
772
|
-
variables
|
|
773
|
-
}).then(res => res.data.program);
|
|
774
|
-
},
|
|
775
|
-
},
|
|
776
|
-
ui: squatchJsApi,
|
|
777
|
-
};
|
|
778
|
-
export { API };
|
|
613
|
+
`,
|
|
614
|
+
variables,
|
|
615
|
+
})
|
|
616
|
+
.then((res) => res.data.user);
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
ui: squatchJsApi,
|
|
620
|
+
};
|
|
621
|
+
export { API };
|