Fix Monday.com column type names: checkbox, status, numbers
Monday.com API returns column types as "checkbox" (not "boolean"), "status" (not "color"), and "numbers" (not "numeric"). Added these as aliases in formatForColumnType so values are properly formatted. Made-with: Cursor
This commit is contained in:
parent
d7d859f49d
commit
9b27041970
1 changed files with 14 additions and 2 deletions
|
|
@ -157,12 +157,14 @@ function toCleanString(val: unknown): string | null {
|
||||||
|
|
||||||
function formatForColumnType(colType: string, val: unknown): unknown | null {
|
function formatForColumnType(colType: string, val: unknown): unknown | null {
|
||||||
switch (colType) {
|
switch (colType) {
|
||||||
case "boolean": {
|
case "boolean":
|
||||||
|
case "checkbox": {
|
||||||
const isChecked = val === true || val === "true";
|
const isChecked = val === true || val === "true";
|
||||||
return { checked: isChecked ? "true" : "false" };
|
return { checked: isChecked ? "true" : "false" };
|
||||||
}
|
}
|
||||||
|
|
||||||
case "color": {
|
case "color":
|
||||||
|
case "status": {
|
||||||
const str = toCleanString(val);
|
const str = toCleanString(val);
|
||||||
return str ? { label: str } : null;
|
return str ? { label: str } : null;
|
||||||
}
|
}
|
||||||
|
|
@ -181,6 +183,14 @@ function formatForColumnType(colType: string, val: unknown): unknown | null {
|
||||||
return iso ? { date: iso } : str;
|
return iso ? { date: iso } : str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "numeric":
|
||||||
|
case "numbers": {
|
||||||
|
const str = toCleanString(val);
|
||||||
|
if (!str) return null;
|
||||||
|
const num = parseFloat(str);
|
||||||
|
return isNaN(num) ? null : String(num);
|
||||||
|
}
|
||||||
|
|
||||||
case "email": {
|
case "email": {
|
||||||
const str = toCleanString(val);
|
const str = toCleanString(val);
|
||||||
return str ? { email: str, text: str } : null;
|
return str ? { email: str, text: str } : null;
|
||||||
|
|
@ -219,6 +229,8 @@ export function mapCardToColumnValues(
|
||||||
const values: Record<string, unknown> = {};
|
const values: Record<string, unknown> = {};
|
||||||
const columnTypes = ((columnMap._columnTypes as Record<string, string>) ?? {});
|
const columnTypes = ((columnMap._columnTypes as Record<string, string>) ?? {});
|
||||||
|
|
||||||
|
console.log("[mapCardToColumnValues] _columnTypes keys:", Object.keys(columnTypes).length, "sample:", JSON.stringify(Object.entries(columnTypes).slice(0, 5)));
|
||||||
|
|
||||||
for (const [cardField, rawColId] of Object.entries(columnMap)) {
|
for (const [cardField, rawColId] of Object.entries(columnMap)) {
|
||||||
if (!rawColId || !cardField || cardField.startsWith("_") || typeof rawColId !== "string") continue;
|
if (!rawColId || !cardField || cardField.startsWith("_") || typeof rawColId !== "string") continue;
|
||||||
const colId = rawColId;
|
const colId = rawColId;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue