@solucx/react-native-solucx-widget 0.2.3 → 0.2.4
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/README.intern.md +0 -23
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/lib/services/widgetBootstrapService.d.ts +1 -0
- package/lib/services/widgetBootstrapService.d.ts.map +1 -1
- package/lib/services/widgetBootstrapService.js +2 -1
- package/lib/services/widgetBootstrapService.js.map +1 -1
- package/package.json +4 -1
- package/src/__tests__/e2e/widget-lifecycle.test.tsx +0 -4
- package/src/__tests__/integration/webview-communication-simple.test.tsx +0 -4
- package/src/__tests__/integration/webview-communication.test.tsx +0 -4
- package/src/index.ts +0 -1
- package/src/services/widgetBootstrapService.ts +1 -0
- package/lib/utils/urlUtils.d.ts +0 -3
- package/lib/utils/urlUtils.d.ts.map +0 -1
- package/lib/utils/urlUtils.js +0 -13
- package/lib/utils/urlUtils.js.map +0 -1
- package/src/__tests__/urlUtils.test.ts +0 -56
- package/src/utils/urlUtils.ts +0 -13
package/README.intern.md
CHANGED
|
@@ -259,25 +259,6 @@ export const getWidgetStyles = (type: WidgetType) => {
|
|
|
259
259
|
- **Modal**: Overlay com background semitransparente
|
|
260
260
|
- **Inline**: Integrado ao fluxo normal do layout
|
|
261
261
|
|
|
262
|
-
## 🔧 Utilitários
|
|
263
|
-
|
|
264
|
-
### Construção de URLs
|
|
265
|
-
|
|
266
|
-
O [`urlUtils.ts`](src/utils/urlUtils.ts) gerencia a construção de URLs da pesquisa:
|
|
267
|
-
|
|
268
|
-
```typescript
|
|
269
|
-
export function buildWidgetURL(key: string, data: WidgetData): string {
|
|
270
|
-
const params = new URLSearchParams(data as Record<string, string>);
|
|
271
|
-
const baseURL = `${BASE_URL}/${key}/?mode=widget`;
|
|
272
|
-
|
|
273
|
-
if (data.transaction_id) {
|
|
274
|
-
return `${baseURL}&${params.toString()}`;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return `${baseURL}&transaction_id=&${params.toString()}`;
|
|
278
|
-
}
|
|
279
|
-
```
|
|
280
|
-
|
|
281
262
|
## 🧪 Testes
|
|
282
263
|
|
|
283
264
|
### Executando Testes
|
|
@@ -477,10 +458,6 @@ console.log('Widget event received:', processedKey, value);
|
|
|
477
458
|
// Verificar dados persistidos
|
|
478
459
|
const data = await storageService.read();
|
|
479
460
|
console.log('Stored data:', data);
|
|
480
|
-
|
|
481
|
-
// Verificar URL construída
|
|
482
|
-
const url = buildWidgetURL(soluCXKey, data);
|
|
483
|
-
console.log('Widget URL:', url);
|
|
484
461
|
```
|
|
485
462
|
|
|
486
463
|
## 📚 Dependências
|
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export { WidgetEventService } from './services/widgetEventService';
|
|
|
4
4
|
export { StorageService } from './services/storage';
|
|
5
5
|
export { getDeviceInfo, type DeviceInfo } from './hooks/useDeviceInfoCollector';
|
|
6
6
|
export { requestWidgetUrl } from './services/widgetBootstrapService';
|
|
7
|
-
export { buildWidgetURL } from './utils/urlUtils';
|
|
8
7
|
export { ModalWidget } from './components/ModalWidget';
|
|
9
8
|
export { getWidgetStyles, styles } from './styles/widgetStyles';
|
|
10
9
|
export { SDK_NAME, SDK_VERSION } from './constants/Constants';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,cAAc,cAAc,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getClientVersion = exports.SDK_VERSION = exports.SDK_NAME = exports.styles = exports.getWidgetStyles = exports.ModalWidget = exports.
|
|
17
|
+
exports.getClientVersion = exports.SDK_VERSION = exports.SDK_NAME = exports.styles = exports.getWidgetStyles = exports.ModalWidget = exports.requestWidgetUrl = exports.getDeviceInfo = exports.StorageService = exports.WidgetEventService = exports.useWidgetState = exports.SoluCXWidget = void 0;
|
|
18
18
|
var SoluCXWidget_1 = require("./SoluCXWidget");
|
|
19
19
|
Object.defineProperty(exports, "SoluCXWidget", { enumerable: true, get: function () { return SoluCXWidget_1.SoluCXWidget; } });
|
|
20
20
|
var useWidgetState_1 = require("./hooks/useWidgetState");
|
|
@@ -27,8 +27,6 @@ var useDeviceInfoCollector_1 = require("./hooks/useDeviceInfoCollector");
|
|
|
27
27
|
Object.defineProperty(exports, "getDeviceInfo", { enumerable: true, get: function () { return useDeviceInfoCollector_1.getDeviceInfo; } });
|
|
28
28
|
var widgetBootstrapService_1 = require("./services/widgetBootstrapService");
|
|
29
29
|
Object.defineProperty(exports, "requestWidgetUrl", { enumerable: true, get: function () { return widgetBootstrapService_1.requestWidgetUrl; } });
|
|
30
|
-
var urlUtils_1 = require("./utils/urlUtils");
|
|
31
|
-
Object.defineProperty(exports, "buildWidgetURL", { enumerable: true, get: function () { return urlUtils_1.buildWidgetURL; } });
|
|
32
30
|
var ModalWidget_1 = require("./components/ModalWidget");
|
|
33
31
|
Object.defineProperty(exports, "ModalWidget", { enumerable: true, get: function () { return ModalWidget_1.ModalWidget; } });
|
|
34
32
|
var widgetStyles_1 = require("./styles/widgetStyles");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,yDAAwD;AAA/C,gHAAA,cAAc,OAAA;AACvB,oEAAmE;AAA1D,wHAAA,kBAAkB,OAAA;AAC3B,8CAAoD;AAA3C,yGAAA,cAAc,OAAA;AACvB,yEAAgF;AAAvE,uHAAA,aAAa,OAAA;AACtB,4EAAqE;AAA5D,0HAAA,gBAAgB,OAAA;AACzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,yDAAwD;AAA/C,gHAAA,cAAc,OAAA;AACvB,oEAAmE;AAA1D,wHAAA,kBAAkB,OAAA;AAC3B,8CAAoD;AAA3C,yGAAA,cAAc,OAAA;AACvB,yEAAgF;AAAvE,uHAAA,aAAa,OAAA;AACtB,4EAAqE;AAA5D,0HAAA,gBAAgB,OAAA;AACzB,wDAAuD;AAA9C,0GAAA,WAAW,OAAA;AACpB,sDAAgE;AAAvD,+GAAA,eAAe,OAAA;AAAE,sGAAA,MAAM,OAAA;AAChC,mDAA8D;AAArD,qGAAA,QAAQ,OAAA;AAAE,wGAAA,WAAW,OAAA;AAC9B,4EAAqE;AAA5D,0HAAA,gBAAgB,OAAA;AACzB,+CAA6B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SoluCXKey, WidgetData } from "../interfaces";
|
|
2
|
+
import { URLSearchParams } from 'react-native-url-polyfill';
|
|
2
3
|
declare const buildRequestParams: (requestParams: WidgetData) => URLSearchParams;
|
|
3
4
|
export declare function requestWidgetUrl(instanceKey: SoluCXKey, requestParams: WidgetData, userId: string): Promise<string>;
|
|
4
5
|
export { buildRequestParams };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widgetBootstrapService.d.ts","sourceRoot":"","sources":["../../src/services/widgetBootstrapService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"widgetBootstrapService.d.ts","sourceRoot":"","sources":["../../src/services/widgetBootstrapService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAM5D,QAAA,MAAM,kBAAkB,GAAI,eAAe,UAAU,KAAG,eAYvD,CAAC;AA0BF,wBAAsB,gBAAgB,CAClC,WAAW,EAAE,SAAS,EACtB,aAAa,EAAE,UAAU,EACzB,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAsBjB;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -6,8 +6,9 @@ const webViewConstants_1 = require("../constants/webViewConstants");
|
|
|
6
6
|
const ClientVersionCollector_1 = require("../services/ClientVersionCollector");
|
|
7
7
|
const useDeviceInfoCollector_1 = require("../hooks/useDeviceInfoCollector");
|
|
8
8
|
const Constants_1 = require("../constants/Constants");
|
|
9
|
+
const react_native_url_polyfill_1 = require("react-native-url-polyfill");
|
|
9
10
|
const buildRequestParams = (requestParams) => {
|
|
10
|
-
const params = new URLSearchParams();
|
|
11
|
+
const params = new react_native_url_polyfill_1.URLSearchParams();
|
|
11
12
|
Object.entries(requestParams).forEach(([key, value]) => {
|
|
12
13
|
if (value === undefined || value === null)
|
|
13
14
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widgetBootstrapService.js","sourceRoot":"","sources":["../../src/services/widgetBootstrapService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"widgetBootstrapService.js","sourceRoot":"","sources":["../../src/services/widgetBootstrapService.ts"],"names":[],"mappings":";;;AAiDA,4CA0BC;AA1ED,oEAAqE;AACrE,+EAAsE;AACtE,4EAAgE;AAChE,sDAA+D;AAC/D,yEAA4D;AAM5D,MAAM,kBAAkB,GAAG,CAAC,aAAyB,EAAmB,EAAE;IACtE,MAAM,MAAM,GAAG,IAAI,2CAAe,EAAE,CAAC;IAErC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACnD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO;QAClD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,C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",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"src/",
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"react-native-url-polyfill": "^2.0.0"
|
|
21
|
+
},
|
|
19
22
|
"peerDependencies": {
|
|
20
23
|
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
21
24
|
"react": ">=18.0.0",
|
|
@@ -53,10 +53,6 @@ jest.mock('react-native-webview', () => {
|
|
|
53
53
|
};
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
jest.mock('../../utils/urlUtils', () => ({
|
|
57
|
-
buildWidgetURL: jest.fn().mockReturnValue('https://widget.solucx.com/form/123'),
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
56
|
jest.mock('../../services/widgetBootstrapService', () => ({
|
|
61
57
|
requestWidgetUrl: jest.fn().mockResolvedValue('https://widget.solucx.com/survey/456'),
|
|
62
58
|
}));
|
|
@@ -27,10 +27,6 @@ jest.mock('react-native-webview', () => {
|
|
|
27
27
|
};
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
jest.mock('../../utils/urlUtils', () => ({
|
|
31
|
-
buildWidgetURL: jest.fn().mockReturnValue('https://form.url/test'),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
30
|
jest.mock('../../services/widgetBootstrapService', () => ({
|
|
35
31
|
requestWidgetUrl: jest.fn().mockResolvedValue('https://survey.url/test'),
|
|
36
32
|
}));
|
|
@@ -44,10 +44,6 @@ jest.mock('../../services/widgetBootstrapService', () => ({
|
|
|
44
44
|
requestWidgetUrl: jest.fn().mockResolvedValue('https://mock.widget.url/form123'),
|
|
45
45
|
}));
|
|
46
46
|
|
|
47
|
-
jest.mock('../../utils/urlUtils', () => ({
|
|
48
|
-
buildWidgetURL: jest.fn().mockReturnValue('https://mock.widget.url/form123'),
|
|
49
|
-
}));
|
|
50
|
-
|
|
51
47
|
jest.mock('../../services/widgetValidationService', () => ({
|
|
52
48
|
WidgetValidationService: jest.fn().mockImplementation(() => ({
|
|
53
49
|
shouldDisplayWidget: jest.fn().mockResolvedValue({ canDisplay: true }),
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,6 @@ export { WidgetEventService } from './services/widgetEventService';
|
|
|
4
4
|
export { StorageService } from './services/storage';
|
|
5
5
|
export { getDeviceInfo, type DeviceInfo } from './hooks/useDeviceInfoCollector';
|
|
6
6
|
export { requestWidgetUrl } from './services/widgetBootstrapService';
|
|
7
|
-
export { buildWidgetURL } from './utils/urlUtils';
|
|
8
7
|
export { ModalWidget } from './components/ModalWidget';
|
|
9
8
|
export { getWidgetStyles, styles } from './styles/widgetStyles';
|
|
10
9
|
export { SDK_NAME, SDK_VERSION } from './constants/Constants';
|
|
@@ -3,6 +3,7 @@ import { RATING_FORM_ENDPOINT } from "../constants/webViewConstants";
|
|
|
3
3
|
import { getClientVersion } from "../services/ClientVersionCollector";
|
|
4
4
|
import { getDeviceInfo } from "../hooks/useDeviceInfoCollector";
|
|
5
5
|
import { SDK_NAME, SDK_VERSION } from "../constants/Constants";
|
|
6
|
+
import { URLSearchParams } from 'react-native-url-polyfill';
|
|
6
7
|
|
|
7
8
|
type Payload = {
|
|
8
9
|
url: string;
|
package/lib/utils/urlUtils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../../src/utils/urlUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE3D,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CASvE"}
|
package/lib/utils/urlUtils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildWidgetURL = buildWidgetURL;
|
|
4
|
-
const webViewConstants_1 = require("../constants/webViewConstants");
|
|
5
|
-
function buildWidgetURL(key, data) {
|
|
6
|
-
const params = new URLSearchParams(data);
|
|
7
|
-
const baseURL = `${webViewConstants_1.BASE_URL}/${key}/?mode=widget`;
|
|
8
|
-
if (data.transaction_id) {
|
|
9
|
-
return `${baseURL}&${params.toString()}`;
|
|
10
|
-
}
|
|
11
|
-
return `${baseURL}&transaction_id=&${params.toString()}`;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=urlUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../../src/utils/urlUtils.ts"],"names":[],"mappings":";;AAGA,wCASC;AAZD,oEAAyD;AAGzD,SAAgB,cAAc,CAAC,GAAc,EAAE,IAAgB;IAC3D,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,IAA8B,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,GAAG,2BAAQ,IAAI,GAAG,eAAe,CAAC;IAElD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,OAAO,GAAG,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC7C,CAAC;IAED,OAAO,GAAG,OAAO,oBAAoB,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { buildWidgetURL } from '../utils/urlUtils';
|
|
2
|
-
|
|
3
|
-
describe('urlUtils', () => {
|
|
4
|
-
describe('buildWidgetURL', () => {
|
|
5
|
-
const mockKey = 'test-widget-key';
|
|
6
|
-
|
|
7
|
-
it('should build URL with transaction_id when provided', () => {
|
|
8
|
-
const data = {
|
|
9
|
-
customer_id: 'customer123',
|
|
10
|
-
form_id: 'form456',
|
|
11
|
-
transaction_id: 'trans789'
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const result = buildWidgetURL(mockKey, data);
|
|
15
|
-
|
|
16
|
-
expect(result).toContain('https://survey-link.solucx.com.br/link/test-widget-key/?mode=widget');
|
|
17
|
-
expect(result).toContain('customer_id=customer123');
|
|
18
|
-
expect(result).toContain('form_id=form456');
|
|
19
|
-
expect(result).toContain('transaction_id=trans789');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should build URL with empty transaction_id when not provided', () => {
|
|
23
|
-
const data = {
|
|
24
|
-
customer_id: 'customer123',
|
|
25
|
-
form_id: 'form456'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const result = buildWidgetURL(mockKey, data);
|
|
29
|
-
|
|
30
|
-
expect(result).toContain('https://survey-link.solucx.com.br/link/test-widget-key/?mode=widget');
|
|
31
|
-
expect(result).toContain('transaction_id=&');
|
|
32
|
-
expect(result).toContain('customer_id=customer123');
|
|
33
|
-
expect(result).toContain('form_id=form456');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should handle empty data object', () => {
|
|
37
|
-
const data = {};
|
|
38
|
-
|
|
39
|
-
const result = buildWidgetURL(mockKey, data);
|
|
40
|
-
|
|
41
|
-
expect(result).toBe('https://survey-link.solucx.com.br/link/test-widget-key/?mode=widget&transaction_id=&');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should encode URL parameters correctly', () => {
|
|
45
|
-
const data = {
|
|
46
|
-
email: 'test@example.com',
|
|
47
|
-
name: 'John Doe'
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const result = buildWidgetURL(mockKey, data);
|
|
51
|
-
|
|
52
|
-
expect(result).toContain('email=test%40example.com');
|
|
53
|
-
expect(result).toContain('name=John+Doe');
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
});
|
package/src/utils/urlUtils.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BASE_URL } from "../constants/webViewConstants";
|
|
2
|
-
import type { WidgetData, SoluCXKey } from "../interfaces";
|
|
3
|
-
|
|
4
|
-
export function buildWidgetURL(key: SoluCXKey, data: WidgetData): string {
|
|
5
|
-
const params = new URLSearchParams(data as Record<string, string>);
|
|
6
|
-
const baseURL = `${BASE_URL}/${key}/?mode=widget`;
|
|
7
|
-
|
|
8
|
-
if (data.transaction_id) {
|
|
9
|
-
return `${baseURL}&${params.toString()}`;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return `${baseURL}&transaction_id=&${params.toString()}`;
|
|
13
|
-
}
|