Skip to content

Commit f6b50bc

Browse files
committed
fix: sonar issues
1 parent 38d1455 commit f6b50bc

4 files changed

Lines changed: 69 additions & 63 deletions

File tree

packages/react-native/src/lib/common/utils.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type {
22
TEnvironmentState,
33
TEnvironmentStateProject,
4-
TProjectStyling,
54
TUserState,
65
} from "@/types/config";
76
import type { Result } from "@/types/error";
7+
import type { TProjectStyling } from "@/types/project";
88
import type { TSurvey } from "@/types/survey";
99

1010
// Helper function to calculate difference in days between two dates
@@ -15,19 +15,19 @@ export const diffInDays = (date1: Date, date2: Date): number => {
1515

1616
export const wrapThrowsAsync =
1717
<T, A extends unknown[]>(fn: (...args: A) => Promise<T>) =>
18-
async (...args: A): Promise<Result<T>> => {
19-
try {
20-
return {
21-
ok: true,
22-
data: await fn(...args),
23-
};
24-
} catch (error) {
25-
return {
26-
ok: false,
27-
error: error as Error,
28-
};
29-
}
30-
};
18+
async (...args: A): Promise<Result<T>> => {
19+
try {
20+
return {
21+
ok: true,
22+
data: await fn(...args),
23+
};
24+
} catch (error) {
25+
return {
26+
ok: false,
27+
error: error as Error,
28+
};
29+
}
30+
};
3131

3232
/**
3333
* Filters surveys based on the displayOption, recontactDays, and segments

packages/react-native/src/types/config.ts

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { type TResponseUpdate } from "@/types/response";
33
import { type TFileUploadParams } from "@/types/storage";
44
import { z } from "zod";
55
import { type TActionClass } from "./action-class";
6-
import { type TProject } from "./project";
7-
import { type TSurvey } from "./survey";
6+
import type { TProject, TProjectStyling } from "./project";
7+
import type { TSurvey } from "./survey";
88

99
export type TEnvironmentStateProject = Pick<
1010
TProject,
@@ -71,38 +71,8 @@ export interface TConfigInput {
7171
appUrl: string;
7272
}
7373

74-
export interface TStylingColor {
75-
light: string;
76-
dark?: string | null;
77-
}
7874

79-
export interface TBaseStyling {
80-
brandColor?: TStylingColor | null;
81-
questionColor?: TStylingColor | null;
82-
inputColor?: TStylingColor | null;
83-
inputBorderColor?: TStylingColor | null;
84-
cardBackgroundColor?: TStylingColor | null;
85-
cardBorderColor?: TStylingColor | null;
86-
cardShadowColor?: TStylingColor | null;
87-
highlightBorderColor?: TStylingColor | null;
88-
isDarkModeEnabled?: boolean | null;
89-
roundness?: number | null;
90-
cardArrangement?: {
91-
linkSurveys: "casual" | "straight" | "simple";
92-
appSurveys: "casual" | "straight" | "simple";
93-
} | null;
94-
background?: {
95-
bg?: string | null;
96-
bgType?: "animation" | "color" | "image" | "upload" | null;
97-
brightness?: number | null;
98-
} | null;
99-
hideProgressBar?: boolean | null;
100-
isLogoHidden?: boolean | null;
101-
}
10275

103-
export interface TProjectStyling extends TBaseStyling {
104-
allowStyleOverwrite: boolean;
105-
}
10676

10777
export interface TWebViewOnMessageData {
10878
onFinished?: boolean | null;

packages/react-native/src/types/project.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { TBaseStyling } from "./survey";
2+
13
export type TProject = {
24
id: string;
35
createdAt: Date;
@@ -24,3 +26,8 @@ export type TProject = {
2426
bgColor?: string;
2527
} | null;
2628
};
29+
30+
31+
export interface TProjectStyling extends TBaseStyling {
32+
allowStyleOverwrite: boolean;
33+
}

packages/react-native/src/types/survey.ts

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { TProjectStyling } from "@/types/config";
21
import type { TResponseData, TResponseUpdate } from "@/types/response";
32
import type { TFileUploadParams, TUploadFileConfig } from "@/types/storage";
3+
import type { TProjectStyling } from "./project";
44

55
export type TJsFileUploadParams = {
66
file: {
@@ -219,10 +219,10 @@ export type TSurvey = {
219219
recontactDays: number | null;
220220
displayLimit: number | null;
221221
displayOption:
222-
| "displayOnce"
223-
| "displayMultiple"
224-
| "respondMultiple"
225-
| "displaySome";
222+
| "displayOnce"
223+
| "displayMultiple"
224+
| "respondMultiple"
225+
| "displaySome";
226226
hiddenFields: {
227227
enabled: boolean;
228228
fieldIds?: string[];
@@ -232,12 +232,12 @@ export type TSurvey = {
232232
brandColor?: string | null;
233233
highlightBorderColor?: string | null;
234234
placement?:
235-
| "topLeft"
236-
| "topRight"
237-
| "bottomLeft"
238-
| "bottomRight"
239-
| "center"
240-
| null;
235+
| "topLeft"
236+
| "topRight"
237+
| "bottomLeft"
238+
| "bottomRight"
239+
| "center"
240+
| null;
241241
clickOutsideClose?: boolean | null;
242242
darkOverlay?: boolean | null;
243243
} | null;
@@ -267,12 +267,12 @@ export type TSurvey = {
267267
urlFilters: {
268268
value: string;
269269
rule:
270-
| "exactMatch"
271-
| "contains"
272-
| "startsWith"
273-
| "endsWith"
274-
| "notMatch"
275-
| "notContains";
270+
| "exactMatch"
271+
| "contains"
272+
| "startsWith"
273+
| "endsWith"
274+
| "notMatch"
275+
| "notContains";
276276
}[];
277277
elementSelector?: {
278278
cssSelector?: string;
@@ -318,3 +318,32 @@ export type TSurvey = {
318318
overwriteThemeStyling?: boolean | null;
319319
};
320320
};
321+
322+
export interface TStylingColor {
323+
light: string;
324+
dark?: string | null;
325+
}
326+
327+
export interface TBaseStyling {
328+
brandColor?: TStylingColor | null;
329+
questionColor?: TStylingColor | null;
330+
inputColor?: TStylingColor | null;
331+
inputBorderColor?: TStylingColor | null;
332+
cardBackgroundColor?: TStylingColor | null;
333+
cardBorderColor?: TStylingColor | null;
334+
cardShadowColor?: TStylingColor | null;
335+
highlightBorderColor?: TStylingColor | null;
336+
isDarkModeEnabled?: boolean | null;
337+
roundness?: number | null;
338+
cardArrangement?: {
339+
linkSurveys: "casual" | "straight" | "simple";
340+
appSurveys: "casual" | "straight" | "simple";
341+
} | null;
342+
background?: {
343+
bg?: string | null;
344+
bgType?: "animation" | "color" | "image" | "upload" | null;
345+
brightness?: number | null;
346+
} | null;
347+
hideProgressBar?: boolean | null;
348+
isLogoHidden?: boolean | null;
349+
}

0 commit comments

Comments
 (0)