@jetthai/cuora 1.1.450 → 1.1.451-dev.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.
@@ -99,6 +99,7 @@ export default function (request, context) {
99
99
  target: 'debouncing',
100
100
  actions: 'setPromotion',
101
101
  internal: false,
102
+ cond: 'isPromotionChanged',
102
103
  },
103
104
  INPUT_AMOUNT: {
104
105
  target: 'debouncing',
@@ -120,7 +121,7 @@ export default function (request, context) {
120
121
  currentPayment,
121
122
  method: currentPayment.method,
122
123
  processing,
123
- selectedAmount: max(promotion?.minimumAmount, currentPayment?.minimum, selectedAmount, 0),
124
+ selectedAmount: max(context.promotion?.minimumAmount, currentPayment?.minimum, context.selectedAmount, 0),
124
125
  virtualBanks,
125
126
  }
126
127
  }),
@@ -158,10 +159,15 @@ export default function (request, context) {
158
159
  setPromotion: assign((context, event) => {
159
160
  return {
160
161
  promotion: event.data,
162
+ selectedAmount: max(event.data?.minimumAmount, context.currentPayment?.minimum, 0),
163
+ calculation: null,
161
164
  }
162
165
  }),
163
166
  },
164
167
  guards: {
168
+ isPromotionChanged: (context, event) => {
169
+ return event.data?.promotionsNo !== context.promotion?.promotionsNo
170
+ },
165
171
  isCalculable: (context, event) => {
166
172
  const {
167
173
  selectedAmount,
@@ -2,6 +2,20 @@ import { assign, createMachine } from 'xstate'
2
2
  import auth from '../api/auth.js'
3
3
  import storage from '../util/storage.js'
4
4
 
5
+ // 註冊強制綁定多型出款:轉發各綁定型別欄位(BANK / CRYPTO / EWALLET),只帶有值的欄位
6
+ const BIND_FIELDS = [
7
+ 'bindingType',
8
+ 'cryptoCurrency',
9
+ 'cryptoNetwork',
10
+ 'cryptoAddress',
11
+ 'walletCode',
12
+ 'ifscCode',
13
+ 'pixType',
14
+ 'firstNameLocale',
15
+ 'lastNameLocale',
16
+ ]
17
+ const pickBindData = (data = {}) => BIND_FIELDS.reduce((acc, key) => (data[key] !== undefined ? { ...acc, [key]: data[key] } : acc), {})
18
+
5
19
  export default function (request) {
6
20
  const { sentry } = request.config
7
21
  return createMachine(
@@ -72,11 +86,26 @@ export default function (request) {
72
86
  return { fc }
73
87
  }),
74
88
  setSignUpId: assign((context, event) => {
75
- const { email, username, nick_name, password, countryCode, phone, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } =
76
- event.data
89
+ const {
90
+ email,
91
+ username,
92
+ nick_name,
93
+ password,
94
+ countryCode,
95
+ phone,
96
+ bankCode,
97
+ bankAccount,
98
+ holderName,
99
+ branch,
100
+ branchCode,
101
+ affiliateCode,
102
+ birthday,
103
+ } = event.data
77
104
  return {
78
105
  signUpData: {
79
106
  provider: 'local',
107
+ birthday,
108
+ ...pickBindData(event.data),
80
109
  email,
81
110
  username,
82
111
  nick_name,
@@ -93,10 +122,13 @@ export default function (request) {
93
122
  }
94
123
  }),
95
124
  setSignUpPhone: assign((context, event) => {
96
- const { email, countryCode, phone, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } = event.data
125
+ const { email, countryCode, phone, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode, birthday } =
126
+ event.data
97
127
  return {
98
128
  signUpData: {
99
129
  provider: 'phone',
130
+ birthday,
131
+ ...pickBindData(event.data),
100
132
  email,
101
133
  countryCode,
102
134
  phone,
@@ -112,10 +144,13 @@ export default function (request) {
112
144
  }
113
145
  }),
114
146
  setSignUpEmail: assign((context, event) => {
115
- const { email, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode, countryCode, phone } = event.data
147
+ const { email, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode, countryCode, phone, birthday } =
148
+ event.data
116
149
  return {
117
150
  signUpData: {
118
151
  provider: 'email',
152
+ birthday,
153
+ ...pickBindData(event.data),
119
154
  email,
120
155
  nick_name,
121
156
  password,
@@ -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()