diff --git a/src/objects/properties.js b/src/objects/properties.js index df388d8..aef861a 100644 --- a/src/objects/properties.js +++ b/src/objects/properties.js @@ -63,6 +63,7 @@ export async function importSmoobuProperties(env) { (g) => g.smoobuId === property.smoobuId ); if (!cached?.notionId) continue; + console.log("Updating property in Notion:", property); const res = await updateNotionProperty(env, property, cached.notionId); updated.push(res); } diff --git a/src/utils/properties.js b/src/utils/properties.js index dea706d..41d0be5 100644 --- a/src/utils/properties.js +++ b/src/utils/properties.js @@ -100,7 +100,10 @@ export function transformSmoobuProperty(env, property) { .split(",") .map((s) => s.trim()) .join("\n"); - + console.log( + "Transformed property:", + property.amenities.map((feature) => feature.replace(/,/g, ";")) || [] + ); return { smoobuId: property.id, name: property.name || "Unknown Property", @@ -311,24 +314,24 @@ export async function addPropertyToNotion(env, property) { export async function updateNotionProperty(env, property, notionId) { console.log("Updating property in Notion:", property.smoobuId); - const details = await fetchSmoobuPropertyDetails(env, property.smoobuId); + // Use the transformed property data directly instead of fetching from Smoobu again const notionProps = { - ...(property.syncName ? { Name: details.name } : {}), - "Max Occupancy": details.rooms.maxOccupancy, - Bedrooms: details.rooms.bedrooms, - Bathrooms: details.rooms.bathrooms, - "Double Beds": details.rooms.doubleBeds, - "Single Beds": details.rooms.singleBeds, - "Sofa Beds": details.rooms.sofaBeds, - Sofas: details.rooms.couches, - "Child Beds": details.rooms.childBeds, - "Queen Size Beds": details.rooms.queenSizeBeds, - "King Size Beds": details.rooms.kingSizeBeds, - Timezone: { select: { name: details.timeZone || "UTC" } }, - Address: `${details.location.street}\n${details.location.city}\n${details.location.zip}`, - Features: details.amenities, - "Min Price": parseFloat(details.price.minimal), - "Max Price": parseFloat(details.price.maximal), + ...(property.syncName ? { Name: property.name } : {}), + "Max Occupancy": property.maxOccupancy, + Bedrooms: property.bedrooms, + Bathrooms: property.bathrooms, + "Double Beds": property.doubleBeds, + "Single Beds": property.singleBeds, + "Sofa Beds": property.sofaBeds, + Sofas: property.sofas, + "Child Beds": property.childBeds, + "Queen Size Beds": property.queenSizeBeds, + "King Size Beds": property.kingSizeBeds, + Timezone: { select: { name: property.timezone || "UTC" } }, + Address: property.address, + Features: property.features, + "Min Price": property.minPrice, + "Max Price": property.maxPrice, }; Object.keys(notionProps).forEach( (k) => notionProps[k] === undefined && delete notionProps[k]