@saasquatch/mint-components 1.6.5-13 → 1.6.5-15

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 (29) hide show
  1. package/dist/cjs/sqm-referral-table_11.cjs.entry.js +4 -1
  2. package/dist/cjs/sqm-rewards-table_9.cjs.entry.js +2 -99
  3. package/dist/cjs/{useReferralTable-b07be5ec.js → useReferralTable-95ceaa3d.js} +145 -0
  4. package/dist/collection/components/sqm-referral-table/mockReferralData.js +4 -0
  5. package/dist/collection/components/sqm-rewards-table/mockRewardData.js +46 -1
  6. package/dist/esm/sqm-referral-table_11.entry.js +4 -1
  7. package/dist/esm/sqm-rewards-table_9.entry.js +1 -98
  8. package/dist/esm/{useReferralTable-46da6b31.js → useReferralTable-f60241cb.js} +144 -1
  9. package/dist/esm-es5/sqm-referral-table_11.entry.js +1 -1
  10. package/dist/esm-es5/sqm-rewards-table_9.entry.js +1 -1
  11. package/dist/esm-es5/useReferralTable-f60241cb.js +1 -0
  12. package/dist/mint-components/mint-components.esm.js +1 -1
  13. package/dist/mint-components/{p-901e8178.system.entry.js → p-0b95e4ec.system.entry.js} +1 -1
  14. package/dist/mint-components/p-458e1750.js +183 -0
  15. package/dist/mint-components/p-4739ef3a.entry.js +1 -0
  16. package/dist/mint-components/p-51c56881.entry.js +104 -0
  17. package/dist/mint-components/p-b43a075f.system.js +1 -1
  18. package/dist/mint-components/p-ba6ba68b.system.js +1 -0
  19. package/dist/mint-components/p-e5c7d2b3.system.entry.js +1 -0
  20. package/dist/types/components/sqm-referral-table/mockReferralData.d.ts +11 -0
  21. package/dist/types/components/sqm-rewards-table/mockRewardData.d.ts +22 -0
  22. package/docs/docs.docx +0 -0
  23. package/package.json +1 -1
  24. package/dist/esm-es5/useReferralTable-46da6b31.js +0 -1
  25. package/dist/mint-components/p-18391f95.system.js +0 -1
  26. package/dist/mint-components/p-19f6f3f6.js +0 -183
  27. package/dist/mint-components/p-2cab4ead.entry.js +0 -104
  28. package/dist/mint-components/p-47b6df26.entry.js +0 -1
  29. package/dist/mint-components/p-e2e3352a.system.entry.js +0 -1
@@ -14,7 +14,7 @@ const GenericTableView = require('./GenericTableView-9271483b.js');
14
14
  const reRender = require('./re-render-172958b1.js');
15
15
  const useChildElements = require('./useChildElements-6993ec39.js');
16
16
  const luxon = require('./luxon-479fc825.js');
17
- const useReferralTable = require('./useReferralTable-b07be5ec.js');
17
+ const useReferralTable = require('./useReferralTable-95ceaa3d.js');
18
18
  const utils = require('./utils-6847bc06.js');
19
19
  const sqmTextSpanView = require('./sqm-text-span-view-c34577fa.js');
20
20
 
@@ -115,6 +115,9 @@ const getMockData = () => {
115
115
  statuses: statuses[Math.floor(Math.random() * statuses.length)],
116
116
  globalRewardKey: null,
117
117
  programRewardKey: "partnerReward",
118
+ meta: {
119
+ ...useReferralTable.getPaypalMeta(),
120
+ },
118
121
  rewardRedemptionTransactions: {
119
122
  data: [
120
123
  {
@@ -14,106 +14,9 @@ const GenericTableView = require('./GenericTableView-9271483b.js');
14
14
  const reRender = require('./re-render-172958b1.js');
15
15
  const useChildElements = require('./useChildElements-6993ec39.js');
16
16
  const luxon = require('./luxon-479fc825.js');
17
- const useReferralTable = require('./useReferralTable-b07be5ec.js');
17
+ const useReferralTable = require('./useReferralTable-95ceaa3d.js');
18
18
  const utils = require('./utils-6847bc06.js');
19
19
 
20
- const mockRewardData = (count = 4) => {
21
- const data = [...Array(count)].map(() => getMockData());
22
- return { data };
23
- };
24
- const units = ["POINT", "TICKET", "GIFT"];
25
- const prettyValues = ["Points", "Tickets", "Gifts"];
26
- const statuses = ["AVAILABLE", "PENDING", "CANCELLED", "EXPIRED", "REDEEMED"];
27
- const pendingReasons = ["US_TAX", "SCHEDULED", "UNHANDLED_ERROR"];
28
- const getMockData = () => {
29
- let isAvailableZero = false;
30
- let randomRedeemed = 0;
31
- let pendingReason;
32
- let dateScheduledFor;
33
- let dateCancelled;
34
- let dateExpires;
35
- const today = luxon.luxon.DateTime.now();
36
- // set random data
37
- const randomUnitNumber = Math.floor(Math.random() * 3);
38
- const randomStatus = statuses[Math.floor(Math.random() * 5)];
39
- const unit = units[randomUnitNumber];
40
- const prettyValue = prettyValues[randomUnitNumber];
41
- const randomValue = Math.floor(Math.random() * 100) + 2;
42
- if (randomStatus === "AVAILABLE") {
43
- randomRedeemed = Math.floor(Math.random() * randomValue);
44
- dateExpires =
45
- Math.floor(Math.random() * 10) < 3 ? today.plus({ days: 7 }).toMillis() : null;
46
- }
47
- else if (randomStatus === "EXPIRED") {
48
- isAvailableZero = true;
49
- randomRedeemed = Math.floor(Math.random() * randomValue);
50
- dateExpires = today.minus({ days: 1 }).toMillis();
51
- }
52
- else if (randomStatus === "PENDING") {
53
- const reason = pendingReasons[Math.floor(Math.random() * 3)];
54
- pendingReason = [reason];
55
- if (reason === "SCHEDULED") {
56
- dateScheduledFor = today.plus({ days: 6 }).toMillis();
57
- }
58
- }
59
- else if (randomStatus === "REDEEMED") {
60
- isAvailableZero = true;
61
- }
62
- else {
63
- isAvailableZero = true;
64
- dateCancelled = today.minus({ days: 2 }).toMillis();
65
- }
66
- const source = Math.floor(Math.random() * 3);
67
- return {
68
- id: "61f7878e096c9265de88b46f",
69
- type: "CREDIT",
70
- value: randomValue,
71
- unit,
72
- name: null,
73
- dateGiven: today.minus({ days: 3 }).toMillis(),
74
- dateExpires,
75
- dateCancelled,
76
- dateRedeemed: randomStatus === "REDEEMED" ? today.plus({ days: 2 }).toMillis() : null,
77
- dateScheduledFor,
78
- fuelTankCode: null,
79
- fuelTankType: null,
80
- currency: null,
81
- prettyValue: `${randomValue} ${prettyValue}`,
82
- prettyValueNumber: `${randomValue}`,
83
- prettyAvailableNumber: isAvailableZero
84
- ? "0"
85
- : `${randomValue - randomRedeemed}`,
86
- prettyRedeemedNumber: isAvailableZero && !randomRedeemed ? "0" : `${randomRedeemed}`,
87
- programId: source === 1 ? "program-id" : null,
88
- program: {
89
- name: "My Program",
90
- },
91
- statuses: [randomStatus],
92
- pendingReasons: pendingReason,
93
- globalRewardKey: null,
94
- programRewardKey: null,
95
- rewardSource: source === 1 ? "AUTOMATED" : "MANUAL",
96
- prettyRedeemedCredit: `${randomRedeemed} ${prettyValue}`,
97
- prettyAssignedCredit: `${randomValue} ${prettyValue}`,
98
- prettyAvailableValue: isAvailableZero
99
- ? `0 ${prettyValue}`
100
- : `${randomValue - randomRedeemed} ${prettyValue}`,
101
- exchangedRewardRedemptionTransaction: source === 2
102
- ? {
103
- id: "61f7878e096c9265de88b414",
104
- creditRedeemed: 50,
105
- prettyRedeemedCredit: "50 Tokens",
106
- unit: "TOKEN",
107
- dateRedeemed: 1643612046258,
108
- }
109
- : null,
110
- referral: null,
111
- rewardRedemptionTransactions: {
112
- data: [],
113
- },
114
- };
115
- };
116
-
117
20
  const debug = stencilHooks_module.browser("sq:useRewardsTable");
118
21
  const CSS_NAMESPACE = "sqm-rewards-table";
119
22
  const GET_REWARDS = index_module.dist.gql `
@@ -400,7 +303,7 @@ function useRewardsTableDemo(props, emptyElement, loadingElement) {
400
303
  page: 0,
401
304
  });
402
305
  const tick = reRender.useRerenderListener();
403
- const { data } = stencilHooks_module.useMemo(() => { var _a; return ((_a = props.demoData) === null || _a === void 0 ? void 0 : _a.mockData) || mockRewardData(props.perPage); }, [props.perPage]);
306
+ const { data } = stencilHooks_module.useMemo(() => { var _a; return ((_a = props.demoData) === null || _a === void 0 ? void 0 : _a.mockData) || useReferralTable.mockRewardData(props.perPage); }, [props.perPage]);
404
307
  const components = useChildElements.useChildElements();
405
308
  async function getComponentData(components) {
406
309
  let componentData = data;
@@ -5,6 +5,149 @@ const stencilHooks_module = require('./stencil-hooks.module-6fe43579.js');
5
5
  const index_module = require('./index.module-0b9b8891.js');
6
6
  const reRender = require('./re-render-172958b1.js');
7
7
  const useChildElements = require('./useChildElements-6993ec39.js');
8
+ const luxon = require('./luxon-479fc825.js');
9
+
10
+ const mockRewardData = (count = 4) => {
11
+ const data = [...Array(count)].map(() => getMockData());
12
+ return { data };
13
+ };
14
+ const units = ["POINT", "TICKET", "GIFT"];
15
+ const prettyValues = ["Points", "Tickets", "Gifts"];
16
+ const statuses = ["AVAILABLE", "PENDING", "CANCELLED", "EXPIRED", "REDEEMED"];
17
+ const pendingReasons = ["US_TAX", "SCHEDULED", "UNHANDLED_ERROR"];
18
+ const paypalStatuses = [
19
+ "FAILED",
20
+ "UNCLAIMED",
21
+ "ONHOLD",
22
+ "REFUNDED",
23
+ "RETURNED",
24
+ "REVERSED",
25
+ "BLOCKED",
26
+ "DENIED",
27
+ ];
28
+ function getPaypalStatus(datePaidOut) {
29
+ if (datePaidOut)
30
+ return "SUCCESS";
31
+ const randomIndex = Math.floor(Math.random() * 6);
32
+ const randomStatus = paypalStatuses.find((_status, index) => index === randomIndex);
33
+ return randomStatus;
34
+ }
35
+ const getPaypalMeta = () => {
36
+ const datePaidOut = Math.floor(Math.random() * 10) >= 5 ? 123456789 : null;
37
+ const dateLastAttempted = Math.floor(Math.random() * 10) >= 5 ? 123456789 : null;
38
+ const paypalStatus = getPaypalStatus(datePaidOut);
39
+ const status = paypalStatus === "DENIED"
40
+ ? "WARN"
41
+ : !!datePaidOut
42
+ ? "SUCCESS"
43
+ : Math.floor(Math.random() * 10) >= 8
44
+ ? "ERROR"
45
+ : "SUCCESS";
46
+ return {
47
+ status,
48
+ customMeta: {
49
+ datePaidOut,
50
+ dateLastAttempted,
51
+ dateFirstAttempted: dateLastAttempted,
52
+ rawPayPalInfo: {
53
+ transaction_status: paypalStatus,
54
+ },
55
+ },
56
+ };
57
+ };
58
+ const getMockData = () => {
59
+ let isAvailableZero = false;
60
+ let randomRedeemed = 0;
61
+ let pendingReason;
62
+ let dateScheduledFor;
63
+ let dateCancelled;
64
+ let dateExpires;
65
+ const today = luxon.luxon.DateTime.now();
66
+ // set random data
67
+ const randomUnitNumber = Math.floor(Math.random() * 3);
68
+ const randomStatus = statuses[Math.floor(Math.random() * 5)];
69
+ const unit = units[randomUnitNumber];
70
+ const prettyValue = prettyValues[randomUnitNumber];
71
+ const randomValue = Math.floor(Math.random() * 100) + 2;
72
+ if (randomStatus === "AVAILABLE") {
73
+ randomRedeemed = Math.floor(Math.random() * randomValue);
74
+ dateExpires =
75
+ Math.floor(Math.random() * 10) < 3
76
+ ? today.plus({ days: 7 }).toMillis()
77
+ : null;
78
+ }
79
+ else if (randomStatus === "EXPIRED") {
80
+ isAvailableZero = true;
81
+ randomRedeemed = Math.floor(Math.random() * randomValue);
82
+ dateExpires = today.minus({ days: 1 }).toMillis();
83
+ }
84
+ else if (randomStatus === "PENDING") {
85
+ const reason = pendingReasons[Math.floor(Math.random() * 3)];
86
+ pendingReason = [reason];
87
+ if (reason === "SCHEDULED") {
88
+ dateScheduledFor = today.plus({ days: 6 }).toMillis();
89
+ }
90
+ }
91
+ else if (randomStatus === "REDEEMED") {
92
+ isAvailableZero = true;
93
+ }
94
+ else {
95
+ isAvailableZero = true;
96
+ dateCancelled = today.minus({ days: 2 }).toMillis();
97
+ }
98
+ const source = Math.floor(Math.random() * 3);
99
+ return {
100
+ id: "61f7878e096c9265de88b46f",
101
+ type: "CREDIT",
102
+ value: randomValue,
103
+ unit,
104
+ name: null,
105
+ dateGiven: today.minus({ days: 3 }).toMillis(),
106
+ dateExpires,
107
+ dateCancelled,
108
+ dateRedeemed: randomStatus === "REDEEMED" ? today.plus({ days: 2 }).toMillis() : null,
109
+ dateScheduledFor,
110
+ fuelTankCode: null,
111
+ fuelTankType: null,
112
+ currency: null,
113
+ prettyValue: `${randomValue} ${prettyValue}`,
114
+ prettyValueNumber: `${randomValue}`,
115
+ prettyAvailableNumber: isAvailableZero
116
+ ? "0"
117
+ : `${randomValue - randomRedeemed}`,
118
+ prettyRedeemedNumber: isAvailableZero && !randomRedeemed ? "0" : `${randomRedeemed}`,
119
+ programId: source === 1 ? "program-id" : null,
120
+ program: {
121
+ name: "My Program",
122
+ },
123
+ meta: {
124
+ ...getPaypalMeta(),
125
+ },
126
+ statuses: [randomStatus],
127
+ pendingReasons: pendingReason,
128
+ globalRewardKey: null,
129
+ programRewardKey: null,
130
+ rewardSource: source === 1 ? "AUTOMATED" : "MANUAL",
131
+ prettyRedeemedCredit: `${randomRedeemed} ${prettyValue}`,
132
+ prettyAssignedCredit: `${randomValue} ${prettyValue}`,
133
+ prettyAvailableValue: isAvailableZero
134
+ ? `0 ${prettyValue}`
135
+ : `${randomValue - randomRedeemed} ${prettyValue}`,
136
+ exchangedRewardRedemptionTransaction: source === 2
137
+ ? {
138
+ id: "61f7878e096c9265de88b414",
139
+ creditRedeemed: 50,
140
+ prettyRedeemedCredit: "50 Tokens",
141
+ unit: "TOKEN",
142
+ dateRedeemed: 1643612046258,
143
+ }
144
+ : null,
145
+ referral: null,
146
+ rewardRedemptionTransactions: {
147
+ data: [],
148
+ },
149
+ };
150
+ };
8
151
 
9
152
  const debug = stencilHooks_module.browser("sq:useReferralTable");
10
153
  const CSS_NAMESPACE = "sqm-referral-table";
@@ -368,5 +511,7 @@ async function tryMethod(c, callback) {
368
511
  }
369
512
 
370
513
  exports.generateUserError = generateUserError;
514
+ exports.getPaypalMeta = getPaypalMeta;
515
+ exports.mockRewardData = mockRewardData;
371
516
  exports.tryMethod = tryMethod;
372
517
  exports.useReferralTable = useReferralTable;
@@ -1,4 +1,5 @@
1
1
  import { DateTime } from "luxon";
2
+ import { getPaypalMeta } from "../sqm-rewards-table/mockRewardData";
2
3
  export default (count = 4) => {
3
4
  const data = [...Array(count)].map(() => getMockData());
4
5
  return {
@@ -96,6 +97,9 @@ const getMockData = () => {
96
97
  statuses: statuses[Math.floor(Math.random() * statuses.length)],
97
98
  globalRewardKey: null,
98
99
  programRewardKey: "partnerReward",
100
+ meta: {
101
+ ...getPaypalMeta(),
102
+ },
99
103
  rewardRedemptionTransactions: {
100
104
  data: [
101
105
  {
@@ -7,6 +7,46 @@ const units = ["POINT", "TICKET", "GIFT"];
7
7
  const prettyValues = ["Points", "Tickets", "Gifts"];
8
8
  const statuses = ["AVAILABLE", "PENDING", "CANCELLED", "EXPIRED", "REDEEMED"];
9
9
  const pendingReasons = ["US_TAX", "SCHEDULED", "UNHANDLED_ERROR"];
10
+ const paypalStatuses = [
11
+ "FAILED",
12
+ "UNCLAIMED",
13
+ "ONHOLD",
14
+ "REFUNDED",
15
+ "RETURNED",
16
+ "REVERSED",
17
+ "BLOCKED",
18
+ "DENIED",
19
+ ];
20
+ function getPaypalStatus(datePaidOut) {
21
+ if (datePaidOut)
22
+ return "SUCCESS";
23
+ const randomIndex = Math.floor(Math.random() * 6);
24
+ const randomStatus = paypalStatuses.find((_status, index) => index === randomIndex);
25
+ return randomStatus;
26
+ }
27
+ export const getPaypalMeta = () => {
28
+ const datePaidOut = Math.floor(Math.random() * 10) >= 5 ? 123456789 : null;
29
+ const dateLastAttempted = Math.floor(Math.random() * 10) >= 5 ? 123456789 : null;
30
+ const paypalStatus = getPaypalStatus(datePaidOut);
31
+ const status = paypalStatus === "DENIED"
32
+ ? "WARN"
33
+ : !!datePaidOut
34
+ ? "SUCCESS"
35
+ : Math.floor(Math.random() * 10) >= 8
36
+ ? "ERROR"
37
+ : "SUCCESS";
38
+ return {
39
+ status,
40
+ customMeta: {
41
+ datePaidOut,
42
+ dateLastAttempted,
43
+ dateFirstAttempted: dateLastAttempted,
44
+ rawPayPalInfo: {
45
+ transaction_status: paypalStatus,
46
+ },
47
+ },
48
+ };
49
+ };
10
50
  const getMockData = () => {
11
51
  let isAvailableZero = false;
12
52
  let randomRedeemed = 0;
@@ -27,7 +67,9 @@ const getMockData = () => {
27
67
  prettyAvailableValue = `${randomValue} ${prettyValue}`;
28
68
  randomRedeemed = Math.floor(Math.random() * randomValue);
29
69
  dateExpires =
30
- Math.floor(Math.random() * 10) < 3 ? today.plus({ days: 7 }).toMillis() : null;
70
+ Math.floor(Math.random() * 10) < 3
71
+ ? today.plus({ days: 7 }).toMillis()
72
+ : null;
31
73
  }
32
74
  else if (randomStatus === "EXPIRED") {
33
75
  prettyAvailableValue = `0 ${prettyValue}`;
@@ -76,6 +118,9 @@ const getMockData = () => {
76
118
  program: {
77
119
  name: "My Program",
78
120
  },
121
+ meta: {
122
+ ...getPaypalMeta(),
123
+ },
79
124
  statuses: [randomStatus],
80
125
  pendingReasons: pendingReason,
81
126
  globalRewardKey: null,
@@ -10,7 +10,7 @@ import { G as GenericTableView } from './GenericTableView-ce26115f.js';
10
10
  import { a as useRequestRerender, u as useRerenderListener } from './re-render-f406e379.js';
11
11
  import { u as useChildElements } from './useChildElements-11279a92.js';
12
12
  import { l as luxon } from './luxon-198ac0b0.js';
13
- import { u as useReferralTable, t as tryMethod } from './useReferralTable-46da6b31.js';
13
+ import { a as getPaypalMeta, u as useReferralTable, t as tryMethod } from './useReferralTable-f60241cb.js';
14
14
  import { l as luxonLocale } from './utils-334c1e34.js';
15
15
  import { T as TextSpanView } from './sqm-text-span-view-f1cacc75.js';
16
16
 
@@ -111,6 +111,9 @@ const getMockData = () => {
111
111
  statuses: statuses[Math.floor(Math.random() * statuses.length)],
112
112
  globalRewardKey: null,
113
113
  programRewardKey: "partnerReward",
114
+ meta: {
115
+ ...getPaypalMeta(),
116
+ },
114
117
  rewardRedemptionTransactions: {
115
118
  data: [
116
119
  {
@@ -10,106 +10,9 @@ import { G as GenericTableView } from './GenericTableView-ce26115f.js';
10
10
  import { u as useRerenderListener, a as useRequestRerender } from './re-render-f406e379.js';
11
11
  import { u as useChildElements } from './useChildElements-11279a92.js';
12
12
  import { l as luxon } from './luxon-198ac0b0.js';
13
- import { g as generateUserError } from './useReferralTable-46da6b31.js';
13
+ import { g as generateUserError, m as mockRewardData } from './useReferralTable-f60241cb.js';
14
14
  import { l as luxonLocale } from './utils-334c1e34.js';
15
15
 
16
- const mockRewardData = (count = 4) => {
17
- const data = [...Array(count)].map(() => getMockData());
18
- return { data };
19
- };
20
- const units = ["POINT", "TICKET", "GIFT"];
21
- const prettyValues = ["Points", "Tickets", "Gifts"];
22
- const statuses = ["AVAILABLE", "PENDING", "CANCELLED", "EXPIRED", "REDEEMED"];
23
- const pendingReasons = ["US_TAX", "SCHEDULED", "UNHANDLED_ERROR"];
24
- const getMockData = () => {
25
- let isAvailableZero = false;
26
- let randomRedeemed = 0;
27
- let pendingReason;
28
- let dateScheduledFor;
29
- let dateCancelled;
30
- let dateExpires;
31
- const today = luxon.DateTime.now();
32
- // set random data
33
- const randomUnitNumber = Math.floor(Math.random() * 3);
34
- const randomStatus = statuses[Math.floor(Math.random() * 5)];
35
- const unit = units[randomUnitNumber];
36
- const prettyValue = prettyValues[randomUnitNumber];
37
- const randomValue = Math.floor(Math.random() * 100) + 2;
38
- if (randomStatus === "AVAILABLE") {
39
- randomRedeemed = Math.floor(Math.random() * randomValue);
40
- dateExpires =
41
- Math.floor(Math.random() * 10) < 3 ? today.plus({ days: 7 }).toMillis() : null;
42
- }
43
- else if (randomStatus === "EXPIRED") {
44
- isAvailableZero = true;
45
- randomRedeemed = Math.floor(Math.random() * randomValue);
46
- dateExpires = today.minus({ days: 1 }).toMillis();
47
- }
48
- else if (randomStatus === "PENDING") {
49
- const reason = pendingReasons[Math.floor(Math.random() * 3)];
50
- pendingReason = [reason];
51
- if (reason === "SCHEDULED") {
52
- dateScheduledFor = today.plus({ days: 6 }).toMillis();
53
- }
54
- }
55
- else if (randomStatus === "REDEEMED") {
56
- isAvailableZero = true;
57
- }
58
- else {
59
- isAvailableZero = true;
60
- dateCancelled = today.minus({ days: 2 }).toMillis();
61
- }
62
- const source = Math.floor(Math.random() * 3);
63
- return {
64
- id: "61f7878e096c9265de88b46f",
65
- type: "CREDIT",
66
- value: randomValue,
67
- unit,
68
- name: null,
69
- dateGiven: today.minus({ days: 3 }).toMillis(),
70
- dateExpires,
71
- dateCancelled,
72
- dateRedeemed: randomStatus === "REDEEMED" ? today.plus({ days: 2 }).toMillis() : null,
73
- dateScheduledFor,
74
- fuelTankCode: null,
75
- fuelTankType: null,
76
- currency: null,
77
- prettyValue: `${randomValue} ${prettyValue}`,
78
- prettyValueNumber: `${randomValue}`,
79
- prettyAvailableNumber: isAvailableZero
80
- ? "0"
81
- : `${randomValue - randomRedeemed}`,
82
- prettyRedeemedNumber: isAvailableZero && !randomRedeemed ? "0" : `${randomRedeemed}`,
83
- programId: source === 1 ? "program-id" : null,
84
- program: {
85
- name: "My Program",
86
- },
87
- statuses: [randomStatus],
88
- pendingReasons: pendingReason,
89
- globalRewardKey: null,
90
- programRewardKey: null,
91
- rewardSource: source === 1 ? "AUTOMATED" : "MANUAL",
92
- prettyRedeemedCredit: `${randomRedeemed} ${prettyValue}`,
93
- prettyAssignedCredit: `${randomValue} ${prettyValue}`,
94
- prettyAvailableValue: isAvailableZero
95
- ? `0 ${prettyValue}`
96
- : `${randomValue - randomRedeemed} ${prettyValue}`,
97
- exchangedRewardRedemptionTransaction: source === 2
98
- ? {
99
- id: "61f7878e096c9265de88b414",
100
- creditRedeemed: 50,
101
- prettyRedeemedCredit: "50 Tokens",
102
- unit: "TOKEN",
103
- dateRedeemed: 1643612046258,
104
- }
105
- : null,
106
- referral: null,
107
- rewardRedemptionTransactions: {
108
- data: [],
109
- },
110
- };
111
- };
112
-
113
16
  const debug = browser("sq:useRewardsTable");
114
17
  const CSS_NAMESPACE = "sqm-rewards-table";
115
18
  const GET_REWARDS = dist.gql `
@@ -3,6 +3,149 @@ import { b as browser, f as useReducer, u as useEffect } from './stencil-hooks.m
3
3
  import { d as dist, N, O, x, a as dn, v as vn } from './index.module-48cc9ee0.js';
4
4
  import { u as useRerenderListener } from './re-render-f406e379.js';
5
5
  import { u as useChildElements } from './useChildElements-11279a92.js';
6
+ import { l as luxon } from './luxon-198ac0b0.js';
7
+
8
+ const mockRewardData = (count = 4) => {
9
+ const data = [...Array(count)].map(() => getMockData());
10
+ return { data };
11
+ };
12
+ const units = ["POINT", "TICKET", "GIFT"];
13
+ const prettyValues = ["Points", "Tickets", "Gifts"];
14
+ const statuses = ["AVAILABLE", "PENDING", "CANCELLED", "EXPIRED", "REDEEMED"];
15
+ const pendingReasons = ["US_TAX", "SCHEDULED", "UNHANDLED_ERROR"];
16
+ const paypalStatuses = [
17
+ "FAILED",
18
+ "UNCLAIMED",
19
+ "ONHOLD",
20
+ "REFUNDED",
21
+ "RETURNED",
22
+ "REVERSED",
23
+ "BLOCKED",
24
+ "DENIED",
25
+ ];
26
+ function getPaypalStatus(datePaidOut) {
27
+ if (datePaidOut)
28
+ return "SUCCESS";
29
+ const randomIndex = Math.floor(Math.random() * 6);
30
+ const randomStatus = paypalStatuses.find((_status, index) => index === randomIndex);
31
+ return randomStatus;
32
+ }
33
+ const getPaypalMeta = () => {
34
+ const datePaidOut = Math.floor(Math.random() * 10) >= 5 ? 123456789 : null;
35
+ const dateLastAttempted = Math.floor(Math.random() * 10) >= 5 ? 123456789 : null;
36
+ const paypalStatus = getPaypalStatus(datePaidOut);
37
+ const status = paypalStatus === "DENIED"
38
+ ? "WARN"
39
+ : !!datePaidOut
40
+ ? "SUCCESS"
41
+ : Math.floor(Math.random() * 10) >= 8
42
+ ? "ERROR"
43
+ : "SUCCESS";
44
+ return {
45
+ status,
46
+ customMeta: {
47
+ datePaidOut,
48
+ dateLastAttempted,
49
+ dateFirstAttempted: dateLastAttempted,
50
+ rawPayPalInfo: {
51
+ transaction_status: paypalStatus,
52
+ },
53
+ },
54
+ };
55
+ };
56
+ const getMockData = () => {
57
+ let isAvailableZero = false;
58
+ let randomRedeemed = 0;
59
+ let pendingReason;
60
+ let dateScheduledFor;
61
+ let dateCancelled;
62
+ let dateExpires;
63
+ const today = luxon.DateTime.now();
64
+ // set random data
65
+ const randomUnitNumber = Math.floor(Math.random() * 3);
66
+ const randomStatus = statuses[Math.floor(Math.random() * 5)];
67
+ const unit = units[randomUnitNumber];
68
+ const prettyValue = prettyValues[randomUnitNumber];
69
+ const randomValue = Math.floor(Math.random() * 100) + 2;
70
+ if (randomStatus === "AVAILABLE") {
71
+ randomRedeemed = Math.floor(Math.random() * randomValue);
72
+ dateExpires =
73
+ Math.floor(Math.random() * 10) < 3
74
+ ? today.plus({ days: 7 }).toMillis()
75
+ : null;
76
+ }
77
+ else if (randomStatus === "EXPIRED") {
78
+ isAvailableZero = true;
79
+ randomRedeemed = Math.floor(Math.random() * randomValue);
80
+ dateExpires = today.minus({ days: 1 }).toMillis();
81
+ }
82
+ else if (randomStatus === "PENDING") {
83
+ const reason = pendingReasons[Math.floor(Math.random() * 3)];
84
+ pendingReason = [reason];
85
+ if (reason === "SCHEDULED") {
86
+ dateScheduledFor = today.plus({ days: 6 }).toMillis();
87
+ }
88
+ }
89
+ else if (randomStatus === "REDEEMED") {
90
+ isAvailableZero = true;
91
+ }
92
+ else {
93
+ isAvailableZero = true;
94
+ dateCancelled = today.minus({ days: 2 }).toMillis();
95
+ }
96
+ const source = Math.floor(Math.random() * 3);
97
+ return {
98
+ id: "61f7878e096c9265de88b46f",
99
+ type: "CREDIT",
100
+ value: randomValue,
101
+ unit,
102
+ name: null,
103
+ dateGiven: today.minus({ days: 3 }).toMillis(),
104
+ dateExpires,
105
+ dateCancelled,
106
+ dateRedeemed: randomStatus === "REDEEMED" ? today.plus({ days: 2 }).toMillis() : null,
107
+ dateScheduledFor,
108
+ fuelTankCode: null,
109
+ fuelTankType: null,
110
+ currency: null,
111
+ prettyValue: `${randomValue} ${prettyValue}`,
112
+ prettyValueNumber: `${randomValue}`,
113
+ prettyAvailableNumber: isAvailableZero
114
+ ? "0"
115
+ : `${randomValue - randomRedeemed}`,
116
+ prettyRedeemedNumber: isAvailableZero && !randomRedeemed ? "0" : `${randomRedeemed}`,
117
+ programId: source === 1 ? "program-id" : null,
118
+ program: {
119
+ name: "My Program",
120
+ },
121
+ meta: {
122
+ ...getPaypalMeta(),
123
+ },
124
+ statuses: [randomStatus],
125
+ pendingReasons: pendingReason,
126
+ globalRewardKey: null,
127
+ programRewardKey: null,
128
+ rewardSource: source === 1 ? "AUTOMATED" : "MANUAL",
129
+ prettyRedeemedCredit: `${randomRedeemed} ${prettyValue}`,
130
+ prettyAssignedCredit: `${randomValue} ${prettyValue}`,
131
+ prettyAvailableValue: isAvailableZero
132
+ ? `0 ${prettyValue}`
133
+ : `${randomValue - randomRedeemed} ${prettyValue}`,
134
+ exchangedRewardRedemptionTransaction: source === 2
135
+ ? {
136
+ id: "61f7878e096c9265de88b414",
137
+ creditRedeemed: 50,
138
+ prettyRedeemedCredit: "50 Tokens",
139
+ unit: "TOKEN",
140
+ dateRedeemed: 1643612046258,
141
+ }
142
+ : null,
143
+ referral: null,
144
+ rewardRedemptionTransactions: {
145
+ data: [],
146
+ },
147
+ };
148
+ };
6
149
 
7
150
  const debug = browser("sq:useReferralTable");
8
151
  const CSS_NAMESPACE = "sqm-referral-table";
@@ -365,4 +508,4 @@ async function tryMethod(c, callback) {
365
508
  }
366
509
  }
367
510
 
368
- export { generateUserError as g, tryMethod as t, useReferralTable as u };
511
+ export { getPaypalMeta as a, generateUserError as g, mockRewardData as m, tryMethod as t, useReferralTable as u };