@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
@@ -9908,293 +9908,293 @@ gql.disableExperimentalFragmentVariables = disableExperimentalFragmentVariables;
9908
9908
 
9909
9909
  var src = gql;
9910
9910
 
9911
- if (!window["widgetIdent"]) {
9912
- window["widgetIdent"] = {
9913
- env: "demo",
9914
- };
9915
- }
9916
- function widgetIdent() {
9917
- //@ts-ignore
9918
- return window.widgetIdent;
9919
- }
9920
- const today = new Date();
9921
- const demoUser = {
9922
- shareLink: "http://ssqt.co",
9923
- fueltankCode: "12AS3F",
9924
- referralcode: "RIDDIKULUS",
9925
- locale: "en_US",
9926
- messageLink: {
9927
- EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
9928
- FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
9929
- TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9930
- SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
9931
- WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
9932
- LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
9933
- PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
9934
- FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9935
- },
9936
- referrals: {
9937
- totalCount: 9,
9938
- data: [
9939
- {
9940
- dateReferralStarted: today.setDate(today.getDate() - 2),
9941
- referredUser: { firstName: "Remus", lastName: "Lupin" },
9942
- rewards: [
9943
- {
9944
- prettyValue: "$20.00",
9945
- dateExpires: today.setDate(today.getDate() + 4),
9946
- statuses: ["EXPIRED"],
9947
- meta: { message: "Applied to Invoice #1234" },
9948
- },
9949
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9950
- { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
9951
- ],
9952
- },
9953
- {
9954
- dateReferralStarted: today.setDate(today.getDate() - 1),
9955
- referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
9956
- rewards: [],
9957
- },
9958
- // Blank string becomes an unknown user, which is editable
9959
- {
9960
- dateReferralStarted: today.setDate(today.getDate() - 1),
9961
- referredUser: { firstName: "", lastName: "" },
9962
- rewards: [
9963
- {
9964
- prettyValue: "$20.00",
9965
- dateExpires: today.setDate(today.getDate() - 2),
9966
- statuses: ["EXPIRED"],
9967
- },
9968
- ],
9969
- },
9970
- {
9971
- dateReferralStarted: today.setDate(today.getDate() - 5),
9972
- referredUser: { firstName: "Lavender", lastName: "Brown" },
9973
- rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
9974
- },
9975
- {
9976
- dateReferralStarted: today.setDate(today.getDate() - 4),
9977
- referredUser: { firstName: "Blaise", lastName: "Zabini" },
9978
- rewards: [
9979
- { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9980
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9981
- ],
9982
- },
9983
- {
9984
- dateReferralStarted: today.setDate(today.getDate() - 10),
9985
- referredUser: { firstName: "Argus", lastName: "Filch" },
9986
- rewards: [],
9987
- },
9988
- {
9989
- dateReferralStarted: today.setDate(today.getDate() - 15),
9990
- referredUser: { firstName: "Ron", lastName: "Weasley" },
9991
- rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
9992
- },
9993
- {
9994
- dateReferralStarted: today.setDate(today.getDate() - 2),
9995
- referredUser: { firstName: "Hermione", lastName: "Granger" },
9996
- rewards: [
9997
- { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9998
- { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9999
- { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
10000
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10001
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10002
- { prettyValue: "5%", statuses: ["AVAILABLE"] },
10003
- ],
10004
- },
10005
- {
10006
- dateConverted: 1606943971468,
10007
- dateReferralStarted: 1606943971468,
10008
- referredUser: {
10009
- imageUrl: "",
10010
- firstName: "Seamus",
10011
- lastName: "Finnigan",
10012
- },
10013
- rewards: [],
10014
- },
10015
- ],
10016
- },
10017
- referredByReferral: {
10018
- dateReferralStarted: today.setDate(today.getDate() - 2),
10019
- referrerUser: {
10020
- firstName: "Rubeus",
10021
- lastName: "Hagrid",
10022
- referralCode: "RUBEUSHAGRID12",
10023
- },
10024
- rewards: [
10025
- {
10026
- fuelTankCode: "CODE1234",
10027
- prettyValue: "$10.00",
10028
- statuses: ["AVAILABLE"],
10029
- },
10030
- ],
10031
- },
10032
- referralsMonth: { totalCount: 6 },
10033
- referralsWeek: { totalCount: 3 },
10034
- rewardsCount: { totalCount: 14 },
10035
- rewardsMonth: { totalCount: 7 },
10036
- rewardsWeek: { totalCount: 4 },
10037
- rewardBalancesGlobal: [
10038
- {
10039
- type: "CREDIT",
10040
- unit: "CENTS",
10041
- value: 17000,
10042
- prettyValue: "$170.00",
10043
- totalAssignedCredit: "17000",
10044
- totalRedeemedCredit: "1500",
10045
- prettyAssignedCredit: "$1000.00",
10046
- prettyRedeemedCredit: "$15.00",
10047
- },
10048
- { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10049
- {
10050
- type: "CREDIT",
10051
- unit: "CASH/CAD",
10052
- count: 3,
10053
- totalPendingCredit: 20000,
10054
- totalAssignedCredit: 30000,
10055
- totalRedeemedCredit: 10000,
10056
- totalExpiredCredit: 0,
10057
- totalCancelledCredit: 0,
10058
- prettyPendingCredit: "$200.00",
10059
- prettyAssignedCredit: "$300.00",
10060
- prettyRedeemedCredit: "$100.00",
10061
- value: 30000,
10062
- prettyValue: "$300.00",
10063
- },
10064
- {
10065
- type: "CREDIT",
10066
- unit: "CASH/USD",
10067
- count: 6,
10068
- totalPendingCredit: 25000,
10069
- totalAssignedCredit: 40000,
10070
- totalRedeemedCredit: 10000,
10071
- totalExpiredCredit: 15000,
10072
- totalCancelledCredit: 10000,
10073
- prettyPendingCredit: "USD250.00",
10074
- prettyAssignedCredit: "USD400.00",
10075
- prettyRedeemedCredit: "USD150.00",
10076
- value: 40000,
10077
- prettyValue: "USD400.00",
10078
- },
10079
- ],
10080
- rewardBalances: [
10081
- {
10082
- type: "CREDIT",
10083
- unit: "CENTS",
10084
- value: 17000,
10085
- prettyValue: "$170.00",
10086
- totalAssignedCredit: "17000",
10087
- totalRedeemedCredit: "1500",
10088
- prettyAssignedCredit: "$170.00",
10089
- prettyRedeemedCredit: "$15.00",
10090
- },
10091
- { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10092
- {
10093
- type: "CREDIT",
10094
- unit: "CASH/CAD",
10095
- count: 3,
10096
- totalPendingCredit: 20000,
10097
- totalAssignedCredit: 30000,
10098
- totalRedeemedCredit: 10000,
10099
- totalExpiredCredit: 0,
10100
- totalCancelledCredit: 0,
10101
- prettyPendingCredit: "$200.00",
10102
- prettyAssignedCredit: "$300.00",
10103
- prettyRedeemedCredit: "$100.00",
10104
- value: 30000,
10105
- prettyValue: "$300.00",
10106
- },
10107
- {
10108
- type: "CREDIT",
10109
- unit: "CASH/USD",
10110
- count: 6,
10111
- totalPendingCredit: 25000,
10112
- totalAssignedCredit: 40000,
10113
- totalRedeemedCredit: 10000,
10114
- totalExpiredCredit: 15000,
10115
- totalCancelledCredit: 10000,
10116
- prettyPendingCredit: "USD250.00",
10117
- prettyAssignedCredit: "USD400.00",
10118
- prettyRedeemedCredit: "USD150.00",
10119
- value: 40000,
10120
- prettyValue: "USD400.00",
10121
- },
10122
- ],
10123
- rewardBalanceDetails: [
10124
- {
10125
- prettyAvailableValue: "$5.00",
10126
- },
10127
- {
10128
- prettyAvailableValue: "18%",
10129
- },
10130
- ],
10131
- };
10132
- //@ts-ignore
10133
- const squatchJsApi = window.frameElement
10134
- ? window.frameElement.squatchJsApi
10135
- : {};
10136
- const apolloClient = () => {
10137
- const { tenantAlias, appDomain, token } = widgetIdent();
10138
- const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
10139
- const headers = {
10140
- Authorization: `Bearer ${token}`,
10141
- };
10142
- const client = new ApolloClient({
10143
- link: new HttpLink({ uri, headers }),
10144
- cache: new InMemoryCache(),
10145
- });
10146
- return client;
10147
- };
10148
- const API = {
10149
- version: "Welcome to widget-host",
10150
- analytics: {
10151
- shareEvent(shareMedium) {
10152
- const widgetId = widgetIdent();
10153
- if (widgetId["env"] === "demo" || !widgetId)
10154
- return Promise.resolve({});
10155
- const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
10156
- const variables = {
10157
- eventMeta: {
10158
- id: userId,
10159
- accountId,
10160
- programId,
10161
- type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
10162
- meta: {
10163
- engagementMedium,
10164
- shareMedium,
10165
- },
10166
- },
10167
- };
10168
- return apolloClient()
10169
- .mutate({
9911
+ if (!window["widgetIdent"]) {
9912
+ window["widgetIdent"] = {
9913
+ env: "demo",
9914
+ };
9915
+ }
9916
+ function widgetIdent() {
9917
+ //@ts-ignore
9918
+ return window.widgetIdent;
9919
+ }
9920
+ const today = new Date();
9921
+ const demoUser = {
9922
+ shareLink: "http://ssqt.co",
9923
+ fueltankCode: "12AS3F",
9924
+ referralcode: "RIDDIKULUS",
9925
+ locale: "en_US",
9926
+ messageLink: {
9927
+ EMAIL: "http://short.staging.referralsaasquatch.com/mJjFXu",
9928
+ FACEBOOK: "http://short.staging.referralsaasquatch.com/mwjFXu",
9929
+ TWITTER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9930
+ SMS: "http://short.staging.referralsaasquatch.com/mwjFXu",
9931
+ WHATSAPP: "http://short.staging.referralsaasquatch.com/mwjFXu",
9932
+ LINKEDIN: "http://short.staging.referralsaasquatch.com/mwjFXu",
9933
+ PINTEREST: "http://short.staging.referralsaasquatch.com/mwjFXu",
9934
+ FBMESSENGER: "http://short.staging.referralsaasquatch.com/mwjFXu",
9935
+ },
9936
+ referrals: {
9937
+ totalCount: 9,
9938
+ data: [
9939
+ {
9940
+ dateReferralStarted: today.setDate(today.getDate() - 2),
9941
+ referredUser: { firstName: "Remus", lastName: "Lupin" },
9942
+ rewards: [
9943
+ {
9944
+ prettyValue: "$20.00",
9945
+ dateExpires: today.setDate(today.getDate() + 4),
9946
+ statuses: ["EXPIRED"],
9947
+ meta: { message: "Applied to Invoice #1234" },
9948
+ },
9949
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9950
+ { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
9951
+ ],
9952
+ },
9953
+ {
9954
+ dateReferralStarted: today.setDate(today.getDate() - 1),
9955
+ referredUser: { firstName: "Gellert", lastName: "Grindelwald" },
9956
+ rewards: [],
9957
+ },
9958
+ // Blank string becomes an unknown user, which is editable
9959
+ {
9960
+ dateReferralStarted: today.setDate(today.getDate() - 1),
9961
+ referredUser: { firstName: "", lastName: "" },
9962
+ rewards: [
9963
+ {
9964
+ prettyValue: "$20.00",
9965
+ dateExpires: today.setDate(today.getDate() - 2),
9966
+ statuses: ["EXPIRED"],
9967
+ },
9968
+ ],
9969
+ },
9970
+ {
9971
+ dateReferralStarted: today.setDate(today.getDate() - 5),
9972
+ referredUser: { firstName: "Lavender", lastName: "Brown" },
9973
+ rewards: [{ prettyValue: "$20.00", statuses: ["CANCELLED"] }],
9974
+ },
9975
+ {
9976
+ dateReferralStarted: today.setDate(today.getDate() - 4),
9977
+ referredUser: { firstName: "Blaise", lastName: "Zabini" },
9978
+ rewards: [
9979
+ { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9980
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9981
+ ],
9982
+ },
9983
+ {
9984
+ dateReferralStarted: today.setDate(today.getDate() - 10),
9985
+ referredUser: { firstName: "Argus", lastName: "Filch" },
9986
+ rewards: [],
9987
+ },
9988
+ {
9989
+ dateReferralStarted: today.setDate(today.getDate() - 15),
9990
+ referredUser: { firstName: "Ron", lastName: "Weasley" },
9991
+ rewards: [{ prettyValue: "$20.00", statuses: ["AVAILABLE"] }],
9992
+ },
9993
+ {
9994
+ dateReferralStarted: today.setDate(today.getDate() - 2),
9995
+ referredUser: { firstName: "Hermione", lastName: "Granger" },
9996
+ rewards: [
9997
+ { prettyValue: "$20.00", statuses: ["AVAILABLE"] },
9998
+ { prettyValue: "$10.00", statuses: ["AVAILABLE"] },
9999
+ { prettyValue: "$5.00", statuses: ["AVAILABLE"] },
10000
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10001
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10002
+ { prettyValue: "5%", statuses: ["AVAILABLE"] },
10003
+ ],
10004
+ },
10005
+ {
10006
+ dateConverted: 1606943971468,
10007
+ dateReferralStarted: 1606943971468,
10008
+ referredUser: {
10009
+ imageUrl: "",
10010
+ firstName: "Seamus",
10011
+ lastName: "Finnigan",
10012
+ },
10013
+ rewards: [],
10014
+ },
10015
+ ],
10016
+ },
10017
+ referredByReferral: {
10018
+ dateReferralStarted: today.setDate(today.getDate() - 2),
10019
+ referrerUser: {
10020
+ firstName: "Rubeus",
10021
+ lastName: "Hagrid",
10022
+ referralCode: "RUBEUSHAGRID12",
10023
+ },
10024
+ rewards: [
10025
+ {
10026
+ fuelTankCode: "CODE1234",
10027
+ prettyValue: "$10.00",
10028
+ statuses: ["AVAILABLE"],
10029
+ },
10030
+ ],
10031
+ },
10032
+ referralsMonth: { totalCount: 6 },
10033
+ referralsWeek: { totalCount: 3 },
10034
+ rewardsCount: { totalCount: 14 },
10035
+ rewardsMonth: { totalCount: 7 },
10036
+ rewardsWeek: { totalCount: 4 },
10037
+ rewardBalancesGlobal: [
10038
+ {
10039
+ type: "CREDIT",
10040
+ unit: "CENTS",
10041
+ value: 17000,
10042
+ prettyValue: "$170.00",
10043
+ totalAssignedCredit: "17000",
10044
+ totalRedeemedCredit: "1500",
10045
+ prettyAssignedCredit: "$1000.00",
10046
+ prettyRedeemedCredit: "$15.00",
10047
+ },
10048
+ { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10049
+ {
10050
+ type: "CREDIT",
10051
+ unit: "CASH/CAD",
10052
+ count: 3,
10053
+ totalPendingCredit: 20000,
10054
+ totalAssignedCredit: 30000,
10055
+ totalRedeemedCredit: 10000,
10056
+ totalExpiredCredit: 0,
10057
+ totalCancelledCredit: 0,
10058
+ prettyPendingCredit: "$200.00",
10059
+ prettyAssignedCredit: "$300.00",
10060
+ prettyRedeemedCredit: "$100.00",
10061
+ value: 30000,
10062
+ prettyValue: "$300.00",
10063
+ },
10064
+ {
10065
+ type: "CREDIT",
10066
+ unit: "CASH/USD",
10067
+ count: 6,
10068
+ totalPendingCredit: 25000,
10069
+ totalAssignedCredit: 40000,
10070
+ totalRedeemedCredit: 10000,
10071
+ totalExpiredCredit: 15000,
10072
+ totalCancelledCredit: 10000,
10073
+ prettyPendingCredit: "USD250.00",
10074
+ prettyAssignedCredit: "USD400.00",
10075
+ prettyRedeemedCredit: "USD150.00",
10076
+ value: 40000,
10077
+ prettyValue: "USD400.00",
10078
+ },
10079
+ ],
10080
+ rewardBalances: [
10081
+ {
10082
+ type: "CREDIT",
10083
+ unit: "CENTS",
10084
+ value: 17000,
10085
+ prettyValue: "$170.00",
10086
+ totalAssignedCredit: "17000",
10087
+ totalRedeemedCredit: "1500",
10088
+ prettyAssignedCredit: "$170.00",
10089
+ prettyRedeemedCredit: "$15.00",
10090
+ },
10091
+ { type: "PCT_DISCOUNT", unit: "%", value: 15, prettyValue: "15%" },
10092
+ {
10093
+ type: "CREDIT",
10094
+ unit: "CASH/CAD",
10095
+ count: 3,
10096
+ totalPendingCredit: 20000,
10097
+ totalAssignedCredit: 30000,
10098
+ totalRedeemedCredit: 10000,
10099
+ totalExpiredCredit: 0,
10100
+ totalCancelledCredit: 0,
10101
+ prettyPendingCredit: "$200.00",
10102
+ prettyAssignedCredit: "$300.00",
10103
+ prettyRedeemedCredit: "$100.00",
10104
+ value: 30000,
10105
+ prettyValue: "$300.00",
10106
+ },
10107
+ {
10108
+ type: "CREDIT",
10109
+ unit: "CASH/USD",
10110
+ count: 6,
10111
+ totalPendingCredit: 25000,
10112
+ totalAssignedCredit: 40000,
10113
+ totalRedeemedCredit: 10000,
10114
+ totalExpiredCredit: 15000,
10115
+ totalCancelledCredit: 10000,
10116
+ prettyPendingCredit: "USD250.00",
10117
+ prettyAssignedCredit: "USD400.00",
10118
+ prettyRedeemedCredit: "USD150.00",
10119
+ value: 40000,
10120
+ prettyValue: "USD400.00",
10121
+ },
10122
+ ],
10123
+ rewardBalanceDetails: [
10124
+ {
10125
+ prettyAvailableValue: "$5.00",
10126
+ },
10127
+ {
10128
+ prettyAvailableValue: "18%",
10129
+ },
10130
+ ],
10131
+ };
10132
+ //@ts-ignore
10133
+ const squatchJsApi = window.frameElement
10134
+ ? window.frameElement.squatchJsApi
10135
+ : {};
10136
+ const apolloClient = () => {
10137
+ const { tenantAlias, appDomain, token } = widgetIdent();
10138
+ const uri = appDomain + "/api/v1/" + tenantAlias + "/graphql";
10139
+ const headers = {
10140
+ Authorization: `Bearer ${token}`,
10141
+ };
10142
+ const client = new ApolloClient({
10143
+ link: new HttpLink({ uri, headers }),
10144
+ cache: new InMemoryCache(),
10145
+ });
10146
+ return client;
10147
+ };
10148
+ const API = {
10149
+ version: "Welcome to widget-host",
10150
+ analytics: {
10151
+ shareEvent(shareMedium) {
10152
+ const widgetId = widgetIdent();
10153
+ if (widgetId["env"] === "demo" || !widgetId)
10154
+ return Promise.resolve({});
10155
+ const { userId, accountId, programId = "classic", engagementMedium, } = widgetId;
10156
+ const variables = {
10157
+ eventMeta: {
10158
+ id: userId,
10159
+ accountId,
10160
+ programId,
10161
+ type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
10162
+ meta: {
10163
+ engagementMedium,
10164
+ shareMedium,
10165
+ },
10166
+ },
10167
+ };
10168
+ return apolloClient()
10169
+ .mutate({
10170
10170
  mutation: src `
10171
10171
  mutation ($eventMeta: UserAnalyticsEvent!) {
10172
10172
  createUserAnalyticsEvent(eventMeta: $eventMeta)
10173
10173
  }
10174
- `,
10175
- variables,
10176
- })
10177
- .then((result) => {
10178
- return result.data.createUserAnalyticsEvent;
10179
- });
10180
- },
10181
- loadEvent() {
10182
- return Promise.resolve({ event: "loadEvent" });
10183
- },
10184
- },
10185
- graphql: {
10186
- getClient() {
10187
- return apolloClient();
10188
- },
10189
- getUserFragment(userFragment, fragmentVariables) {
10174
+ `,
10175
+ variables,
10176
+ })
10177
+ .then((result) => {
10178
+ return result.data.createUserAnalyticsEvent;
10179
+ });
10180
+ },
10181
+ loadEvent() {
10182
+ return Promise.resolve({ event: "loadEvent" });
10183
+ },
10184
+ },
10185
+ graphql: {
10186
+ getClient() {
10187
+ return apolloClient();
10188
+ },
10189
+ getUserFragment(userFragment, fragmentVariables) {
10190
10190
  const fragment = src `
10191
10191
  fragment UserFragment on User {
10192
10192
  ${userFragment}
10193
- }`;
10194
- const { userId, accountId } = widgetIdent();
10195
- const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
10196
- accountId });
10197
- return this.getClient().query({
10193
+ }`;
10194
+ const { userId, accountId } = widgetIdent();
10195
+ const variables = Object.assign(Object.assign({}, fragmentVariables), { userId,
10196
+ accountId });
10197
+ return this.getClient().query({
10198
10198
  query: src `
10199
10199
  query ($userId: String!, $accountId: String!, $offset: Int) {
10200
10200
  user(id: $userId, accountId: $accountId) {
@@ -10202,23 +10202,23 @@ const API = {
10202
10202
  }
10203
10203
  }
10204
10204
  ${fragment}
10205
- `,
10206
- variables,
10207
- });
10208
- },
10209
- getShareLink() {
10210
- const widgetId = widgetIdent();
10211
- if (widgetId["env"] === "demo" || !widgetId)
10212
- return Promise.resolve(demoUser.shareLink);
10213
- const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10214
- const variables = {
10215
- userId,
10216
- accountId,
10217
- programId,
10218
- engagementMedium,
10219
- };
10220
- return this.getClient()
10221
- .query({
10205
+ `,
10206
+ variables,
10207
+ });
10208
+ },
10209
+ getShareLink() {
10210
+ const widgetId = widgetIdent();
10211
+ if (widgetId["env"] === "demo" || !widgetId)
10212
+ return Promise.resolve(demoUser.shareLink);
10213
+ const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10214
+ const variables = {
10215
+ userId,
10216
+ accountId,
10217
+ programId,
10218
+ engagementMedium,
10219
+ };
10220
+ return this.getClient()
10221
+ .query({
10222
10222
  query: src `
10223
10223
  query (
10224
10224
  $userId: String!
@@ -10235,33 +10235,33 @@ const API = {
10235
10235
  )
10236
10236
  }
10237
10237
  }
10238
- `,
10239
- variables,
10240
- })
10241
- .then((res) => res.data.user.shareLink);
10242
- },
10243
- getReferrals(showReferrer, offset = 0, limit = 3) {
10244
- const widgetId = widgetIdent();
10245
- if (widgetId["env"] === "demo" || !widgetId) {
10246
- const { referrals: refs, referredByReferral, locale } = demoUser;
10247
- const referrals = {
10248
- totalCount: refs.totalCount,
10249
- data: refs.data.slice(offset, offset + limit),
10250
- };
10251
- const user = { referrals, referredByReferral, locale };
10252
- return Promise.resolve(user);
10253
- }
10254
- const { userId, accountId, programId = null } = widgetId;
10255
- const variables = {
10256
- limit,
10257
- offset,
10258
- userId,
10259
- accountId,
10260
- programId,
10261
- programId_exists: programId ? true : false,
10262
- };
10263
- return this.getClient()
10264
- .query({
10238
+ `,
10239
+ variables,
10240
+ })
10241
+ .then((res) => res.data.user.shareLink);
10242
+ },
10243
+ getReferrals(showReferrer, offset = 0, limit = 3) {
10244
+ const widgetId = widgetIdent();
10245
+ if (widgetId["env"] === "demo" || !widgetId) {
10246
+ const { referrals: refs, referredByReferral, locale } = demoUser;
10247
+ const referrals = {
10248
+ totalCount: refs.totalCount,
10249
+ data: refs.data.slice(offset, offset + limit),
10250
+ };
10251
+ const user = { referrals, referredByReferral, locale };
10252
+ return Promise.resolve(user);
10253
+ }
10254
+ const { userId, accountId, programId = null } = widgetId;
10255
+ const variables = {
10256
+ limit,
10257
+ offset,
10258
+ userId,
10259
+ accountId,
10260
+ programId,
10261
+ programId_exists: programId ? true : false,
10262
+ };
10263
+ return this.getClient()
10264
+ .query({
10265
10265
  query: src `
10266
10266
  query (
10267
10267
  $userId: String!
@@ -10301,7 +10301,7 @@ const API = {
10301
10301
  }
10302
10302
  }
10303
10303
  }
10304
- ${showReferrer
10304
+ ${showReferrer
10305
10305
  ? `referredByReferral(programId: $programId) {
10306
10306
  referrerUser {
10307
10307
  firstName
@@ -10314,40 +10314,40 @@ const API = {
10314
10314
  prettyValue
10315
10315
  statuses
10316
10316
  }
10317
- }`
10317
+ }`
10318
10318
  : ""}
10319
10319
  }
10320
10320
  }
10321
- `,
10322
- variables,
10323
- })
10324
- .then((res) => res.data.user);
10325
- },
10326
- getStats() {
10327
- const widgetId = widgetIdent();
10328
- if (widgetId["env"] === "demo" || !widgetId) {
10329
- const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
10330
- const user = {
10331
- referralsCount,
10332
- referralsMonth,
10333
- referralsWeek,
10334
- rewardsCount,
10335
- rewardsMonth,
10336
- rewardsWeek,
10337
- rewardBalances,
10338
- rewardBalancesGlobal,
10339
- };
10340
- return Promise.resolve(user);
10341
- }
10342
- const { userId, accountId, programId = null } = widgetId;
10343
- const variables = {
10344
- userId,
10345
- accountId,
10346
- programId,
10347
- programId_exists: programId ? true : false,
10348
- };
10349
- return this.getClient()
10350
- .query({
10321
+ `,
10322
+ variables,
10323
+ })
10324
+ .then((res) => res.data.user);
10325
+ },
10326
+ getStats() {
10327
+ const widgetId = widgetIdent();
10328
+ if (widgetId["env"] === "demo" || !widgetId) {
10329
+ const { referrals: referralsCount, referralsMonth, referralsWeek, rewardsCount, rewardsMonth, rewardsWeek, rewardBalances, rewardBalancesGlobal, } = demoUser;
10330
+ const user = {
10331
+ referralsCount,
10332
+ referralsMonth,
10333
+ referralsWeek,
10334
+ rewardsCount,
10335
+ rewardsMonth,
10336
+ rewardsWeek,
10337
+ rewardBalances,
10338
+ rewardBalancesGlobal,
10339
+ };
10340
+ return Promise.resolve(user);
10341
+ }
10342
+ const { userId, accountId, programId = null } = widgetId;
10343
+ const variables = {
10344
+ userId,
10345
+ accountId,
10346
+ programId,
10347
+ programId_exists: programId ? true : false,
10348
+ };
10349
+ return this.getClient()
10350
+ .query({
10351
10351
  query: src `
10352
10352
  query (
10353
10353
  $userId: String!
@@ -10412,137 +10412,51 @@ const API = {
10412
10412
  rewardBalancesGlobal: rewardBalances
10413
10413
  }
10414
10414
  }
10415
- `,
10416
- variables,
10417
- })
10418
- .then((res) => res.data.user);
10419
- },
10420
- getBalanceDetails() {
10421
- const widgetId = widgetIdent();
10422
- if (widgetId["env"] === "demo" || !widgetId) {
10423
- const { rewardBalanceDetails } = demoUser;
10424
- const user = {
10425
- rewardBalanceDetails
10426
- };
10427
- return Promise.resolve(user);
10428
- }
10429
- const { userId, accountId, programId = null, locale } = widgetId;
10430
- const variables = {
10431
- userId,
10432
- accountId,
10433
- programId,
10434
- locale
10435
- };
10436
- return this.getClient().query({
10437
- query: src `
10438
- query(
10439
- $userId: String!,
10440
- $accountId: String!,
10441
- $programId: ID,
10442
- $locale: String!
10443
- ) {
10444
- user(id: $userId, accountId: $accountId) {
10445
- rewardBalanceDetails(programId: $programId) {
10446
- prettyAvailableValue
10447
- unit
10448
- ... on CreditRewardBalance {
10449
- prettyAssignedCredit
10450
- prettyRedeemedCredit
10451
- rewardUnit {
10452
- currency {
10453
- displayName(locale: $locale)
10454
- symbol(locale: $locale)
10455
- currencyCode
10456
- }
10457
- }
10458
- }
10459
- }
10460
- }
10461
- }
10462
- `,
10463
- variables
10464
- }).then(res => res.data.user);
10465
- },
10466
- getRewardExpiries() {
10467
- const widgetId = widgetIdent();
10468
- if (widgetId["env"] === "demo" || !widgetId) {
10469
- const { rewardBalanceDetails } = demoUser;
10470
- const user = {
10471
- rewardBalanceDetails
10472
- };
10473
- return Promise.resolve(user);
10474
- }
10475
- const { userId, accountId, programId = null, locale } = widgetId;
10476
- const variables = {
10477
- userId,
10478
- accountId,
10479
- programId,
10480
- locale
10481
- };
10482
- return this.getClient().query({
10483
- query: src `
10484
- query(
10485
- $userId: String!,
10486
- $accountId: String!,
10487
- $programId: ID,
10488
- $locale: String!
10489
- ) {
10490
- user(id: $userId, accountId: $accountId) {
10491
- rewards(programId_eq: $programId) {
10492
- data {
10493
- dateCreated
10494
- dateScheduledFor
10495
- dateExpires
10496
- prettyValue
10497
- unit
10498
- }
10499
- }
10500
- }
10501
- }
10502
- `,
10503
- variables
10504
- }).then(res => res.data.user);
10505
- },
10506
- async getReferralCode() {
10507
- const widgetId = widgetIdent();
10508
- if (widgetId["env"] === "demo" || !widgetId)
10509
- return demoUser.referralcode;
10510
- const { userId, accountId, programId } = widgetId;
10511
- const variables = {
10512
- userId,
10513
- accountId,
10514
- programId,
10515
- };
10516
- return this.getClient()
10517
- .query({
10415
+ `,
10416
+ variables,
10417
+ })
10418
+ .then((res) => res.data.user);
10419
+ },
10420
+ async getReferralCode() {
10421
+ const widgetId = widgetIdent();
10422
+ if (widgetId["env"] === "demo" || !widgetId)
10423
+ return demoUser.referralcode;
10424
+ const { userId, accountId, programId } = widgetId;
10425
+ const variables = {
10426
+ userId,
10427
+ accountId,
10428
+ programId,
10429
+ };
10430
+ return this.getClient()
10431
+ .query({
10518
10432
  query: src `
10519
10433
  query ($userId: String!, $accountId: String!, $programId: ID!) {
10520
10434
  user(id: $userId, accountId: $accountId) {
10521
10435
  referralCode(programId: $programId)
10522
10436
  }
10523
10437
  }
10524
- `,
10525
- variables,
10526
- })
10527
- .then((res) => res.data.user.referralCode);
10528
- },
10529
- async getFueltankCode(rewardKey) {
10530
- const widgetId = widgetIdent();
10531
- if (widgetId["env"] === "demo" || !widgetId) {
10532
- return {
10533
- referredByReferral: demoUser.referredByReferral,
10534
- rewards: { data: demoUser.referredByReferral.rewards },
10535
- };
10536
- }
10537
- const { userId, accountId, programId } = widgetId;
10538
- const variables = {
10539
- userId,
10540
- accountId,
10541
- programId,
10542
- rewardKey,
10543
- };
10544
- return this.getClient()
10545
- .query({
10438
+ `,
10439
+ variables,
10440
+ })
10441
+ .then((res) => res.data.user.referralCode);
10442
+ },
10443
+ async getFueltankCode(rewardKey) {
10444
+ const widgetId = widgetIdent();
10445
+ if (widgetId["env"] === "demo" || !widgetId) {
10446
+ return {
10447
+ referredByReferral: demoUser.referredByReferral,
10448
+ rewards: { data: demoUser.referredByReferral.rewards },
10449
+ };
10450
+ }
10451
+ const { userId, accountId, programId } = widgetId;
10452
+ const variables = {
10453
+ userId,
10454
+ accountId,
10455
+ programId,
10456
+ rewardKey,
10457
+ };
10458
+ return this.getClient()
10459
+ .query({
10546
10460
  query: src `
10547
10461
  query (
10548
10462
  $userId: String!
@@ -10570,24 +10484,24 @@ const API = {
10570
10484
  }
10571
10485
  }
10572
10486
  }
10573
- `,
10574
- variables,
10575
- })
10576
- .then((res) => res.data.user);
10577
- },
10578
- getMessageLinks(mediums) {
10579
- const widgetId = widgetIdent();
10580
- if (widgetId["env"] === "demo" || !widgetId)
10581
- return Promise.resolve(demoUser.messageLink);
10582
- const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10583
- const variables = {
10584
- userId,
10585
- accountId,
10586
- programId,
10587
- engagementMedium,
10588
- };
10589
- return this.getClient()
10590
- .query({
10487
+ `,
10488
+ variables,
10489
+ })
10490
+ .then((res) => res.data.user);
10491
+ },
10492
+ getMessageLinks(mediums) {
10493
+ const widgetId = widgetIdent();
10494
+ if (widgetId["env"] === "demo" || !widgetId)
10495
+ return Promise.resolve(demoUser.messageLink);
10496
+ const { userId, accountId, programId = null, engagementMedium, } = widgetId;
10497
+ const variables = {
10498
+ userId,
10499
+ accountId,
10500
+ programId,
10501
+ engagementMedium,
10502
+ };
10503
+ return this.getClient()
10504
+ .query({
10591
10505
  query: src `
10592
10506
  query($userId: String!, $accountId: String!, $programId: ID, $engagementMedium: UserEngagementMedium!) {
10593
10507
  user(id: $userId, accountId: $accountId) {
@@ -10602,84 +10516,13 @@ const API = {
10602
10516
  ${mediums[8]}:messageLink(programId: $programId, engagementMedium: $engagementMedium, shareMedium: ${mediums[8]})
10603
10517
  }
10604
10518
  }
10605
- `,
10606
- variables,
10607
- })
10608
- .then((res) => res.data.user);
10609
- },
10610
- getUserProgress() {
10611
- const widgetId = widgetIdent();
10612
- if (widgetId["env"] === "demo" || !widgetId) {
10613
- const demoData = {
10614
- customFields: { demo_totalValue: 16 },
10615
- rewardBalanceDetails: [{
10616
- prettyAvailableValue: "$10.00"
10617
- }],
10618
- rewards: { count: 1 }
10619
- };
10620
- return Promise.resolve(demoData);
10621
- }
10622
- const { userId, accountId, programId } = widgetId;
10623
- const variables = {
10624
- userId,
10625
- accountId,
10626
- programId,
10627
- };
10628
- return this.getClient().query({
10629
- query: src `
10630
- query($userId: String!, $accountId: String!, $programId: ID) {
10631
- user(id: $userId, accountId: $accountId){
10632
- customFields
10633
- locale
10634
- rewardBalanceDetails(programId: $programId) {
10635
- prettyAvailableValue(formatType:UNIT_FORMATTED)
10636
- }
10637
- rewards(limit:1000,offset:0, filter:{programId_eq: $programId}){
10638
- count
10639
- }
10640
- }
10641
- }
10642
- `,
10643
- variables
10644
- }).then(res => res.data.user);
10645
- },
10646
- getProgramRules() {
10647
- const widgetId = widgetIdent();
10648
- if (widgetId["env"] === "demo" || !widgetId) {
10649
- const demoData = {
10650
- id: "demo",
10651
- name: "Demo Program",
10652
- rules: {
10653
- programWindow: "",
10654
- rewardRules: {
10655
- rewardRulesType: 1,
10656
- rewardGoal: 24,
10657
- isRecurring: 1,
10658
- defaultCurrency: "CAD"
10659
- }
10660
- }
10661
- };
10662
- return Promise.resolve(demoData);
10663
- }
10664
- const { programId } = widgetId;
10665
- const variables = {
10666
- programId
10667
- };
10668
- return this.getClient().query({
10669
- query: src `
10670
- query($programId: ID!) {
10671
- program(id:$programId){
10672
- id
10673
- name
10674
- rules
10675
- }
10676
- }
10677
- `,
10678
- variables
10679
- }).then(res => res.data.program);
10680
- },
10681
- },
10682
- ui: squatchJsApi,
10519
+ `,
10520
+ variables,
10521
+ })
10522
+ .then((res) => res.data.user);
10523
+ },
10524
+ },
10525
+ ui: squatchJsApi,
10683
10526
  };
10684
10527
 
10685
10528
  export { API as A, widgetIdent as w };