@jetthai/cuora 1.1.453 → 1.1.454-dev.0

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.
@@ -1,6 +1,5 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import payment from '../../api/payment.js'
3
- import { max } from '../../util'
4
3
 
5
4
  export default function (request, context) {
6
5
  const { paymentDetail = [], promotion, selectedAmount } = context || {}
@@ -102,6 +101,7 @@ export default function (request, context) {
102
101
  target: '.debouncing',
103
102
  actions: 'setPromotion',
104
103
  internal: false,
104
+ cond: 'isPromotionChanged',
105
105
  },
106
106
  SELECT_QRCODE: {
107
107
  target: '.debouncing',
@@ -123,7 +123,7 @@ export default function (request, context) {
123
123
  {
124
124
  actions: {
125
125
  setInitData: assign((context, event) => {
126
- const { paymentDetail, selectedAmount, promotion } = context
126
+ const { paymentDetail } = context
127
127
  const qrcodes = paymentDetail.filter((element) => element.category === context.currentCategory && element.transferType === 'deposit')
128
128
  const selectedQrcode = qrcodes[0]
129
129
  return {
@@ -131,11 +131,9 @@ export default function (request, context) {
131
131
  qrcodes,
132
132
  selectedQrcode,
133
133
  options: selectedQrcode?.optional,
134
- selectedAmount: max(promotion?.minimumAmount, selectedQrcode?.minimum, selectedAmount, 0),
135
134
  }
136
135
  }),
137
136
  setPromotion: assign((context, event) => {
138
- const { selectedAmount } = context
139
137
  const promotion = event.data
140
138
  const qrcodes = context.qrcodes
141
139
  const selectedQrcode = qrcodes[0]
@@ -144,17 +142,14 @@ export default function (request, context) {
144
142
  qrcodes,
145
143
  selectedQrcode,
146
144
  options: selectedQrcode?.optional,
147
- selectedAmount: max(promotion.minimumAmount, selectedQrcode?.minimum, selectedAmount, 0),
148
145
  calculation: null,
149
146
  }
150
147
  }),
151
148
  setQrcode: assign((context, event) => {
152
- const { promotion, selectedAmount } = context
153
149
  const selectedQrcode = event.data
154
150
  return {
155
151
  selectedQrcode,
156
152
  options: selectedQrcode.optional,
157
- selectedAmount: max(promotion.minimumAmount, selectedAmount, 0),
158
153
  calculation: null,
159
154
  }
160
155
  }),
@@ -194,6 +189,9 @@ export default function (request, context) {
194
189
  }),
195
190
  },
196
191
  guards: {
192
+ isPromotionChanged: (context, event) => {
193
+ return event.data?.promotionsNo !== context.promotion?.promotionsNo
194
+ },
197
195
  hasQrcodeMethods: (context, event) => {
198
196
  return context.paymentDetail?.filter((element) => element.category === context.currentCategory).length > 0
199
197
  },
@@ -1,6 +1,5 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import payment from '@jetthai/cuora/src/api/payment.js'
3
- import { max } from '@jetthai/cuora/src/util/index.js'
4
3
 
5
4
  export default function (request, context) {
6
5
  const { appSecret } = request.config
@@ -99,6 +98,7 @@ export default function (request, context) {
99
98
  target: 'debouncing',
100
99
  actions: 'setPromotion',
101
100
  internal: false,
101
+ cond: 'isPromotionChanged',
102
102
  },
103
103
  INPUT_AMOUNT: {
104
104
  target: 'debouncing',
@@ -120,7 +120,6 @@ export default function (request, context) {
120
120
  currentPayment,
121
121
  method: currentPayment.method,
122
122
  processing,
123
- selectedAmount: max(promotion?.minimumAmount, currentPayment?.minimum, selectedAmount, 0),
124
123
  virtualBanks,
125
124
  }
126
125
  }),
@@ -158,10 +157,14 @@ export default function (request, context) {
158
157
  setPromotion: assign((context, event) => {
159
158
  return {
160
159
  promotion: event.data,
160
+ calculation: null,
161
161
  }
162
162
  }),
163
163
  },
164
164
  guards: {
165
+ isPromotionChanged: (context, event) => {
166
+ return event.data?.promotionsNo !== context.promotion?.promotionsNo
167
+ },
165
168
  isCalculable: (context, event) => {
166
169
  const {
167
170
  selectedAmount,
@@ -104,6 +104,7 @@ export default function (request) {
104
104
  return {
105
105
  signUpData: {
106
106
  provider: 'local',
107
+ birthday,
107
108
  ...pickBindData(event.data),
108
109
  birthday,
109
110
  email,
@@ -127,6 +128,7 @@ export default function (request) {
127
128
  return {
128
129
  signUpData: {
129
130
  provider: 'phone',
131
+ birthday,
130
132
  ...pickBindData(event.data),
131
133
  birthday,
132
134
  email,
@@ -149,6 +151,7 @@ export default function (request) {
149
151
  return {
150
152
  signUpData: {
151
153
  provider: 'email',
154
+ birthday,
152
155
  ...pickBindData(event.data),
153
156
  birthday,
154
157
  email,
@@ -254,7 +254,7 @@ export default class Request {
254
254
  // reject → onError → leaving → 乾淨登出,且一樣不送網路 → 洪水照止
255
255
  if (!req.isPublic && !this.getToken()) return Promise.reject({ code: 'ERR_A103' })
256
256
 
257
- const cancelToken = customToken || this.source.token
257
+ const cancelToken = customToken
258
258
 
259
259
  // ERR_A103 No token provided 改由後端回傳:不再於送出前自行 throw,
260
260
  const requestConfig = this._createConfig(req, cancelToken)
@@ -283,6 +283,8 @@ export default class Request {
283
283
  }
284
284
  }
285
285
 
286
+ // 注意:send() 已不再預設附加 this.source.token(見 send 內註解),
287
+ // sourceUpdate 僅對「呼叫端明確以 this.source.token 為 customToken」的請求有效;保留以維持 API 相容。
286
288
  sourceUpdate() {
287
289
  this.source.cancel('Requests Cancelled')
288
290
  this.source = this.axios.CancelToken.source()