diff --git a/plugins/airtable/src/FieldMapping.tsx b/plugins/airtable/src/FieldMapping.tsx index 4cc370a49..999ed9c7b 100644 --- a/plugins/airtable/src/FieldMapping.tsx +++ b/plugins/airtable/src/FieldMapping.tsx @@ -1,4 +1,4 @@ -import type { ManagedCollection, EditableManagedCollectionField, Field, } from "framer-plugin" +import type { ManagedCollection, EditableManagedCollectionField, Field } from "framer-plugin" import type { DataSource, PossibleField } from "./data" import { framer } from "framer-plugin" @@ -199,6 +199,8 @@ export function FieldMapping({ collection, dataSource, initialSlugFieldId }: Fie } as PossibleField case "image": return { ...field, type: "image" } as PossibleField + case "string": + return { ...field, type: "string" } as PossibleField default: return field } diff --git a/plugins/airtable/src/data.ts b/plugins/airtable/src/data.ts index a8627cd3c..28929c8dd 100644 --- a/plugins/airtable/src/data.ts +++ b/plugins/airtable/src/data.ts @@ -137,13 +137,21 @@ export async function inferFields(collection: ManagedCollection, table: Airtable break case "singleLineText": + fields.push({ + ...fieldMetadata, + airtableType: fieldSchema.type, + type: "string", + allowedTypes: ["string"], + }) + break + case "email": case "phoneNumber": fields.push({ ...fieldMetadata, airtableType: fieldSchema.type, type: "string", - allowedTypes: ["string"], + allowedTypes: ["string", "link"], }) break @@ -301,9 +309,22 @@ function getFieldDataEntryForFieldSchema(fieldSchema: PossibleField, value: unkn case "image": case "file": if (typeof value === "string") { + if (fieldSchema.airtableType === "email") { + return { + value: `mailto:${value}`, + type: "link", + } + } + if (fieldSchema.airtableType === "phoneNumber") { + return { + value: `tel:${value}`, + type: "link", + } + } + return { value, - type: "string", + type: fieldSchema.type, } } @@ -438,12 +459,20 @@ export async function getItems(dataSource: DataSource, slugFieldId: string) { switch (field.type) { case "string": case "formattedText": - case "enum": fieldData[field.id] = { value: "", type: field.type, } break + case "enum": + console.warn( + `Missing value for field “${field.name}” on item “${item.id}”, it will be set to the first case.` + ) + fieldData[field.id] = { + value: field.cases[0].id, + type: "enum", + } + break case "boolean": fieldData[field.id] = { value: false,