@jetthai/cuora 1.1.305-dev-4 → 1.1.305-dev-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.305-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev-5...v1.1.305-dev-6) (2024-09-13)
6
+
7
+ ### [1.1.305-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev-4...v1.1.305-dev-5) (2024-09-13)
8
+
5
9
  ### [1.1.305-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev-3...v1.1.305-dev-4) (2024-09-13)
6
10
 
7
11
  ### [1.1.305-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev-2...v1.1.305-dev-3) (2024-09-12)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.305-dev-4",
3
+ "version": "1.1.305-dev-6",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -21,6 +21,7 @@ export default function (request) {
21
21
  dailyRedemptionLimit: 0,
22
22
  reachedAmountLimit: false,
23
23
  activityNo: null,
24
+ claimResultData: null,
24
25
  },
25
26
  initial: 'idle',
26
27
  states: {
@@ -68,7 +69,7 @@ export default function (request) {
68
69
  invoke: {
69
70
  src: 'claimRebateAmount',
70
71
  onDone: {
71
- target: 'claimed',
72
+ target: 'checkClaimStatus',
72
73
  actions: 'setClaimesult',
73
74
  },
74
75
  onError: {
@@ -76,6 +77,16 @@ export default function (request) {
76
77
  },
77
78
  },
78
79
  },
80
+ checkClaimStatus: {
81
+ always: [{ target: 'claimed', cond: 'isClaimSuccess' }, { target: 'claimFail' }],
82
+ },
83
+ claimFail: {
84
+ after: {
85
+ 0: {
86
+ target: 'claimEnable',
87
+ },
88
+ },
89
+ },
79
90
  claimed: {},
80
91
  fail: {},
81
92
  },
@@ -131,6 +142,11 @@ export default function (request) {
131
142
  reachedAmountLimit,
132
143
  }
133
144
  }),
145
+ setClaimesult: assign((context, event) => {
146
+ return {
147
+ claimResultData: event.data,
148
+ }
149
+ }),
134
150
  },
135
151
  guards: {
136
152
  isClaimAmountLimitReached: (context, event) => {
@@ -143,36 +159,26 @@ export default function (request) {
143
159
  },
144
160
  isInsufficientAmount: (context, event) => {
145
161
  const { collectAvailable, singleMinimumAmountReceive, actualRebateAmount } = context
146
- let splitArray = actualRebateAmount?.split(',')
147
- let combindString = '0'
148
- if (splitArray?.length > 0) {
149
- splitArray.forEach((item) => {
150
- combindString += item
151
- })
152
- } else {
153
- combindString = actualRebateAmount
154
- }
155
- const deformatRebateAmount = parseFloat(`${combindString}`)
156
- return !collectAvailable && deformatRebateAmount < parseFloat(`${singleMinimumAmountReceive}`)
162
+ const formattedSingleMinimumAmountReceive = parseFloat(singleMinimumAmountReceive.replace(/,/g, ''))
163
+ const formattedActualRebateAmount = parseFloat(actualRebateAmount.replace(/,/g, ''))
164
+
165
+ return !collectAvailable && parseFloat(`${formattedActualRebateAmount}`) < parseFloat(`${formattedSingleMinimumAmountReceive}`)
157
166
  },
158
167
  isClaimEnable: (context, event) => {
159
168
  const { collectAvailable, remainingCount, dailyRedemptionLimit, actualRebateAmount, singleMinimumAmountReceive } = context
160
- let splitArray = actualRebateAmount?.split(',')
161
- let combindString = '0'
162
- if (splitArray?.length > 0) {
163
- splitArray.forEach((item) => {
164
- combindString += item
165
- })
166
- } else {
167
- combindString = actualRebateAmount
168
- }
169
- const deformatRebateAmount = parseFloat(combindString)
169
+ const formattedSingleMinimumAmountReceive = parseFloat(singleMinimumAmountReceive.replace(/,/g, ''))
170
+ const formattedActualRebateAmount = parseFloat(actualRebateAmount.replace(/,/g, ''))
171
+
170
172
  return (
171
173
  collectAvailable &&
172
174
  parseInt(`${remainingCount}`) < parseInt(`${dailyRedemptionLimit}`) &&
173
- deformatRebateAmount >= parseFloat(`${singleMinimumAmountReceive}`)
175
+ parseFloat(`${formattedActualRebateAmount}`) >= parseFloat(`${formattedSingleMinimumAmountReceive}`)
174
176
  )
175
177
  },
178
+ isClaimSuccess: (context, event) => {
179
+ const { claimResultData } = context
180
+ return claimResultData?.result === 'success'
181
+ },
176
182
  },
177
183
  services: {
178
184
  estimate: async (context, event) => {