@solucx/react-native-solucx-widget 0.1.15 → 0.1.16

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,24 +1,24 @@
1
- export type SoluCXKey = string;
2
- export type WidgetType = "bottom" | "top" | "inline" | "modal";
3
- export type EventKey =
4
- | "FORM_OPENED"
5
- | "FORM_CLOSE"
6
- | "FORM_ERROR"
7
- | "FORM_PAGECHANGED"
8
- | "QUESTION_ANSWERED"
9
- | "FORM_COMPLETED"
10
- | "FORM_PARTIALCOMPLETED"
11
- | "FORM_RESIZE";
12
- export type SurveyEventKey =
13
- | "closeSoluCXWidget"
14
- | "dismissSoluCXWidget"
15
- | "completeSoluCXWidget"
16
- | "partialSoluCXWidget"
17
- | "resizeSoluCXWidget"
18
- | "openSoluCXWidget"
19
- | `errorSoluCXWidget`;
20
- export type { WidgetResponse } from './WidgetResponse';
21
- export type { WidgetData } from './WidgetData';
22
- export type { WidgetOptions } from './WidgetOptions';
23
- export type { WidgetSamplerLog } from './WidgetSamplerLog';
1
+ export type SoluCXKey = string;
2
+ export type WidgetType = "bottom" | "top" | "inline" | "modal";
3
+ export type EventKey =
4
+ | "FORM_OPENED"
5
+ | "FORM_CLOSE"
6
+ | "FORM_ERROR"
7
+ | "FORM_PAGECHANGED"
8
+ | "QUESTION_ANSWERED"
9
+ | "FORM_COMPLETED"
10
+ | "FORM_PARTIALCOMPLETED"
11
+ | "FORM_RESIZE";
12
+ export type SurveyEventKey =
13
+ | "closeSoluCXWidget"
14
+ | "dismissSoluCXWidget"
15
+ | "completeSoluCXWidget"
16
+ | "partialSoluCXWidget"
17
+ | "resizeSoluCXWidget"
18
+ | "openSoluCXWidget"
19
+ | `errorSoluCXWidget`;
20
+ export type { WidgetResponse } from './WidgetResponse';
21
+ export type { WidgetData } from './WidgetData';
22
+ export type { WidgetOptions } from './WidgetOptions';
23
+ export type { WidgetSamplerLog } from './WidgetSamplerLog';
24
24
  export type { WidgetError } from './WidgetResponse';
