Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion plugins/airtable/src/FieldMapping.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
35 changes: 32 additions & 3 deletions plugins/airtable/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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,
Expand Down