Compare commits

..

3 Commits

Author SHA1 Message Date
Dhruwang
b744156d42 fix: update welcome card toggle logic to set active element when enabled 2026-02-09 14:13:34 +05:30
Dhruwang Jariwala
07a6cd6c0e chore: survey ui console warnings (#7228) 2026-02-09 07:39:30 +00:00
Dhruwang Jariwala
335da2f1f5 fix: webhook data not being sent (#7219) 2026-02-09 06:06:30 +00:00
6 changed files with 65 additions and 6 deletions

View File

@@ -141,5 +141,52 @@ describe("Time Utilities", () => {
expect(convertDatesInObject("string")).toBe("string");
expect(convertDatesInObject(123)).toBe(123);
});
test("should not convert dates in contactAttributes", () => {
const input = {
createdAt: "2024-03-20T15:30:00",
contactAttributes: {
createdAt: "2024-03-20T16:30:00",
email: "test@example.com",
},
};
const result = convertDatesInObject(input);
expect(result.createdAt).toBeInstanceOf(Date);
expect(result.contactAttributes.createdAt).toBe("2024-03-20T16:30:00");
expect(result.contactAttributes.email).toBe("test@example.com");
});
test("should not convert dates in variables", () => {
const input = {
updatedAt: "2024-03-20T15:30:00",
variables: {
createdAt: "2024-03-20T16:30:00",
userId: "123",
},
};
const result = convertDatesInObject(input);
expect(result.updatedAt).toBeInstanceOf(Date);
expect(result.variables.createdAt).toBe("2024-03-20T16:30:00");
expect(result.variables.userId).toBe("123");
});
test("should not convert dates in data or meta", () => {
const input = {
createdAt: "2024-03-20T15:30:00",
data: {
createdAt: "2024-03-20T16:30:00",
},
meta: {
updatedAt: "2024-03-20T17:30:00",
},
};
const result = convertDatesInObject(input);
expect(result.createdAt).toBeInstanceOf(Date);
expect(result.data.createdAt).toBe("2024-03-20T16:30:00");
expect(result.meta.updatedAt).toBe("2024-03-20T17:30:00");
});
});
});

View File

@@ -160,7 +160,12 @@ export const convertDatesInObject = <T>(obj: T): T => {
return obj.map((item) => convertDatesInObject(item)) as unknown as T;
}
const newObj: any = {};
const keysToIgnore = new Set(["contactAttributes", "variables", "data", "meta"]);
for (const key in obj) {
if (keysToIgnore.has(key)) {
newObj[key] = obj[key];
continue;
}
if (
(key === "createdAt" || key === "updatedAt") &&
typeof obj[key] === "string" &&

View File

@@ -67,7 +67,7 @@ export const EditWelcomeCard = ({
<div
className={cn(
open ? "bg-slate-50" : "",
"flex w-10 items-center justify-center rounded-l-lg border-t border-b border-l group-aria-expanded:rounded-bl-none",
"flex w-10 items-center justify-center rounded-l-lg border-b border-l border-t group-aria-expanded:rounded-bl-none",
isInvalid ? "bg-red-400" : "bg-white group-hover:bg-slate-50"
)}>
<Hand className="h-4 w-4" />
@@ -101,7 +101,11 @@ export const EditWelcomeCard = ({
checked={localSurvey?.welcomeCard?.enabled}
onClick={(e) => {
e.stopPropagation();
updateSurvey({ enabled: !localSurvey.welcomeCard?.enabled });
const newEnabledState = !localSurvey.welcomeCard?.enabled;
updateSurvey({ enabled: newEnabledState });
if (newEnabledState && !open) {
setActiveElementId("start");
}
}}
/>
</div>

View File

@@ -19,6 +19,8 @@ import tailwindcss from "@tailwindcss/vite";
*/
export default defineConfig({
build: {
// Keep dist when running watch so surveys (and others) can resolve types during parallel go
emptyOutDir: false,
lib: {
entry: "src/index.ts",
formats: ["es"],

View File

@@ -7,7 +7,8 @@
"jsx": "react-jsx",
"jsxImportSource": "preact",
"paths": {
"@/*": ["./src/*"]
"@/*": ["./src/*"],
"@formbricks/survey-ui": ["../survey-ui"]
},
"resolveJsonModule": true
},

View File

@@ -88,16 +88,16 @@
"persistent": true
},
"@formbricks/surveys#build": {
"dependsOn": ["^build"],
"dependsOn": ["^build", "@formbricks/survey-ui#build"],
"outputs": ["dist/**"]
},
"@formbricks/surveys#build:dev": {
"dependsOn": ["^build:dev", "@formbricks/i18n-utils#build"],
"dependsOn": ["^build:dev", "@formbricks/i18n-utils#build", "@formbricks/survey-ui#build:dev"],
"outputs": ["dist/**"]
},
"@formbricks/surveys#go": {
"cache": false,
"dependsOn": ["@formbricks/surveys#build"],
"dependsOn": ["@formbricks/survey-ui#build", "@formbricks/surveys#build"],
"persistent": true
},
"@formbricks/surveys#test": {