@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.
Files changed (109) hide show
  1. package/dist/cjs/{WidgetHost-cee741d8.js → WidgetHost-fce29ef5.js} +420 -577
  2. package/dist/cjs/{en-3a7cb52e.js → en-a49a5ef5.js} +2 -2
  3. package/dist/cjs/{index-09a04159.js → index-deb40352.js} +3 -54
  4. package/dist/cjs/loader.cjs.js +3 -3
  5. package/dist/cjs/sqh-close-button.cjs.entry.js +26 -26
  6. package/dist/cjs/{sqh-copy-button_14.cjs.entry.js → sqh-copy-button_12.cjs.entry.js} +976 -2246
  7. package/dist/cjs/sqh-referral-code.cjs.entry.js +23 -23
  8. package/dist/cjs/sqh-rewards-actions.cjs.entry.js +27 -27
  9. package/dist/cjs/widget-components.cjs.js +3 -3
  10. package/dist/collection/collection-manifest.json +0 -2
  11. package/dist/collection/components/close-button/close-button.js +68 -70
  12. package/dist/collection/components/copy-button/copy-button.js +358 -367
  13. package/dist/collection/components/copy-link-button/copy-link-button.js +215 -221
  14. package/dist/collection/components/global-container/global-container.js +151 -165
  15. package/dist/collection/components/image-component/image-component.js +165 -168
  16. package/dist/collection/components/partner-stat-component/partner-stat-component.js +194 -197
  17. package/dist/collection/components/referral-code/referral-code.js +36 -36
  18. package/dist/collection/components/referral-component/referral-component.js +255 -255
  19. package/dist/collection/components/referral-list/referral-list.js +860 -884
  20. package/dist/collection/components/rewards-actions/rewards-actions.js +105 -105
  21. package/dist/collection/components/share-button/share-button.js +282 -291
  22. package/dist/collection/components/share-button-container/share-button-container.js +2384 -2439
  23. package/dist/collection/components/stat-component/stat-component.js +194 -198
  24. package/dist/collection/components/stats-container/stats-container.js +206 -206
  25. package/dist/collection/components/text-component/text-component.js +294 -294
  26. package/dist/collection/entrypoint.js +19 -17
  27. package/dist/collection/global/global.js +4 -4
  28. package/dist/collection/services/FormatJs.js +15 -15
  29. package/dist/collection/services/WidgetHost.js +426 -583
  30. package/dist/collection/utilities.js +81 -81
  31. package/dist/esm/{WidgetHost-6cd6c29a.js → WidgetHost-903fb7cc.js} +420 -577
  32. package/dist/esm/{en-a652ab83.js → en-be593af0.js} +1 -1
  33. package/dist/esm/{index-342d7c26.js → index-8ea8b6d8.js} +3 -54
  34. package/dist/esm/loader.mjs +3 -3
  35. package/dist/esm/polyfills/core-js.js +0 -0
  36. package/dist/esm/polyfills/dom.js +0 -0
  37. package/dist/esm/polyfills/es5-html-element.js +0 -0
  38. package/dist/esm/polyfills/index.js +0 -0
  39. package/dist/esm/polyfills/system.js +0 -0
  40. package/dist/esm/sqh-close-button.entry.js +26 -26
  41. package/dist/esm/{sqh-copy-button_14.entry.js → sqh-copy-button_12.entry.js} +977 -2245
  42. package/dist/esm/sqh-referral-code.entry.js +23 -23
  43. package/dist/esm/sqh-rewards-actions.entry.js +27 -27
  44. package/dist/esm/widget-components.mjs +3 -3
  45. package/dist/esm-es5/{WidgetHost-6cd6c29a.js → WidgetHost-903fb7cc.js} +9432 -9524
  46. package/dist/esm-es5/_commonjsHelpers-1d681858.js +17 -17
  47. package/dist/esm-es5/css-shim-a659079f.js +122 -122
  48. package/dist/esm-es5/dom-4061ceba.js +468 -468
  49. package/dist/esm-es5/{en-a652ab83.js → en-be593af0.js} +1471 -1471
  50. package/dist/esm-es5/{index-342d7c26.js → index-8ea8b6d8.js} +1758 -1808
  51. package/dist/esm-es5/loader.mjs +11 -11
  52. package/dist/esm-es5/sqh-close-button.entry.js +35 -35
  53. package/dist/esm-es5/{sqh-copy-button_14.entry.js → sqh-copy-button_12.entry.js} +9535 -10669
  54. package/dist/esm-es5/sqh-referral-code.entry.js +29 -29
  55. package/dist/esm-es5/sqh-rewards-actions.entry.js +31 -31
  56. package/dist/esm-es5/widget-components.mjs +6 -6
  57. package/dist/types/components/close-button/close-button.d.ts +16 -18
  58. package/dist/types/components/copy-button/copy-button.d.ts +90 -93
  59. package/dist/types/components/copy-link-button/copy-link-button.d.ts +53 -55
  60. package/dist/types/components/global-container/global-container.d.ts +39 -43
  61. package/dist/types/components/image-component/image-component.d.ts +45 -46
  62. package/dist/types/components/partner-stat-component/partner-stat-component.d.ts +51 -52
  63. package/dist/types/components/referral-code/referral-code.d.ts +12 -12
  64. package/dist/types/components/referral-component/referral-component.d.ts +46 -46
  65. package/dist/types/components/referral-list/referral-list.d.ts +234 -242
  66. package/dist/types/components/rewards-actions/rewards-actions.d.ts +25 -25
  67. package/dist/types/components/share-button/share-button.d.ts +77 -80
  68. package/dist/types/components/share-button-container/share-button-container.d.ts +593 -611
  69. package/dist/types/components/stat-component/stat-component.d.ts +48 -50
  70. package/dist/types/components/stats-container/stats-container.d.ts +47 -47
  71. package/dist/types/components/text-component/text-component.d.ts +74 -74
  72. package/dist/types/components.d.ts +218 -498
  73. package/dist/types/global/global.d.ts +4 -4
  74. package/dist/types/services/FormatJs.d.ts +7 -7
  75. package/dist/types/services/WidgetHost.d.ts +45 -51
  76. package/dist/types/utilities.d.ts +7 -7
  77. package/dist/widget-components/entrypoint.js +19 -17
  78. package/dist/widget-components/{p-1dfd20e2.entry.js → p-131a5c4a.entry.js} +1 -1
  79. package/dist/widget-components/p-1b8f2cfc.system.entry.js +8 -0
  80. package/dist/widget-components/p-24fc4ba9.js +1 -1
  81. package/dist/widget-components/{p-17d80384.js → p-44a6559d.js} +1 -1
  82. package/dist/widget-components/p-46109683.js +3 -3
  83. package/dist/widget-components/p-485eaf44.js +1 -0
  84. package/dist/widget-components/{p-9ffe6e46.entry.js → p-50ae8f2b.entry.js} +1 -1
  85. package/dist/widget-components/{p-e82def83.system.js → p-58be1132.system.js} +1 -1
  86. package/dist/widget-components/p-8baa34a0.entry.js +149 -0
  87. package/dist/widget-components/{p-fb528be6.entry.js → p-9746ae26.entry.js} +1 -1
  88. package/dist/widget-components/{p-aaf44379.system.js → p-a846f503.system.js} +1 -1
  89. package/dist/widget-components/{p-599e6d35.system.entry.js → p-b9fcb846.system.entry.js} +1 -1
  90. package/dist/widget-components/p-da180bcd.system.entry.js +1 -0
  91. package/dist/widget-components/{p-665b8d42.system.entry.js → p-e2b4739f.system.entry.js} +1 -1
  92. package/dist/widget-components/p-e61a8100.system.js +1 -0
  93. package/dist/widget-components/{p-b67d3319.system.js → p-e692beaf.system.js} +2 -2
  94. package/dist/widget-components/{p-4b1ab75c.js → p-ffeb02d1.js} +3 -68
  95. package/dist/widget-components/widget-components.esm.js +1 -1
  96. package/dist/widget-components/widget-components.js +1 -1
  97. package/docs/raisins.json +1 -1
  98. package/package.json +4 -4
  99. package/dist/collection/components/cta-component/cta-component.css +0 -6
  100. package/dist/collection/components/cta-component/cta-component.js +0 -396
  101. package/dist/collection/components/progress-indicator/progress-indicator.css +0 -73
  102. package/dist/collection/components/progress-indicator/progress-indicator.js +0 -493
  103. package/dist/types/components/cta-component/cta-component.d.ts +0 -86
  104. package/dist/types/components/progress-indicator/progress-indicator.d.ts +0 -42
  105. package/dist/widget-components/p-7d98ea96.entry.js +0 -233
  106. package/dist/widget-components/p-8ca0fd41.system.entry.js +0 -10
  107. package/dist/widget-components/p-ad5121cf.system.js +0 -1
  108. package/dist/widget-components/p-eeb2bfd4.system.entry.js +0 -1
  109. package/dist/widget-components/p-fbf0c7fe.js +0 -1