@@ -1,21 +1,21 @@
1
- import AsyncStorage from '@react-native-async-storage/async-storage';
2
- import { WidgetSamplerLog } from '../interfaces';
3
- import { STORAGE_KEY } from '../constants/webViewConstants';
4
-
5
- export class StorageService {
6
- private key: string;
7
-
8
- constructor(key: string) {
9
- this.key = `${STORAGE_KEY}_${key}`;
10
- }
11
-
12
- async write(data: WidgetSamplerLog): Promise<void> {
13
- const json = JSON.stringify(data);
14
- await AsyncStorage.setItem(this.key, json);
15
- }
16
-
17
- async read(): Promise<WidgetSamplerLog> {
18
- const json = await AsyncStorage.getItem(this.key);
19
- return json ? JSON.parse(json) as WidgetSamplerLog : {} as WidgetSamplerLog;
20
- }
1
+ import AsyncStorage from '@react-native-async-storage/async-storage';
2
+ import { WidgetSamplerLog } from '../interfaces';
3
+ import { STORAGE_KEY } from '../constants/webViewConstants';
4
+
5
+ export class StorageService {
6
+ private key: string;
7
+
8
+ constructor(key: string) {
9
+ this.key = `${STORAGE_KEY}_${key}`;
10
+ }
11
+
12
+ async write(data: WidgetSamplerLog): Promise<void> {
13
+ const json = JSON.stringify(data);
14
+ await AsyncStorage.setItem(this.key, json);
15
+ }
16
+
17
+ async read(): Promise<WidgetSamplerLog> {
18
+ const json = await AsyncStorage.getItem(this.key);
19
+ return json ? JSON.parse(json) as WidgetSamplerLog : {} as WidgetSamplerLog;
20
+ }
21
21
  }
@@ -1,111 +1,126 @@
1
- import { EventKey, SurveyEventKey, WidgetResponse, WidgetOptions } from '../interfaces';
2
- import { WidgetValidationService } from './widgetValidationService';
3
-
4
- export class WidgetEventService {
5
- private setIsWidgetVisible: (visible: boolean) => void;
6
- private resize: (value: string) => void;
7
- private open: () => void;
8
- private validationService: WidgetValidationService;
9
- private widgetOptions: WidgetOptions;
10
-
11
- constructor(
12
- setIsWidgetVisible: (visible: boolean) => void,
13
- resize: (value: string) => void,
14
- open: () => void,
15
- userId: string,
16
- widgetOptions: WidgetOptions
17
- ) {
18
- this.setIsWidgetVisible = setIsWidgetVisible;
19
- this.resize = resize;
20
- this.open = open;
21
- this.validationService = new WidgetValidationService(userId);
22
- this.widgetOptions = widgetOptions;
23
- }
24
-
25
- async handleMessage(message: string, isForm: boolean): Promise<WidgetResponse> {
26
- const [eventKey, value = ""] = message.split("-");
27
- const processedKey = isForm
28
- ? eventKey as EventKey
29
- : this.adaptSurveyKeyToWidgetKey(eventKey as SurveyEventKey);
30
-
31
- return await this.executeEvent(processedKey, value);
32
- }
33
-
34
- private async executeEvent(eventKey: EventKey, value: string): Promise<WidgetResponse> {
35
- const eventHandlers = {
36
- FORM_OPENED: () => this.handleFormOpened(),
37
- FORM_CLOSE: () => this.handleFormClose(),
38
- FORM_ERROR: (value: string) => this.handleFormError(value),
39
- FORM_PAGECHANGED: (value: string) => this.handlePageChanged(value),
40
- QUESTION_ANSWERED: () => this.handleQuestionAnswered(),
41
- FORM_COMPLETED: () => this.handleFormCompleted(),
42
- FORM_PARTIALCOMPLETED: () => this.handlePartialCompleted(),
43
- FORM_RESIZE: (value: string) => this.handleResize(value),
44
- };
45
-
46
- const handler = eventHandlers[eventKey];
47
- return await (handler?.(value) || { status: "error", message: "Unknown event" });
48
- }
49
-
50
- private async handleFormOpened(): Promise<WidgetResponse> {
51
- const canDisplay = await this.validationService.shouldDisplayWidget(this.widgetOptions);
52
-
53
- if (!canDisplay) {
54
- return { status: "error", message: "Widget not allowed" };
55
- }
56
-
57
- this.open();
58
- this.setIsWidgetVisible(true);
59
- return { status: "success" };
60
- }
61
-
62
- private handleFormClose(): WidgetResponse {
63
- this.setIsWidgetVisible(false);
64
- return { status: "success" };
65
- }
66
-
67
- private handleFormError(value: string): WidgetResponse {
68
- this.setIsWidgetVisible(false);
69
- return { status: "error", message: value };
70
- }
71
-
72
- private handlePageChanged(value: string): WidgetResponse {
73
- console.log("Page changed:", value);
74
- return { status: "success" };
75
- }
76
-
77
- private handleQuestionAnswered(): WidgetResponse {
78
- console.log("Question answered");
79
- return { status: "success" };
80
- }
81
-
82
- private handleFormCompleted(): WidgetResponse {
83
- // TODO: Implement completion logic
84
- return { status: "success" };
85
- }
86
-
87
- private handlePartialCompleted(): WidgetResponse {
88
- // TODO: Implement partial completion logic
89
- return { status: "success" };
90
- }
91
-
92
- private handleResize(value: string): WidgetResponse {
93
- this.setIsWidgetVisible(true);
94
- this.resize(value);
95
- return { status: "success" };
96
- }
97
-
98
- private adaptSurveyKeyToWidgetKey(key: SurveyEventKey): EventKey {
99
- const keyMapping = {
100
- closeSoluCXWidget: "FORM_CLOSE",
101
- dismissSoluCXWidget: "FORM_CLOSE",
102
- completeSoluCXWidget: "FORM_COMPLETED",
103
- partialSoluCXWidget: "FORM_PARTIALCOMPLETED",
104
- resizeSoluCXWidget: "FORM_RESIZE",
105
- openSoluCXWidget: "FORM_OPENED",
106
- errorSoluCXWidget: "FORM_ERROR",
107
- } as const;
108
-
109
- return keyMapping[key] as EventKey;
110
- }
111
- }
1
+ import {
2
+ EventKey,
3
+ SurveyEventKey,
4
+ WidgetResponse,
5
+ WidgetOptions,
6
+ } from "../interfaces";
7
+ import { WidgetValidationService } from "./widgetValidationService";
8
+
9
+ export class WidgetEventService {
10
+ private setIsWidgetVisible: (visible: boolean) => void;
11
+ private resize: (value: string) => void;
12
+ private open: () => void;
13
+ private validationService: WidgetValidationService;
14
+ private widgetOptions: WidgetOptions;
15
+
16
+ constructor(
17
+ setIsWidgetVisible: (visible: boolean) => void,
18
+ resize: (value: string) => void,
19
+ open: () => void,
20
+ userId: string,
21
+ widgetOptions: WidgetOptions,
22
+ ) {
23
+ this.setIsWidgetVisible = setIsWidgetVisible;
24
+ this.resize = resize;
25
+ this.open = open;
26
+ this.validationService = new WidgetValidationService(userId);
27
+ this.widgetOptions = widgetOptions;
28
+ }
29
+
30
+ async handleMessage(
31
+ message: string,
32
+ isForm: boolean,
33
+ ): Promise<WidgetResponse> {
34
+ const [eventKey, value = ""] = message.split("-");
35
+ const processedKey = isForm
36
+ ? (eventKey as EventKey)
37
+ : this.adaptSurveyKeyToWidgetKey(eventKey as SurveyEventKey);
38
+
39
+ return await this.executeEvent(processedKey, value);
40
+ }
41
+
42
+ private async executeEvent(
43
+ eventKey: EventKey,
44
+ value: string,
45
+ ): Promise<WidgetResponse> {
46
+ const eventHandlers = {
47
+ FORM_OPENED: () => this.handleFormOpened(),
48
+ FORM_CLOSE: () => this.handleFormClose(),
49
+ FORM_ERROR: (value: string) => this.handleFormError(value),
50
+ FORM_PAGECHANGED: (value: string) => this.handlePageChanged(value),
51
+ QUESTION_ANSWERED: () => this.handleQuestionAnswered(),
52
+ FORM_COMPLETED: () => this.handleFormCompleted(),
53
+ FORM_PARTIALCOMPLETED: () => this.handlePartialCompleted(),
54
+ FORM_RESIZE: (value: string) => this.handleResize(value),
55
+ };
56
+
57
+ const handler = eventHandlers[eventKey];
58
+ return await (handler?.(value) || {
59
+ status: "error",
60
+ message: "Unknown event",
61
+ });
62
+ }
63
+
64
+ private async handleFormOpened(): Promise<WidgetResponse> {
65
+ const canDisplay = await this.validationService.shouldDisplayWidget(
66
+ this.widgetOptions,
67
+ );
68
+
69
+ if (!canDisplay) {
70
+ return { status: "error", message: "Widget not allowed" };
71
+ }
72
+
73
+ this.open();
74
+ this.setIsWidgetVisible(true);
75
+ return { status: "success" };
76
+ }
77
+
78
+ private handleFormClose(): WidgetResponse {
79
+ this.setIsWidgetVisible(false);
80
+ return { status: "success" };
81
+ }
82
+
83
+ private handleFormError(value: string): WidgetResponse {
84
+ this.setIsWidgetVisible(false);
85
+ return { status: "error", message: value };
86
+ }
87
+
88
+ private handlePageChanged(value: string): WidgetResponse {
89
+ console.log("Page changed:", value);
90
+ return { status: "success" };
91
+ }
92
+
93
+ private handleQuestionAnswered(): WidgetResponse {
94
+ console.log("Question answered");
95
+ return { status: "success" };
96
+ }
97
+
98
+ private handleFormCompleted(): WidgetResponse {
99
+ // TODO: Implement completion logic
100
+ return { status: "success" };
101
+ }
102
+
103
+ private handlePartialCompleted(): WidgetResponse {
104
+ // TODO: Implement partial completion logic
105
+ return { status: "success" };
106
+ }
107
+
108
+ private handleResize(value: string): WidgetResponse {
109
+ this.resize(value);
110
+ return { status: "success" };
111
+ }
112
+
113
+ private adaptSurveyKeyToWidgetKey(key: SurveyEventKey): EventKey {
114
+ const keyMapping = {
115
+ closeSoluCXWidget: "FORM_CLOSE",
116
+ dismissSoluCXWidget: "FORM_CLOSE",
117
+ completeSoluCXWidget: "FORM_COMPLETED",
118
+ partialSoluCXWidget: "FORM_PARTIALCOMPLETED",
119
+ resizeSoluCXWidget: "FORM_RESIZE",
120
+ openSoluCXWidget: "FORM_OPENED",
121
+ errorSoluCXWidget: "FORM_ERROR",
122
+ } as const;
123
+
124
+ return keyMapping[key] as EventKey;
125
+ }
126
+ }
@@ -1,86 +1,86 @@
1
- import { WidgetOptions, WidgetSamplerLog } from '../interfaces';
2
- import { StorageService } from './storage';
3
-
4
- export class WidgetValidationService {
5
- private storageService: StorageService;
6
-
7
- constructor(userId: string) {
8
- this.storageService = new StorageService(userId);
9
- }
10
-
11
- async shouldDisplayWidget(widgetOptions: WidgetOptions): Promise<boolean> {
12
- const { retry, waitDelayAfterRating = 60 } = widgetOptions;
13
- const { attempts = 5, interval = 1 } = retry || {};
14
- const userLog = await this.getLog();
15
- const now = Date.now();
16
- const dayInMilliseconds = 86400000;
17
-
18
- if (this.isWithinCollectInterval(userLog, waitDelayAfterRating, now, dayInMilliseconds)) return false;
19
- if (this.isWithinCollectPartialInterval(userLog, waitDelayAfterRating, now, dayInMilliseconds)) return false;
20
- if (this.isWithinRetryInterval(userLog, interval, attempts, now, dayInMilliseconds)) return false;
21
-
22
- await this.resetAttemptsIfNeeded(userLog, attempts);
23
- await this.setLog(userLog);
24
- return true;
25
- }
26
-
27
- private async getLog(): Promise<WidgetSamplerLog> {
28
- try {
29
- return await this.storageService.read();
30
- } catch (error) {
31
- console.error('Error reading widget log:', error);
32
- return {
33
- attempts: 0,
34
- lastAttempt: 0,
35
- lastRating: 0,
36
- lastParcial: 0
37
- };
38
- }
39
- }
40
-
41
- private async setLog(userLog: WidgetSamplerLog): Promise<void> {
42
- try {
43
- await this.storageService.write(userLog);
44
- } catch (error) {
45
- console.error('Error writing widget log:', error);
46
- }
47
- }
48
-
49
- private isWithinCollectInterval(
50
- userLog: WidgetSamplerLog,
51
- waitDelayAfterRating: number,
52
- now: number,
53
- dayInMilliseconds: number
54
- ): boolean {
55
- const timeSinceLastRating = now - userLog.lastRating;
56
- return userLog.lastRating > 0 && timeSinceLastRating < waitDelayAfterRating * dayInMilliseconds;
57
- }
58
-
59
- private isWithinCollectPartialInterval(
60
- userLog: WidgetSamplerLog,
61
- waitDelayAfterRating: number,
62
- now: number,
63
- dayInMilliseconds: number
64
- ): boolean {
65
- const timeSinceLastPartial = now - userLog.lastParcial;
66
- return userLog.lastParcial > 0 && timeSinceLastPartial < waitDelayAfterRating * dayInMilliseconds;
67
- }
68
-
69
- private isWithinRetryInterval(
70
- userLog: WidgetSamplerLog,
71
- interval: number,
72
- attempts: number,
73
- now: number,
74
- dayInMilliseconds: number
75
- ): boolean {
76
- if (userLog.attempts < attempts) return false;
77
- const timeSinceLastAttempt = now - userLog.lastAttempt;
78
- return timeSinceLastAttempt < interval * dayInMilliseconds;
79
- }
80
-
81
- private async resetAttemptsIfNeeded(userLog: WidgetSamplerLog, maxAttempts: number): Promise<void> {
82
- if (userLog.attempts >= maxAttempts) {
83
- userLog.attempts = 0;
84
- }
85
- }
86
- }
1
+ import { WidgetOptions, WidgetSamplerLog } from '../interfaces';
2
+ import { StorageService } from './storage';
3
+
4
+ export class WidgetValidationService {
5
+ private storageService: StorageService;
6
+
7
+ constructor(userId: string) {
8
+ this.storageService = new StorageService(userId);
9
+ }
10
+
11
+ async shouldDisplayWidget(widgetOptions: WidgetOptions): Promise<boolean> {
12
+ const { retry, waitDelayAfterRating = 60 } = widgetOptions;
13
+ const { attempts = 5, interval = 1 } = retry || {};
14
+ const userLog = await this.getLog();
15
+ const now = Date.now();
16
+ const dayInMilliseconds = 86400000;
17
+
18
+ if (this.isWithinCollectInterval(userLog, waitDelayAfterRating, now, dayInMilliseconds)) return false;
19
+ if (this.isWithinCollectPartialInterval(userLog, waitDelayAfterRating, now, dayInMilliseconds)) return false;
20
+ if (this.isWithinRetryInterval(userLog, interval, attempts, now, dayInMilliseconds)) return false;
21
+
22
+ await this.resetAttemptsIfNeeded(userLog, attempts);
23
+ await this.setLog(userLog);
24
+ return true;
25
+ }
26
+
27
+ private async getLog(): Promise<WidgetSamplerLog> {
28
+ try {
29
+ return await this.storageService.read();
30
+ } catch (error) {
31
+ console.error('Error reading widget log:', error);
32
+ return {
33
+ attempts: 0,
34
+ lastAttempt: 0,
35
+ lastRating: 0,
36
+ lastParcial: 0
37
+ };
38
+ }
39
+ }
40
+
41
+ private async setLog(userLog: WidgetSamplerLog): Promise<void> {
42
+ try {
43
+ await this.storageService.write(userLog);
44
+ } catch (error) {
45
+ console.error('Error writing widget log:', error);
46
+ }
47
+ }
48
+
49
+ private isWithinCollectInterval(
50
+ userLog: WidgetSamplerLog,
51
+ waitDelayAfterRating: number,
52
+ now: number,
53
+ dayInMilliseconds: number
54
+ ): boolean {
55
+ const timeSinceLastRating = now - userLog.lastRating;
56
+ return userLog.lastRating > 0 && timeSinceLastRating < waitDelayAfterRating * dayInMilliseconds;
57
+ }
58
+
59
+ private isWithinCollectPartialInterval(
60
+ userLog: WidgetSamplerLog,
61
+ waitDelayAfterRating: number,
62
+ now: number,
63
+ dayInMilliseconds: number
64
+ ): boolean {
65
+ const timeSinceLastPartial = now - userLog.lastParcial;
66
+ return userLog.lastParcial > 0 && timeSinceLastPartial < waitDelayAfterRating * dayInMilliseconds;
67
+ }
68
+
69
+ private isWithinRetryInterval(
70
+ userLog: WidgetSamplerLog,
71
+ interval: number,
72
+ attempts: number,
73
+ now: number,
74
+ dayInMilliseconds: number
75
+ ): boolean {
76
+ if (userLog.attempts < attempts) return false;
77
+ const timeSinceLastAttempt = now - userLog.lastAttempt;
78
+ return timeSinceLastAttempt < interval * dayInMilliseconds;
79
+ }
80
+
81
+ private async resetAttemptsIfNeeded(userLog: WidgetSamplerLog, maxAttempts: number): Promise<void> {
82
+ if (userLog.attempts >= maxAttempts) {
83
+ userLog.attempts = 0;
84
+ }
85
+ }
86
+ }
@@ -1,58 +1,58 @@
1
- import { StyleSheet } from 'react-native';
2
- import { WidgetType } from '../interfaces';
3
-
4
- export const styles = StyleSheet.create({
5
- wrapper: {
6
- flex: 1,
7
- justifyContent: 'center',
8
- alignItems: 'center',
9
- },
10
- inlineWrapper: {
11
- justifyContent: 'center',
12
- alignItems: 'center',
13
- },
14
- bottom: {
15
- position: 'absolute',
16
- bottom: 0,
17
- justifyContent: 'center',
18
- alignItems: 'center',
19
- },
20
- top: {
21
- position: 'absolute',
22
- top: 0,
23
- justifyContent: 'center',
24
- alignItems: 'center',
25
- },
26
- inline: {
27
- justifyContent: 'center',
28
- alignItems: 'center',
29
- },
30
- modalOverlay: {
31
- flex: 1,
32
- justifyContent: 'center',
33
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
34
- alignItems: 'center',
35
- },
36
- modalContent: {
37
- backgroundColor: 'white',
38
- borderRadius: 10,
39
- },
40
- });
41
-
42
- export const getWidgetVisibility = (visibility: boolean) => {
43
- return {
44
- opacity: visibility ? 1 : 0,
45
- pointerEvents: visibility ? 'auto' as const : 'none' as const,
46
- };
47
- };
48
-
49
- export const getWidgetStyles = (type: WidgetType) => {
50
- const styleMap = {
51
- 'bottom': { container: styles.wrapper, content: styles.bottom },
52
- 'top': { container: styles.wrapper, content: styles.top },
53
- 'inline': { container: styles.inlineWrapper, content: styles.inline },
54
- 'modal': { container: styles.wrapper, content: styles.inline }
55
- };
56
-
57
- return styleMap[type] || styleMap.bottom;
58
- };
1
+ import { StyleSheet } from 'react-native';
2
+ import { WidgetType } from '../interfaces';
3
+
4
+ export const styles = StyleSheet.create({
5
+ wrapper: {
6
+ flex: 1,
7
+ justifyContent: 'center',
8
+ alignItems: 'center',
9
+ },
10
+ inlineWrapper: {
11
+ justifyContent: 'center',
12
+ alignItems: 'center',
13
+ },
14
+ bottom: {
15
+ position: 'absolute',
16
+ bottom: 0,
17
+ justifyContent: 'center',
18
+ alignItems: 'center',
19
+ },
20
+ top: {
21
+ position: 'absolute',
22
+ top: 0,
23
+ justifyContent: 'center',
24
+ alignItems: 'center',
25
+ },
26
+ inline: {
27
+ justifyContent: 'center',
28
+ alignItems: 'center',
29
+ },
30
+ modalOverlay: {
31
+ flex: 1,
32
+ justifyContent: 'center',
33
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
34
+ alignItems: 'center',
35
+ },
36
+ modalContent: {
37
+ backgroundColor: 'white',
38
+ borderRadius: 10,
39
+ },
40
+ });
41
+
42
+ export const getWidgetVisibility = (visibility: boolean) => {
43
+ return {
44
+ opacity: visibility ? 1 : 0,
45
+ pointerEvents: visibility ? 'auto' as const : 'none' as const,
46
+ };
47
+ };
48
+
49
+ export const getWidgetStyles = (type: WidgetType) => {
50
+ const styleMap = {
51
+ 'bottom': { container: styles.wrapper, content: styles.bottom },
52
+ 'top': { container: styles.wrapper, content: styles.top },
53
+ 'inline': { container: styles.inlineWrapper, content: styles.inline },
54
+ 'modal': { container: styles.wrapper, content: styles.inline }
55
+ };
56
+
57
+ return styleMap[type] || styleMap.bottom;
58
+ };
@@ -1,13 +1,13 @@
1
- import { BASE_URL } from '../constants/webViewConstants';
2
- import { 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
- }
1
+ import { BASE_URL } from '../constants/webViewConstants';
2
+ import { 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
+ }