@jetthai/cuora 1.0.101 → 1.0.103

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.0.103](https://github.com/jetthai/cuora-module/compare/v1.0.102...v1.0.103) (2022-03-17)
6
+
7
+ ### [1.0.102](https://github.com/jetthai/cuora-module/compare/v1.0.101...v1.0.102) (2022-03-17)
8
+
5
9
  ### [1.0.101](https://github.com/jetthai/cuora-module/compare/v1.0.100...v1.0.101) (2022-03-17)
6
10
 
7
11
  ### [1.0.100](https://github.com/jetthai/cuora-module/compare/v1.0.99...v1.0.100) (2022-03-10)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.101",
3
+ "version": "1.0.103",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -1,10 +1,7 @@
1
1
  import urljoin from 'url-join'
2
2
  import Cookies from 'universal-cookie'
3
3
  import qs from 'qs'
4
- import omitBy from 'lodash/omitBy'
5
- import isNull from 'lodash/isNull'
6
- import isUndefined from 'lodash/isUndefined'
7
- import { assign, createMachine, send } from 'xstate'
4
+ import { assign, createMachine } from 'xstate'
8
5
  import auth from '../api/auth'
9
6
  import user from '../api/user'
10
7
  import { getDeviceToken } from '../util/deviceToken'
@@ -252,17 +249,14 @@ export default function (request) {
252
249
  redirectTo3Party: async (context, event) => {
253
250
  const { provider, channel, subchannel } = event.data
254
251
  const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
255
- const redirectParams = omitBy(omitBy({ channel, subchannel }, isUndefined), isNull)
256
- const query = new URLSearchParams(redirectParams).toString()
257
- const redirectURI = urljoin(`${window.location.protocol}//${window.location.host}`, query ? `?${query}` : '')
258
252
  const redirectURL = urljoin(
259
253
  request.config.fullURL,
260
254
  'login?' +
261
255
  qs.stringify({
262
256
  provider,
263
- redirectURI,
264
- channel: channel || 'official',
265
- subchannel: subchannel || 'pwa',
257
+ redirectURI: `${window.location.protocol}//${window.location.host}`,
258
+ channel: cookies.get('channel') || channel || 'official',
259
+ subchannel: cookies.get('subchannel') || subchannel || 'pwa',
266
260
  dt,
267
261
  platform: 'pwa',
268
262
  })
@@ -1,6 +1,8 @@
1
1
  import UAParser from 'ua-parser-js'
2
+ import Cookies from 'universal-cookie'
2
3
  import { assign, createMachine } from 'xstate'
3
4
  import api from '../api/common'
5
+ const cookies = new Cookies()
4
6
 
5
7
  export default function (request) {
6
8
  const { appSecret } = request.config
@@ -45,7 +47,7 @@ export default function (request) {
45
47
  },
46
48
  },
47
49
  fetching: {
48
- entry: 'setUA',
50
+ entry: ['setUA', 'setAgent'],
49
51
  invoke: {
50
52
  src: 'fetchSiteConfig',
51
53
  onDone: {
@@ -136,6 +138,22 @@ export default function (request) {
136
138
  isMobile: userAgent?.device?.type,
137
139
  }
138
140
  }),
141
+ setAgent: (context, event) => {
142
+ let urlParams = new URLSearchParams(window.location.search)
143
+ const channel = urlParams.get('channel')
144
+ const subchannel = urlParams.get('subchannel')
145
+
146
+ if (channel && subchannel) {
147
+ cookies.set('channel', channel, {
148
+ path: '/',
149
+ maxAge: 60 * 60 * 24 * 7,
150
+ })
151
+ cookies.set('subchannel', subchannel, {
152
+ path: '/',
153
+ maxAge: 60 * 60 * 24 * 7,
154
+ })
155
+ }
156
+ },
139
157
  setFeeds: assign((context, event) => {
140
158
  const { announcementList, broadcastList, mailBoxInfo } = event.data
141
159
  const promotions = announcementList?.announcements?.filter?.((item) => item.category === 3) || []
@@ -1,6 +1,8 @@
1
1
  import { createMachine, assign } from 'xstate'
2
+ import Cookies from 'universal-cookie'
2
3
  import auth from '../api/auth'
3
4
  import { getDeviceToken } from '../util/deviceToken'
5
+ const cookies = new Cookies()
4
6
 
5
7
  export default function (request) {
6
8
  const { fpToken, sentry } = request.config
@@ -92,7 +94,16 @@ export default function (request) {
92
94
  signUp: async (context, event) => {
93
95
  const { email, password, channel, subchannel } = context
94
96
  const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
95
- return await request.send(auth.register({ provider: 'email', email, password, channel, subchannel, dt }))
97
+ return await request.send(
98
+ auth.register({
99
+ provider: 'email',
100
+ email,
101
+ password,
102
+ channel: cookies.get('channel') || channel,
103
+ subchannel: cookies.get('subchannel') || subchannel,
104
+ dt,
105
+ })
106
+ )
96
107
  },
97
108
  },
98
109
  }
@@ -289,8 +289,9 @@ export default function (request) {
289
289
  submitWithdraw: async (context, event) => {
290
290
  const { amount, applyerBankCode, applyerAccountNumber, branch, holderName } = event.data
291
291
  const { method } = context.paymentDetail[0]
292
+ const branchTemp = branch === 'BLANK' ? '' : branch
292
293
  return await request.send(
293
- payment.submitWithdrawTransactionVN({ method, amount, applyerBankCode, applyerAccountNumber, branch, holderName })
294
+ payment.submitWithdrawTransactionVN({ method, amount, applyerBankCode, applyerAccountNumber, branch: branchTemp, holderName })
294
295
  )
295
296
  },
296
297
  submitWithdrawFree: async (context, event) => {