@@ -9910,293 +9910,293 @@ gql.disableExperimentalFragmentVariables = disableExperimentalFragmentVariables;
9910
9910
 
9911
9911
  var src = gql;
9912
9912
 
9913
- if (!window["widgetIdent"]) {
9914
- window["widgetIdent"] = {
9915
- env: "demo",
9916
- };
9917
- }
9918
- function widgetIdent() {
9919
- //@ts-ignore
9920
- return window.widgetIdent;
9921
- }
9922
- const today = new Date();
9923
- const demoUser = {
9924
- shareLink: "http://ssqt.co",
9925
- fueltankCode: "12AS3F",
9926
- referralcode: "RIDDIKULUS",
9927
- locale: "en_US",
9928
- messageLink: {
9929
- EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
9930
- FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
9931
- TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9932
- SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
9933
- WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
9934
- LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
9935
- PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
9936
- FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9937
- },
9938
- referrals: {
9939
- totalCount: 9,
9940
- data: [
9941
- {
9942
- dateReferralStarted: today.setDate(today.getDate() - 2),
9943
- referredUser: { firstName: "Remus", lastName: "Lupin" },
9944
- rewards: [
9945
- {
9946
- prettyValue: "$20.00",
9947
- dateExpires: today.setDate(today.getDate() + 4),
9948
- statuses: ["EXPIRED"],
9949
- meta: { message: "Applied to Invoice #1234" },
9950
- },
9951
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9952
- { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
9953
- ],
9954
- },
9955
- {
9956
- dateReferralStarted: today.setDate(today.getDate() - 1),
9957
- referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
9958
- rewards: [],
9959
- },
9960
- // Blank string becomes an unknown user, which is editable
9961
- {
9962
- dateReferralStarted: today.setDate(today.getDate() - 1),
9963
- referredUser: { firstName: "", lastName: "" },
9964
- rewards: [
9965
- {
9966
- prettyValue: "$20.00",
9967
- dateExpires: today.setDate(today.getDate() - 2),
9968
- statuses: ["EXPIRED"],
9969
- },
9970
- ],
9971
- },
9972
- {
9973
- dateReferralStarted: today.setDate(today.getDate() - 5),
9974
- referredUser: { firstName: "Lavender", lastName: "Brown" },
9975
- rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
9976
- },
9977
- {
9978
- dateReferralStarted: today.setDate(today.getDate() - 4),
9979
- referredUser: { firstName: "Blaise", lastName: "Zabini" },
9980
- rewards: [
9981
- { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9982
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9983
- ],
9984
- },
9985
- {
9986
- dateReferralStarted: today.setDate(today.getDate() - 10),
9987
- referredUser: { firstName: "Argus", lastName: "Filch" },
9988
- rewards: [],
9989
- },
9990
- {
9991
- dateReferralStarted: today.setDate(today.getDate() - 15),
9992
- referredUser: { firstName: "Ron", lastName: "Weasley" },
9993
- rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
9994
- },
9995
- {
9996
- dateReferralStarted: today.setDate(today.getDate() - 2),
9997
- referredUser: { firstName: "Hermione", lastName: "Granger" },
9998
- rewards: [
9999
- { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
10000
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
10001
- { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
10002
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10003
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10004
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10005
- ],
10006
- },
10007
- {
10008
- dateConverted: 1606943971468,
10009
- dateReferralStarted: 1606943971468,
10010
- referredUser: {
10011
- imageUrl: "",
10012
- firstName: "Seamus",
10013
- lastName: "Finnigan",
10014
- },
10015
- rewards: [],
10016
- },
10017
- ],
10018
- },
10019
- referredByReferral: {
10020
- dateReferralStarted: today.setDate(today.getDate() - 2),
10021
- referrerUser: {
10022
- firstName: "Rubeus",
10023
- lastName: "Hagrid",
10024
- referralCode: "RUBEUSHAGRID12",
10025
- },
10026
- rewards: [
10027
- {
10028
- fuelTankCode: "CODE1234",
10029
- prettyValue: "$10.00",
10030
- statuses: ["AVAILABLE"],
10031
- },
10032
- ],
10033
- },
10034
- referralsMonth: { totalCount: 6 },
10035
- referralsWeek: { totalCount: 3 },
10036
- rewardsCount: { totalCount: 14 },
10037
- rewardsMonth: { totalCount: 7 },
10038
- rewardsWeek: { totalCount: 4 },
10039
- rewardBalancesGlobal: [
10040
- {
10041
- type: "CREDIT",
10042
- unit: "CENTS",
10043
- value: 17000,
10044
- prettyValue: "$170.00",
10045
- totalAssignedCredit: "17000",
10046
- totalRedeemedCredit: "1500",
10047
- prettyAssignedCredit: "$1000.00",
10048
- prettyRedeemedCredit: "$15.00",
10049
- },
10050
- { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10051
- {
10052
- type: "CREDIT",
10053
- unit: "CASH/CAD",
10054
- count: 3,
10055
- totalPendingCredit: 20000,
10056
- totalAssignedCredit: 30000,
10057
- totalRedeemedCredit: 10000,
10058
- totalExpiredCredit: 0,
10059
- totalCancelledCredit: 0,
10060
- prettyPendingCredit: "$200.00",
10061
- prettyAssignedCredit: "$300.00",
10062
- prettyRedeemedCredit: "$100.00",
10063
- value: 30000,
10064
- prettyValue: "$300.00",
10065
- },
10066
- {
10067
- type: "CREDIT",
10068
- unit: "CASH/USD",
10069
- count: 6,
10070
- totalPendingCredit: 25000,
10071
- totalAssignedCredit: 40000,
10072
- totalRedeemedCredit: 10000,
10073
- totalExpiredCredit: 15000,
10074
- totalCancelledCredit: 10000,
10075
- prettyPendingCredit: "USD250.00",
10076
- prettyAssignedCredit: "USD400.00",
10077
- prettyRedeemedCredit: "USD150.00",
10078
- value: 40000,
10079
- prettyValue: "USD400.00",
10080
- },
10081
- ],
10082
- rewardBalances: [
10083
- {
10084
- type: "CREDIT",
10085
- unit: "CENTS",
10086
- value: 17000,
10087
- prettyValue: "$170.00",
10088
- totalAssignedCredit: "17000",
10089
- totalRedeemedCredit: "1500",
10090
- prettyAssignedCredit: "$170.00",
10091
- prettyRedeemedCredit: "$15.00",
10092
- },
10093
- { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10094
- {
10095
- type: "CREDIT",
10096
- unit: "CASH/CAD",
10097
- count: 3,
10098
- totalPendingCredit: 20000,
10099
- totalAssignedCredit: 30000,
10100
- totalRedeemedCredit: 10000,
10101
- totalExpiredCredit: 0,
10102
- totalCancelledCredit: 0,
10103
- prettyPendingCredit: "$200.00",
10104
- prettyAssignedCredit: "$300.00",
10105
- prettyRedeemedCredit: "$100.00",
10106
- value: 30000,
10107
- prettyValue: "$300.00",
10108
- },
10109
- {
10110
- type: "CREDIT",
10111
- unit: "CASH/USD",
10112
- count: 6,
10113
- totalPendingCredit: 25000,
10114
- totalAssignedCredit: 40000,
10115
- totalRedeemedCredit: 10000,
10116
- totalExpiredCredit: 15000,
10117
- totalCancelledCredit: 10000,
10118
- prettyPendingCredit: "USD250.00",
10119
- prettyAssignedCredit: "USD400.00",
10120
- prettyRedeemedCredit: "USD150.00",
10121
- value: 40000,
10122
- prettyValue: "USD400.00",
10123
- },
10124
- ],
10125
- rewardBalanceDetails: [
10126
- {
10127
- prettyAvailableValue: "$5.00",
10128
- },
10129
- {
10130
- prettyAvailableValue: "18%",
10131
- },
10132
- ],
10133
- };
10134
- //@ts-ignore
10135
- const squatchJsApi = window.frameElement
10136
- ? window.frameElement.squatchJsApi
10137
- : {};
10138
- const apolloClient = () => {
10139
- const { tenantAlias, appDomain, token } = widgetIdent();
10140
- const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
10141
- const headers = {
10142
- Authorization: `Bearer ${token}`,
10143
- };
10144
- const client = new ApolloClient({
10145
- link: new HttpLink({ uri, headers }),
10146
- cache: new InMemoryCache(),
10147
- });
10148
- return client;
10149
- };
10150
- const API = {
10151
- version: "Welcome to widget-host",
10152
- analytics: {
10153
- shareEvent(shareMedium) {
10154
- const widgetId = widgetIdent();
10155
- if (widgetId["env"] === "demo" || !widgetId)
10156
- return Promise.resolve({});
10157
- const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
10158
- const variables = {
10159
- eventMeta: {
10160
- id: userId,
10161
- accountId,
10162
- programId,
10163
- type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
10164
- meta: {
10165
- engagementMedium,
10166
- shareMedium,
10167
- },
10168
- },
10169
- };
10170
- return apolloClient()
10171
- .mutate({
9913
+ if (!window["widgetIdent"]) {
9914
+ window["widgetIdent"] = {
9915
+ env: "demo",
9916
+ };
9917
+ }
9918
+ function widgetIdent() {
9919
+ //@ts-ignore
9920
+ return window.widgetIdent;
9921
+ }
9922
+ const today = new Date();
9923
+ const demoUser = {
9924
+ shareLink: "http://ssqt.co",
9925
+ fueltankCode: "12AS3F",
9926
+ referralcode: "RIDDIKULUS",
9927
+ locale: "en_US",
9928
+ messageLink: {
9929
+ EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
9930
+ FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
9931
+ TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9932
+ SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
9933
+ WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
9934
+ LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
9935
+ PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
9936
+ FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9937
+ },
9938
+ referrals: {
9939
+ totalCount: 9,
9940
+ data: [
9941
+ {
9942
+ dateReferralStarted: today.setDate(today.getDate() - 2),
9943
+ referredUser: { firstName: "Remus", lastName: "Lupin" },
9944
+ rewards: [
9945
+ {
9946
+ prettyValue: "$20.00",
9947
+ dateExpires: today.setDate(today.getDate() + 4),
9948
+ statuses: ["EXPIRED"],
9949
+ meta: { message: "Applied to Invoice #1234" },
9950
+ },
9951
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9952
+ { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
9953
+ ],
9954
+ },
9955
+ {
9956
+ dateReferralStarted: today.setDate(today.getDate() - 1),
9957
+ referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
9958
+ rewards: [],
9959
+ },
9960
+ // Blank string becomes an unknown user, which is editable
9961
+ {
9962
+ dateReferralStarted: today.setDate(today.getDate() - 1),
9963
+ referredUser: { firstName: "", lastName: "" },
9964
+ rewards: [
9965
+ {
9966
+ prettyValue: "$20.00",
9967
+ dateExpires: today.setDate(today.getDate() - 2),
9968
+ statuses: ["EXPIRED"],
9969
+ },
9970
+ ],
9971
+ },
9972
+ {
9973
+ dateReferralStarted: today.setDate(today.getDate() - 5),
9974
+ referredUser: { firstName: "Lavender", lastName: "Brown" },
9975
+ rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
9976
+ },
9977
+ {
9978
+ dateReferralStarted: today.setDate(today.getDate() - 4),
9979
+ referredUser: { firstName: "Blaise", lastName: "Zabini" },
9980
+ rewards: [
9981
+ { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9982
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9983
+ ],
9984
+ },
9985
+ {
9986
+ dateReferralStarted: today.setDate(today.getDate() - 10),
9987
+ referredUser: { firstName: "Argus", lastName: "Filch" },
9988
+ rewards: [],
9989
+ },
9990
+ {
9991
+ dateReferralStarted: today.setDate(today.getDate() - 15),
9992
+ referredUser: { firstName: "Ron", lastName: "Weasley" },
9993
+ rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
9994
+ },
9995
+ {
9996
+ dateReferralStarted: today.setDate(today.getDate() - 2),
9997
+ referredUser: { firstName: "Hermione", lastName: "Granger" },
9998
+ rewards: [
9999
+ { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
10000
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
10001
+ { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
10002
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10003
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10004
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10005
+ ],
10006
+ },
10007
+ {
10008
+ dateConverted: 1606943971468,
10009
+ dateReferralStarted: 1606943971468,
10010
+ referredUser: {
10011
+ imageUrl: "",
10012
+ firstName: "Seamus",
10013
+ lastName: "Finnigan",
10014
+ },
10015
+ rewards: [],
10016
+ },
10017
+ ],
10018
+ },
10019
+ referredByReferral: {
10020
+ dateReferralStarted: today.setDate(today.getDate() - 2),
10021
+ referrerUser: {
10022
+ firstName: "Rubeus",
10023
+ lastName: "Hagrid",
10024
+ referralCode: "RUBEUSHAGRID12",
10025
+ },
10026
+ rewards: [
10027
+ {
10028
+ fuelTankCode: "CODE1234",
10029
+ prettyValue: "$10.00",
10030
+ statuses: ["AVAILABLE"],
10031
+ },
10032
+ ],
10033
+ },
10034
+ referralsMonth: { totalCount: 6 },
10035
+ referralsWeek: { totalCount: 3 },
10036
+ rewardsCount: { totalCount: 14 },
10037
+ rewardsMonth: { totalCount: 7 },
10038
+ rewardsWeek: { totalCount: 4 },
10039
+ rewardBalancesGlobal: [
10040
+ {
10041
+ type: "CREDIT",
10042
+ unit: "CENTS",
10043
+ value: 17000,
10044
+ prettyValue: "$170.00",
10045
+ totalAssignedCredit: "17000",
10046
+ totalRedeemedCredit: "1500",
10047
+ prettyAssignedCredit: "$1000.00",
10048
+ prettyRedeemedCredit: "$15.00",
10049
+ },
10050
+ { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10051
+ {
10052
+ type: "CREDIT",
10053
+ unit: "CASH/CAD",
10054
+ count: 3,
10055
+ totalPendingCredit: 20000,
10056
+ totalAssignedCredit: 30000,
10057
+ totalRedeemedCredit: 10000,
10058
+ totalExpiredCredit: 0,
10059
+ totalCancelledCredit: 0,
10060
+ prettyPendingCredit: "$200.00",
10061
+ prettyAssignedCredit: "$300.00",
10062
+ prettyRedeemedCredit: "$100.00",
10063
+ value: 30000,
10064
+ prettyValue: "$300.00",
10065
+ },
10066
+ {
10067
+ type: "CREDIT",
10068
+ unit: "CASH/USD",
10069
+ count: 6,
10070
+ totalPendingCredit: 25000,
10071
+ totalAssignedCredit: 40000,
10072
+ totalRedeemedCredit: 10000,
10073
+ totalExpiredCredit: 15000,
10074
+ totalCancelledCredit: 10000,
10075
+ prettyPendingCredit: "USD250.00",
10076
+ prettyAssignedCredit: "USD400.00",
10077
+ prettyRedeemedCredit: "USD150.00",
10078
+ value: 40000,
10079
+ prettyValue: "USD400.00",
10080
+ },
10081
+ ],
10082
+ rewardBalances: [
10083
+ {
10084
+ type: "CREDIT",
10085
+ unit: "CENTS",
10086
+ value: 17000,
10087
+ prettyValue: "$170.00",
10088
+ totalAssignedCredit: "17000",
10089
+ totalRedeemedCredit: "1500",
10090
+ prettyAssignedCredit: "$170.00",
10091
+ prettyRedeemedCredit: "$15.00",
10092
+ },
10093
+ { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10094
+ {
10095
+ type: "CREDIT",
10096
+ unit: "CASH/CAD",
10097
+ count: 3,
10098
+ totalPendingCredit: 20000,
10099
+ totalAssignedCredit: 30000,
10100
+ totalRedeemedCredit: 10000,
10101
+ totalExpiredCredit: 0,
10102
+ totalCancelledCredit: 0,
10103
+ prettyPendingCredit: "$200.00",
10104
+ prettyAssignedCredit: "$300.00",
10105
+ prettyRedeemedCredit: "$100.00",
10106
+ value: 30000,
10107
+ prettyValue: "$300.00",
10108
+ },
10109
+ {
10110
+ type: "CREDIT",
10111
+ unit: "CASH/USD",
10112
+ count: 6,
10113
+ totalPendingCredit: 25000,
10114
+ totalAssignedCredit: 40000,
10115
+ totalRedeemedCredit: 10000,
10116
+ totalExpiredCredit: 15000,
10117
+ totalCancelledCredit: 10000,
10118
+ prettyPendingCredit: "USD250.00",
10119
+ prettyAssignedCredit: "USD400.00",
10120
+ prettyRedeemedCredit: "USD150.00",
10121
+ value: 40000,
10122
+ prettyValue: "USD400.00",
10123
+ },
10124
+ ],
10125
+ rewardBalanceDetails: [
10126
+ {
10127
+ prettyAvailableValue: "$5.00",
10128
+ },
10129
+ {
10130
+ prettyAvailableValue: "18%",
10131
+ },
10132
+ ],
10133
+ };
10134
+ //@ts-ignore
10135
+ const squatchJsApi = window.frameElement
10136
+ ? window.frameElement.squatchJsApi
10137
+ : {};
10138
+ const apolloClient = () => {
10139
+ const { tenantAlias, appDomain, token } = widgetIdent();
10140
+ const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
10141
+ const headers = {
10142
+ Authorization: `Bearer ${token}`,
10143
+ };
10144
+ const client = new ApolloClient({
10145
+ link: new HttpLink({ uri, headers }),
10146
+ cache: new InMemoryCache(),
10147
+ });
10148
+ return client;
10149
+ };
10150
+ const API = {
10151
+ version: "Welcome to widget-host",
10152
+ analytics: {
10153
+ shareEvent(shareMedium) {
10154
+ const widgetId = widgetIdent();
10155
+ if (widgetId["env"] === "demo" || !widgetId)
10156
+ return Promise.resolve({});
10157
+ const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
10158
+ const variables = {
10159
+ eventMeta: {
10160
+ id: userId,
10161
+ accountId,
10162
+ programId,
10163
+ type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
10164
+ meta: {
10165
+ engagementMedium,
10166
+ shareMedium,
10167
+ },
10168
+ },
10169
+ };
10170
+ return apolloClient()
10171
+ .mutate({
10172
10172
  mutation: src `
10173
10173
  mutation ($eventMeta: UserAnalyticsEvent!) {
10174
10174
  createUserAnalyticsEvent(eventMeta: $eventMeta)
10175
10175
  }
10176
- `,
10177
- variables,
10178
- })
10179
- .then((result) => {
10180
- return result.data.createUserAnalyticsEvent;
10181
- });
10182
- },
10183
- loadEvent() {
10184
- return Promise.resolve({ event: "loadEvent" });
10185
- },
10186
- },
10187
- graphql: {
10188
- getClient() {
10189
- return apolloClient();
10190
- },
10191
- getUserFragment(userFragment, fragmentVariables) {
10176
+ `,
10177
+ variables,
10178
+ })
10179
+ .then((result) => {
10180
+ return result.data.createUserAnalyticsEvent;
10181
+ });
10182
+ },
10183
+ loadEvent() {
10184
+ return Promise.resolve({ event: "loadEvent" });
10185
+ },
10186
+ },
10187
+ graphql: {
10188
+ getClient() {
10189
+ return apolloClient();
10190
+ },
10191
+ getUserFragment(userFragment, fragmentVariables) {
10192
10192
  const fragment = src `
10193
10193
  fragment UserFragment on User {
10194
10194
  ${userFragment}
10195
- }`;
10196
- const { userId, accountId } = widgetIdent();
10197
- const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
10198
- accountId });
10199
- return this.getClient().query({
10195
+ }`;
10196
+ const { userId, accountId } = widgetIdent();
10197
+ const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
10198
+ accountId });
10199
+ return this.getClient().query({
10200
10200
  query: src `
10201
10201
  query ($userId: String!, $accountId: String!, $offset: Int) {
10202
10202
  user(id: $userId, accountId: $accountId) {
@@ -10204,23 +10204,23 @@ const API = {
10204
10204
  }
10205
10205
  }
10206
10206
  ${fragment}
10207
- `,
10208
- variables,
10209
- });
10210
- },
10211
- getShareLink() {
10212
- const widgetId = widgetIdent();
10213
- if (widgetId["env"] === "demo" || !widgetId)
10214
- return Promise.resolve(demoUser.shareLink);
10215
- const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10216
- const variables = {
10217
- userId,
10218
- accountId,
10219
- programId,
10220
- engagementMedium,
10221
- };
10222
- return this.getClient()
10223
- .query({
10207
+ `,
10208
+ variables,
10209
+ });
10210
+ },
10211
+ getShareLink() {
10212
+ const widgetId = widgetIdent();
10213
+ if (widgetId["env"] === "demo" || !widgetId)
10214
+ return Promise.resolve(demoUser.shareLink);
10215
+ const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10216
+ const variables = {
10217
+ userId,
10218
+ accountId,
10219
+ programId,
10220
+ engagementMedium,
10221
+ };
10222
+ return this.getClient()
10223
+ .query({
10224
10224
  query: src `
10225
10225
  query (
10226
10226
  $userId: String!
@@ -10237,33 +10237,33 @@ const API = {
10237
10237
  )
10238
10238
  }
10239
10239
  }
10240
- `,
10241
- variables,
10242
- })
10243
- .then((res) => res.data.user.shareLink);
10244
- },
10245
- getReferrals(showReferrer, offset = 0, limit = 3) {
10246
- const widgetId = widgetIdent();
10247
- if (widgetId["env"] === "demo" || !widgetId) {
10248
- const { referrals: refs, referredByReferral, locale } = demoUser;
10249
- const referrals = {
10250
- totalCount: refs.totalCount,
10251
- data: refs.data.slice(offset, offset + limit),
10252
- };
10253
- const user = { referrals, referredByReferral, locale };
10254
- return Promise.resolve(user);
10255
- }
10256
- const { userId, accountId, programId = null } = widgetId;
10257
- const variables = {
10258
- limit,
10259
- offset,
10260
- userId,
10261
- accountId,
10262
- programId,
10263
- programId_exists: programId ? true : false,
10264
- };
10265
- return this.getClient()
10266
- .query({
10240
+ `,
10241
+ variables,
10242
+ })
10243
+ .then((res) => res.data.user.shareLink);
10244
+ },
10245
+ getReferrals(showReferrer, offset = 0, limit = 3) {
10246
+ const widgetId = widgetIdent();
10247
+ if (widgetId["env"] === "demo" || !widgetId) {
10248
+ const { referrals: refs, referredByReferral, locale } = demoUser;
10249
+ const referrals = {
10250
+ totalCount: refs.totalCount,
10251
+ data: refs.data.slice(offset, offset + limit),
10252
+ };
10253
+ const user = { referrals, referredByReferral, locale };
10254
+ return Promise.resolve(user);
10255
+ }
10256
+ const { userId, accountId, programId = null } = widgetId;
10257
+ const variables = {
10258
+ limit,
10259
+ offset,
10260
+ userId,
10261
+ accountId,
10262
+ programId,
10263
+ programId_exists: programId ? true : false,
10264
+ };
10265
+ return this.getClient()
10266
+ .query({
10267
10267
  query: src `
10268
10268
  query (
10269
10269
  $userId: String!
@@ -10303,7 +10303,7 @@ const API = {
10303
10303
  }
10304
10304
  }
10305
10305
  }
10306
- ${showReferrer
10306
+ ${showReferrer
10307
10307
  ? `referredByReferral(programId: $programId) {
10308
10308
  referrerUser {
10309
10309
  firstName
@@ -10316,40 +10316,40 @@ const API = {
10316
10316
  prettyValue
10317
10317
  statuses
10318
10318
  }
10319
- }`
10319
+ }`
10320
10320
  : ""}
10321
10321
  }
10322
10322
  }
10323
- `,
10324
- variables,
10325
- })
10326
- .then((res) => res.data.user);
10327
- },
10328
- getStats() {
10329
- const widgetId = widgetIdent();
10330
- if (widgetId["env"] === "demo" || !widgetId) {
10331
- const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
10332
- const user = {
10333
- referralsCount,
10334
- referralsMonth,
10335
- referralsWeek,
10336
- rewardsCount,
10337
- rewardsMonth,
10338
- rewardsWeek,
10339
- rewardBalances,
10340
- rewardBalancesGlobal,
10341
- };
10342
- return Promise.resolve(user);
10343
- }
10344
- const { userId, accountId, programId = null } = widgetId;
10345
- const variables = {
10346
- userId,
10347
- accountId,
10348
- programId,
10349
- programId_exists: programId ? true : false,
10350
- };
10351
- return this.getClient()
10352
- .query({
10323
+ `,
10324
+ variables,
10325
+ })
10326
+ .then((res) => res.data.user);
10327
+ },
10328
+ getStats() {
10329
+ const widgetId = widgetIdent();
10330
+ if (widgetId["env"] === "demo" || !widgetId) {
10331
+ const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
10332
+ const user = {
10333
+ referralsCount,
10334
+ referralsMonth,
10335
+ referralsWeek,
10336
+ rewardsCount,
10337
+ rewardsMonth,
10338
+ rewardsWeek,
10339
+ rewardBalances,
10340
+ rewardBalancesGlobal,
10341
+ };
10342
+ return Promise.resolve(user);
10343
+ }
10344
+ const { userId, accountId, programId = null } = widgetId;
10345
+ const variables = {
10346
+ userId,
10347
+ accountId,
10348
+ programId,
10349
+ programId_exists: programId ? true : false,
10350
+ };
10351
+ return this.getClient()
10352
+ .query({
10353
10353
  query: src `
10354
10354
  query (
10355
10355
  $userId: String!
@@ -10414,137 +10414,51 @@ const API = {
10414
10414
  rewardBalancesGlobal: rewardBalances
10415
10415
  }
10416
10416
  }
10417
- `,
10418
- variables,
10419
- })
10420
- .then((res) => res.data.user);
10421
- },
10422
- getBalanceDetails() {
10423
- const widgetId = widgetIdent();
10424
- if (widgetId["env"] === "demo" || !widgetId) {
10425
- const { rewardBalanceDetails } = demoUser;
10426
- const user = {
10427
- rewardBalanceDetails
10428
- };
10429
- return Promise.resolve(user);
10430
- }
10431
- const { userId, accountId, programId = null, locale } = widgetId;
10432
- const variables = {
10433
- userId,
10434
- accountId,
10435
- programId,
10436
- locale
10437
- };
10438
- return this.getClient().query({
10439
- query: src `
10440
- query(
10441
- $userId: String!,
10442
- $accountId: String!,
10443
- $programId: ID,
10444
- $locale: String!
10445
- ) {
10446
- user(id: $userId, accountId: $accountId) {
10447
- rewardBalanceDetails(programId: $programId) {
10448
- prettyAvailableValue
10449
- unit
10450
- ... on CreditRewardBalance {
10451
- prettyAssignedCredit
10452
- prettyRedeemedCredit
10453
- rewardUnit {
10454
- currency {
10455
- displayName(locale: $locale)
10456
- symbol(locale: $locale)
10457
- currencyCode
10458
- }
10459
- }
10460
- }
10461
- }
10462
- }
10463
- }
10464
- `,
10465
- variables
10466
- }).then(res => res.data.user);
10467
- },
10468
- getRewardExpiries() {
10469
- const widgetId = widgetIdent();
10470
- if (widgetId["env"] === "demo" || !widgetId) {
10471
- const { rewardBalanceDetails } = demoUser;
10472
- const user = {
10473
- rewardBalanceDetails
10474
- };
10475
- return Promise.resolve(user);
10476
- }
10477
- const { userId, accountId, programId = null, locale } = widgetId;
10478
- const variables = {
10479
- userId,
10480
- accountId,
10481
- programId,
10482
- locale
10483
- };
10484
- return this.getClient().query({
10485
- query: src `
10486
- query(
10487
- $userId: String!,
10488
- $accountId: String!,
10489
- $programId: ID,
10490
- $locale: String!
10491
- ) {
10492
- user(id: $userId, accountId: $accountId) {
10493
- rewards(programId_eq: $programId) {
10494
- data {
10495
- dateCreated
10496
- dateScheduledFor
10497
- dateExpires
10498
- prettyValue
10499
- unit
10500
- }
10501
- }
10502
- }
10503
- }
10504
- `,
10505
- variables
10506
- }).then(res => res.data.user);
10507
- },
10508
- async getReferralCode() {
10509
- const widgetId = widgetIdent();
10510
- if (widgetId["env"] === "demo" || !widgetId)
10511
- return demoUser.referralcode;
10512
- const { userId, accountId, programId } = widgetId;
10513
- const variables = {
10514
- userId,
10515
- accountId,
10516
- programId,
10517
- };
10518
- return this.getClient()
10519
- .query({
10417
+ `,
10418
+ variables,
10419
+ })
10420
+ .then((res) => res.data.user);
10421
+ },
10422
+ async getReferralCode() {
10423
+ const widgetId = widgetIdent();
10424
+ if (widgetId["env"] === "demo" || !widgetId)
10425
+ return demoUser.referralcode;
10426
+ const { userId, accountId, programId } = widgetId;
10427
+ const variables = {
10428
+ userId,
10429
+ accountId,
10430
+ programId,
10431
+ };
10432
+ return this.getClient()
10433
+ .query({
10520
10434
  query: src `
10521
10435
  query ($userId: String!, $accountId: String!, $programId: ID!) {
10522
10436
  user(id: $userId, accountId: $accountId) {
10523
10437
  referralCode(programId: $programId)
10524
10438
  }
10525
10439
  }
10526
- `,
10527
- variables,
10528
- })
10529
- .then((res) => res.data.user.referralCode);
10530
- },
10531
- async getFueltankCode(rewardKey) {
10532
- const widgetId = widgetIdent();
10533
- if (widgetId["env"] === "demo" || !widgetId) {
10534
- return {
10535
- referredByReferral: demoUser.referredByReferral,
10536
- rewards: { data: demoUser.referredByReferral.rewards },
10537
- };
10538
- }
10539
- const { userId, accountId, programId } = widgetId;
10540
- const variables = {
10541
- userId,
10542
- accountId,
10543
- programId,
10544
- rewardKey,
10545
- };
10546
- return this.getClient()
10547
- .query({
10440
+ `,
10441
+ variables,
10442
+ })
10443
+ .then((res) => res.data.user.referralCode);
10444
+ },
10445
+ async getFueltankCode(rewardKey) {
10446
+ const widgetId = widgetIdent();
10447
+ if (widgetId["env"] === "demo" || !widgetId) {
10448
+ return {
10449
+ referredByReferral: demoUser.referredByReferral,
10450
+ rewards: { data: demoUser.referredByReferral.rewards },
10451
+ };
10452
+ }
10453
+ const { userId, accountId, programId } = widgetId;
10454
+ const variables = {
10455
+ userId,
10456
+ accountId,
10457
+ programId,
10458
+ rewardKey,
10459
+ };
10460
+ return this.getClient()
10461
+ .query({
10548
10462
  query: src `
10549
10463
  query (
10550
10464
  $userId: String!
@@ -10572,24 +10486,24 @@ const API = {
10572
10486
  }
10573
10487
  }
10574
10488
  }
10575
- `,
10576
- variables,
10577
- })
10578
- .then((res) => res.data.user);
10579
- },
10580
- getMessageLinks(mediums) {
10581
- const widgetId = widgetIdent();
10582
- if (widgetId["env"] === "demo" || !widgetId)
10583
- return Promise.resolve(demoUser.messageLink);
10584
- const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10585
- const variables = {
10586
- userId,
10587
- accountId,
10588
- programId,
10589
- engagementMedium,
10590
- };
10591
- return this.getClient()
10592
- .query({
10489
+ `,
10490
+ variables,
10491
+ })
10492
+ .then((res) => res.data.user);
10493
+ },
10494
+ getMessageLinks(mediums) {
10495
+ const widgetId = widgetIdent();
10496
+ if (widgetId["env"] === "demo" || !widgetId)
10497
+ return Promise.resolve(demoUser.messageLink);
10498
+ const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10499
+ const variables = {
10500
+ userId,
10501
+ accountId,
10502
+ programId,
10503
+ engagementMedium,
10504
+ };
10505
+ return this.getClient()
10506
+ .query({
10593
10507
  query: src `
10594
10508
  query($userId: String!, $accountId: String!, $programId: ID, $engagementMedium: UserEngagementMedium!) {
10595
10509
  user(id: $userId, accountId: $accountId) {
@@ -10604,84 +10518,13 @@ const API = {
10604
10518
  ${mediums[8]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[8]})
10605
10519
  }
10606
10520
  }
10607
- `,
10608
- variables,
10609
- })
10610
- .then((res) => res.data.user);
10611
- },
10612
- getUserProgress() {
10613
- const widgetId = widgetIdent();
10614
- if (widgetId["env"] === "demo" || !widgetId) {
10615
- const demoData = {
10616
- customFields: { demo_totalValue: 16 },
10617
- rewardBalanceDetails: [{
10618
- prettyAvailableValue: "$10.00"
10619
- }],
10620
- rewards: { count: 1 }
10621
- };
10622
- return Promise.resolve(demoData);
10623
- }
10624
- const { userId, accountId, programId } = widgetId;
10625
- const variables = {
10626
- userId,
10627
- accountId,
10628
- programId,
10629
- };
10630
- return this.getClient().query({
10631
- query: src `
10632
- query($userId: String!, $accountId: String!, $programId: ID) {
10633
- user(id: $userId, accountId: $accountId){
10634
- customFields
10635
- locale
10636
- rewardBalanceDetails(programId: $programId) {
10637
- prettyAvailableValue(formatType:UNIT_FORMATTED)
10638
- }
10639
- rewards(limit:1000,offset:0, filter:{programId_eq: $programId}){
10640
- count
10641
- }
10642
- }
10643
- }
10644
- `,
10645
- variables
10646
- }).then(res => res.data.user);
10647
- },
10648
- getProgramRules() {
10649
- const widgetId = widgetIdent();
10650
- if (widgetId["env"] === "demo" || !widgetId) {
10651
- const demoData = {
10652
- id: "demo",
10653
- name: "Demo Program",
10654
- rules: {
10655
- programWindow: "",
10656
- rewardRules: {
10657
- rewardRulesType: 1,
10658
- rewardGoal: 24,
10659
- isRecurring: 1,
10660
- defaultCurrency: "CAD"
10661
- }
10662
- }
10663
- };
10664
- return Promise.resolve(demoData);
10665
- }
10666
- const { programId } = widgetId;
10667
- const variables = {
10668
- programId
10669
- };
10670
- return this.getClient().query({
10671
- query: src `
10672
- query($programId: ID!) {
10673
- program(id:$programId){
10674
- id
10675
- name
10676
- rules
10677
- }
10678
- }
10679
- `,
10680
- variables
10681
- }).then(res => res.data.program);
10682
- },
10683
- },
10684
- ui: squatchJsApi,
10521
+ `,
10522
+ variables,
10523
+ })
10524
+ .then((res) => res.data.user);
10525
+ },
10526
+ },
10527
+ ui: squatchJsApi,
10685
10528
  };
10686
10529
 
10687
10530
  exports.API = API;