mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-09 18:58:46 -06:00
Compare commits
3 Commits
epic/attri
...
fix/welcom
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b744156d42 | ||
|
|
07a6cd6c0e | ||
|
|
335da2f1f5 |
@@ -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");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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" &&
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"],
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
"@/*": ["./src/*"],
|
||||
"@formbricks/survey-ui": ["../survey-ui"]
|
||||
},
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user