@saasquatch/vanilla-components 1.2.4 → 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.
Files changed (84) hide show
  1. package/dist/cjs/{WidgetHost-d7b870ce.js → WidgetHost-fce29ef5.js} +420 -420
  2. package/dist/cjs/sqh-close-button.cjs.entry.js +25 -25
  3. package/dist/cjs/sqh-copy-button_12.cjs.entry.js +870 -971
  4. package/dist/cjs/sqh-referral-code.cjs.entry.js +22 -22
  5. package/dist/cjs/sqh-rewards-actions.cjs.entry.js +26 -26
  6. package/dist/collection/components/close-button/close-button.js +68 -68
  7. package/dist/collection/components/copy-button/copy-button.js +358 -358
  8. package/dist/collection/components/copy-link-button/copy-link-button.js +215 -215
  9. package/dist/collection/components/global-container/global-container.js +151 -151
  10. package/dist/collection/components/image-component/image-component.js +165 -165
  11. package/dist/collection/components/partner-stat-component/partner-stat-component.js +194 -194
  12. package/dist/collection/components/referral-code/referral-code.js +36 -36
  13. package/dist/collection/components/referral-component/referral-component.js +255 -255
  14. package/dist/collection/components/referral-list/referral-list.js +860 -860
  15. package/dist/collection/components/rewards-actions/rewards-actions.js +105 -105
  16. package/dist/collection/components/share-button/share-button.js +282 -282
  17. package/dist/collection/components/share-button-container/share-button-container.js +2384 -2384
  18. package/dist/collection/components/stat-component/stat-component.js +194 -194
  19. package/dist/collection/components/stats-container/stats-container.js +206 -206
  20. package/dist/collection/components/text-component/text-component.js +291 -291
  21. package/dist/collection/global/global.js +4 -4
  22. package/dist/collection/services/FormatJs.js +15 -15
  23. package/dist/collection/services/WidgetHost.js +426 -426
  24. package/dist/collection/utilities.js +81 -81
  25. package/dist/esm/{WidgetHost-a27e693d.js → WidgetHost-903fb7cc.js} +420 -420
  26. package/dist/esm/polyfills/core-js.js +0 -0
  27. package/dist/esm/polyfills/dom.js +0 -0
  28. package/dist/esm/polyfills/es5-html-element.js +0 -0
  29. package/dist/esm/polyfills/index.js +0 -0
  30. package/dist/esm/polyfills/system.js +0 -0
  31. package/dist/esm/sqh-close-button.entry.js +25 -25
  32. package/dist/esm/sqh-copy-button_12.entry.js +870 -971
  33. package/dist/esm/sqh-referral-code.entry.js +22 -22
  34. package/dist/esm/sqh-rewards-actions.entry.js +26 -26
  35. package/dist/esm-es5/{WidgetHost-a27e693d.js → WidgetHost-903fb7cc.js} +9432 -9432
  36. package/dist/esm-es5/_commonjsHelpers-1d681858.js +17 -17
  37. package/dist/esm-es5/css-shim-a659079f.js +122 -122
  38. package/dist/esm-es5/dom-4061ceba.js +468 -468
  39. package/dist/esm-es5/en-be593af0.js +1471 -1471
  40. package/dist/esm-es5/index-8ea8b6d8.js +1758 -1758
  41. package/dist/esm-es5/loader.mjs +11 -11
  42. package/dist/esm-es5/sqh-close-button.entry.js +35 -35
  43. package/dist/esm-es5/sqh-copy-button_12.entry.js +9535 -9624
  44. package/dist/esm-es5/sqh-referral-code.entry.js +29 -29
  45. package/dist/esm-es5/sqh-rewards-actions.entry.js +31 -31
  46. package/dist/esm-es5/widget-components.mjs +6 -6
  47. package/dist/types/components/close-button/close-button.d.ts +16 -16
  48. package/dist/types/components/copy-button/copy-button.d.ts +90 -90
  49. package/dist/types/components/copy-link-button/copy-link-button.d.ts +53 -53
  50. package/dist/types/components/global-container/global-container.d.ts +39 -39
  51. package/dist/types/components/image-component/image-component.d.ts +45 -45
  52. package/dist/types/components/partner-stat-component/partner-stat-component.d.ts +51 -51
  53. package/dist/types/components/referral-code/referral-code.d.ts +12 -12
  54. package/dist/types/components/referral-component/referral-component.d.ts +46 -46
  55. package/dist/types/components/referral-list/referral-list.d.ts +234 -234
  56. package/dist/types/components/rewards-actions/rewards-actions.d.ts +25 -25
  57. package/dist/types/components/share-button/share-button.d.ts +77 -77
  58. package/dist/types/components/share-button-container/share-button-container.d.ts +593 -593
  59. package/dist/types/components/stat-component/stat-component.d.ts +48 -48
  60. package/dist/types/components/stats-container/stats-container.d.ts +47 -47
  61. package/dist/types/components/text-component/text-component.d.ts +74 -74
  62. package/dist/types/components.d.ts +4 -4
  63. package/dist/types/global/global.d.ts +4 -4
  64. package/dist/types/services/FormatJs.d.ts +7 -7
  65. package/dist/types/services/WidgetHost.d.ts +45 -45
  66. package/dist/types/utilities.d.ts +7 -7
  67. package/dist/widget-components/{p-650d012d.entry.js → p-131a5c4a.entry.js} +1 -1
  68. package/dist/widget-components/p-1b8f2cfc.system.entry.js +8 -0
  69. package/dist/widget-components/p-24fc4ba9.js +1 -1
  70. package/dist/widget-components/p-46109683.js +3 -3
  71. package/dist/widget-components/{p-d4b27c72.entry.js → p-50ae8f2b.entry.js} +1 -1
  72. package/dist/widget-components/p-58be1132.system.js +1 -1
  73. package/dist/widget-components/{p-0bfec452.entry.js → p-8baa34a0.entry.js} +16 -16
  74. package/dist/widget-components/{p-c0cdba77.system.entry.js → p-b9fcb846.system.entry.js} +1 -1
  75. package/dist/widget-components/p-da180bcd.system.entry.js +1 -0
  76. package/dist/widget-components/{p-9adc7c50.system.js → p-e692beaf.system.js} +0 -0
  77. package/dist/widget-components/{p-9525bf4a.js → p-ffeb02d1.js} +0 -0
  78. package/dist/widget-components/widget-components.esm.js +1 -1
  79. package/dist/widget-components/widget-components.js +1 -1
  80. package/docs/raisins.json +1 -1
  81. package/package.json +1 -1
  82. package/CHANGELOG.md +0 -163
  83. package/dist/widget-components/p-796dc228.system.entry.js +0 -8
  84. package/dist/widget-components/p-908068c2.system.entry.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,51 +506,51 @@ const API = {
506
506
  rewardBalancesGlobal: rewardBalances
507
507
  }
508
508
  }
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({
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({
526
526
  query: gql `
527
527
  query ($userId: String!, $accountId: String!, $programId: ID!) {
528
528
  user(id: $userId, accountId: $accountId) {
529
529
  referralCode(programId: $programId)
530
530
  }
531
531
  }
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({
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({
554
554
  query: gql `
555
555
  query (
556
556
  $userId: String!
@@ -578,24 +578,24 @@ const API = {
578
578
  }
579
579
  }
580
580
  }
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({
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({
599
599
  query: gql `
600
600
  query($userId: String!, $accountId: String!, $programId: ID, $engagementMedium: UserEngagementMedium!) {
601
601
  user(id: $userId, accountId: $accountId) {
@@ -610,12 +610,12 @@ const API = {
610
610
  ${mediums[8]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[8]})
611
611
  }
612
612
  }
613
- `,
614
- variables,
615
- })
616
- .then((res) => res.data.user);
617
- },
618
- },
619
- ui: squatchJsApi,
620
- };
621
- export { API };
613
+ `,
614
+ variables,
615
+ })
616
+ .then((res) => res.data.user);
617
+ },
618
+ },
619
+ ui: squatchJsApi,
620
+ };
621
+ export { API };