mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 10:19:51 -06:00
fix: notion issue with empty url (#4517)
This commit is contained in:
committed by
GitHub
parent
2433d40918
commit
9b8112b478
@@ -348,16 +348,16 @@ const buildNotionPayloadProperties = (
|
||||
mapping.forEach((map) => {
|
||||
if (map.question.id === "metadata") {
|
||||
properties[map.column.name] = {
|
||||
[map.column.type]: getValue(map.column.type, convertMetaObjectToString(data.response.meta)),
|
||||
[map.column.type]: getValue(map.column.type, convertMetaObjectToString(data.response.meta)) || null,
|
||||
};
|
||||
} else if (map.question.id === "createdAt") {
|
||||
properties[map.column.name] = {
|
||||
[map.column.type]: getValue(map.column.type, data.response.createdAt.toISOString()),
|
||||
[map.column.type]: getValue(map.column.type, data.response.createdAt) || null,
|
||||
};
|
||||
} else {
|
||||
const value = responses[map.question.id];
|
||||
properties[map.column.name] = {
|
||||
[map.column.type]: getValue(map.column.type, value),
|
||||
[map.column.type]: getValue(map.column.type, value) || null,
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -367,16 +367,21 @@ const buildNotionPayloadProperties = (
|
||||
|
||||
// notion requires specific payload for each column type
|
||||
// * TYPES NOT SUPPORTED BY NOTION API - rollup, created_by, created_time, last_edited_by, or last_edited_time
|
||||
const getValue = (colType: string, value: string | string[] | number | Record<string, string>) => {
|
||||
const getValue = (colType: string, value: string | string[] | Date | number | Record<string, string>) => {
|
||||
try {
|
||||
switch (colType) {
|
||||
case "select":
|
||||
return {
|
||||
name: value,
|
||||
};
|
||||
if (!value) return null;
|
||||
if (typeof value === "string") {
|
||||
// Replace commas
|
||||
const sanitizedValue = value.replace(/,/g, "");
|
||||
return {
|
||||
name: sanitizedValue,
|
||||
};
|
||||
}
|
||||
case "multi_select":
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((v: string) => ({ name: v }));
|
||||
return value.map((v: string) => ({ name: v.replace(/,/g, "") }));
|
||||
}
|
||||
case "title":
|
||||
return [
|
||||
@@ -402,7 +407,7 @@ const getValue = (colType: string, value: string | string[] | number | Record<st
|
||||
return value === "accepted" || value === "clicked";
|
||||
case "date":
|
||||
return {
|
||||
start: new Date(value as string).toISOString().substring(0, 10),
|
||||
start: value,
|
||||
};
|
||||
case "email":
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user