@jetthai/cuora 1.0.133 → 1.0.135

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.135](https://github.com/jetthai/cuora-module/compare/v1.0.134...v1.0.135) (2022-06-16)
6
+
7
+ ### [1.0.134](https://github.com/jetthai/cuora-module/compare/v1.0.133...v1.0.134) (2022-06-13)
8
+
5
9
  ### [1.0.133](https://github.com/jetthai/cuora-module/compare/v1.0.132...v1.0.133) (2022-06-13)
6
10
 
7
11
  ### [1.0.132](https://github.com/jetthai/cuora-module/compare/v1.0.131...v1.0.132) (2022-06-08)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.133",
3
+ "version": "1.0.135",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -6,7 +6,7 @@ import api from '../api/common'
6
6
  const cookies = new Cookies()
7
7
 
8
8
  export default function (request) {
9
- const { appSecret } = request.config
9
+ const { appSecret, defaultChannel, defaultSubchannel } = request.config
10
10
  return createMachine(
11
11
  {
12
12
  id: 'common',
@@ -37,6 +37,8 @@ export default function (request) {
37
37
  normalBroadcast: null,
38
38
  sentEmergencyBroadcastList: [],
39
39
  sentNormalBroadcastList: [],
40
+ channel: null,
41
+ subchannel: null,
40
42
  },
41
43
  states: {
42
44
  config: {
@@ -144,22 +146,25 @@ export default function (request) {
144
146
  isMobile: userAgent?.device?.type,
145
147
  }
146
148
  }),
147
- setAgent: (context, event) => {
149
+ setAgent: assign((context, event) => {
148
150
  let urlParams = new URLSearchParams(window.location.search)
149
- const channel = urlParams.get('channel')
150
- const subchannel = urlParams.get('subchannel')
151
+ const channel = urlParams.get('channel') || cookies.get('channel') || defaultChannel || 'official'
152
+ const subchannel = urlParams.get('subchannel') || cookies.get('subchannel') || defaultSubchannel || 'pwa'
151
153
 
152
- if (channel && subchannel) {
153
- cookies.set('channel', channel, {
154
- path: '/',
155
- maxAge: 60 * 60 * 24 * 7,
156
- })
157
- cookies.set('subchannel', subchannel, {
158
- path: '/',
159
- maxAge: 60 * 60 * 24 * 7,
160
- })
154
+ cookies.set('channel', channel, {
155
+ path: '/',
156
+ maxAge: 60 * 60 * 24 * 7,
157
+ })
158
+ cookies.set('subchannel', subchannel, {
159
+ path: '/',
160
+ maxAge: 60 * 60 * 24 * 7,
161
+ })
162
+
163
+ return {
164
+ channel,
165
+ subchannel,
161
166
  }
162
- },
167
+ }),
163
168
  setFeeds: assign((context, event) => {
164
169
  const { announcementList, broadcastList, mailBoxInfo } = event.data
165
170
  const promotions = announcementList?.announcements?.filter?.((item) => item.category === 3) || []
@@ -8,9 +8,9 @@ export default function (request) {
8
8
  initial: 'loading',
9
9
  context: {
10
10
  cards: [
11
- { name: 'mobifone', code: 'VMS' },
12
- { name: 'viettel', code: 'VTT' },
13
- { name: 'vinaphone', code: 'VNP' },
11
+ { name: 'mobifone', code: 'VMS', category: 'loadcard', methodDescription: 'MOBIFONE' },
12
+ { name: 'viettel', code: 'VTT', category: 'loadcard', methodDescription: 'VIETTEL' },
13
+ { name: 'vinaphone', code: 'VNP', category: 'loadcard', methodDescription: 'VINAPHONE' },
14
14
  // { name: 'vietnam mobile', code: 'VNM' },
15
15
  // { name: 'thẻ zing', code: 'ZING' },
16
16
  // { name: 'thẻ gate', code: 'GATE' },
@@ -1,7 +1,7 @@
1
1
  import urljoin from 'url-join'
2
2
 
3
3
  export default class Config {
4
- constructor({ apiURL, apiVersion, clientId, appSecret, platform, version, fpToken, sentry }) {
4
+ constructor({ apiURL, apiVersion, clientId, appSecret, platform, version, fpToken, sentry, defaultChannel, defaultSubchannel }) {
5
5
  this.apiURL = apiURL
6
6
  this.apiVersion = apiVersion
7
7
  this.clientId = clientId
@@ -11,6 +11,8 @@ export default class Config {
11
11
  this.fullURL = urljoin(this.apiURL, this.apiVersion, this.clientId)
12
12
  this.fpToken = fpToken // fingerprintjs token
13
13
  this.sentry = sentry
14
+ this.defaultChannel = defaultChannel
15
+ this.defaultSubchannel = defaultSubchannel
14
16
  }
15
17
 
16
18
  setApiURL(url) {