@@ -20,9 +20,11 @@ const API_BASE_URL = process.env.API_BASE_URL || 'http://localhost:3000';
2020type EmailCampaignOptions = {
2121 subject ?: string ;
2222 toEmail ?: string ;
23- recentLandlordPropertyIDs ?: string [ ] ;
24- lovedPropertyIds ?: string [ ] ;
23+ nearbyPropertyIDs ?: string [ ] ;
24+ budgetPropertyIDs ?: string [ ] ;
2525 recentAreaPropertyIDs ?: string [ ] ;
26+ lovedPropertyIDs ?: string [ ] ;
27+ reviewedPropertyIDs ?: string [ ] ;
2628} ;
2729
2830/**
@@ -32,9 +34,11 @@ type EmailCampaignOptions = {
3234 * @param options - Configuration options for the email campaign
3335 * @param options.subject - Email subject line (default: 'Check Out These New Apartments!')
3436 * @param options.toEmail - Primary recipient email address (default: 'laurenpothuru@gmail.com')
35- * @param options.recentLandlordPropertyIDs - List of property IDs to feature as recent landlord properties
36- * @param options.lovedPropertyIds - List of property IDs to feature as loved properties
37+ * @param options.nearbyPropertyIDs - List of property IDs to feature as nearby available properties
38+ * @param options.budgetPropertyIDs - List of property IDs to feature as budget-friendly properties
3739 * @param options.recentAreaPropertyIDs - List of property IDs to feature as recent area properties
40+ * @param options.lovedPropertyIDs - List of property IDs to feature as top loved properties
41+ * @param options.reviewedPropertyIDs - List of property IDs to feature as most reviewed properties
3842 * @returns Promise that resolves when all email batches have been sent
3943 */
4044const sendEmailCampaign = async ( options : EmailCampaignOptions = { } ) : Promise < void > => {
@@ -53,8 +57,6 @@ const sendEmailCampaign = async (options: EmailCampaignOptions = {}): Promise<vo
5357 return ;
5458 }
5559
56- // const { API_BASE_URL } = process.env;
57-
5860 /**
5961 * getPropertiesByIds
6062 * Fetches apartment data for a given list of property IDs.
@@ -82,19 +84,27 @@ const sendEmailCampaign = async (options: EmailCampaignOptions = {}): Promise<vo
8284 } ;
8385
8486 // Loads chosen properties
85- const recentLandlordProperties = options . recentLandlordPropertyIDs
86- ? await getPropertiesByIds ( options . recentLandlordPropertyIDs )
87+ const nearbyProperties = options . nearbyPropertyIDs
88+ ? await getPropertiesByIds ( options . nearbyPropertyIDs )
8789 : [ ] ;
88- const lovedProperties = options . lovedPropertyIds
89- ? await getPropertiesByIds ( options . lovedPropertyIds )
90+ const budgetProperties = options . budgetPropertyIDs
91+ ? await getPropertiesByIds ( options . budgetPropertyIDs )
9092 : [ ] ;
9193 const recentAreaProperties = options . recentAreaPropertyIDs
9294 ? await getPropertiesByIds ( options . recentAreaPropertyIDs )
9395 : [ ] ;
96+ const lovedProperties = options . lovedPropertyIDs
97+ ? await getPropertiesByIds ( options . lovedPropertyIDs )
98+ : [ ] ;
99+ const reviewedProperties = options . reviewedPropertyIDs
100+ ? await getPropertiesByIds ( options . reviewedPropertyIDs )
101+ : [ ] ;
94102
95- console . log (
96- `Fetched ${ recentLandlordProperties . length } recent properties (landlord highlight), ${ lovedProperties . length } loved properties (landlord highlight), and ${ recentAreaProperties . length } recent properties (area spotlight).`
97- ) ;
103+ console . log ( `Fetched ${ nearbyProperties . length } nearby properties (recently released spotlight)` ) ;
104+ console . log ( `Fetched ${ budgetProperties . length } budget properties (recently released spotlight)` ) ;
105+ console . log ( `Fetched ${ recentAreaProperties . length } recent area properties (area spotlight)` ) ;
106+ console . log ( `Fetched ${ lovedProperties . length } loved properties (loved spotlight)` ) ;
107+ console . log ( `Fetched ${ reviewedProperties . length } reviewed properties (loved spotlight)` ) ;
98108
99109 const resend = new Resend ( apiKey ) ;
100110
@@ -135,9 +145,11 @@ const sendEmailCampaign = async (options: EmailCampaignOptions = {}): Promise<vo
135145 // bcc: bccEmails,
136146 subject,
137147 react : React . createElement ( GenerateNewsletter , {
138- recentLandlordProperties ,
139- lovedProperties ,
148+ nearbyProperties ,
149+ budgetProperties ,
140150 recentAreaProperties,
151+ lovedProperties,
152+ reviewedProperties,
141153 } ) ,
142154 } ) ;
143155
@@ -169,9 +181,11 @@ const sendEmailCampaign = async (options: EmailCampaignOptions = {}): Promise<vo
169181 to : 'laurenpothuru@gmail.com' ,
170182 subject,
171183 react : React . createElement ( GenerateNewsletter , {
172- recentLandlordProperties ,
173- lovedProperties ,
184+ nearbyProperties ,
185+ budgetProperties ,
174186 recentAreaProperties,
187+ lovedProperties,
188+ reviewedProperties,
175189 } ) ,
176190 } ) ;
177191 if ( error ) {
@@ -202,8 +216,10 @@ async function main() {
202216 await sendEmailCampaign ( {
203217 subject : 'New Apartment Listings Available!' ,
204218 recentAreaPropertyIDs : [ '12' , '2' , '24' ] ,
205- lovedPropertyIds : [ '23' , '24' , '24' ] ,
206- recentLandlordPropertyIDs : [ '14' , '23' , '24' ] ,
219+ budgetPropertyIDs : [ '23' , '24' , '24' ] ,
220+ nearbyPropertyIDs : [ '14' , '23' , '24' ] ,
221+ reviewedPropertyIDs : [ '1' , '2' , '3' ] ,
222+ lovedPropertyIDs : [ '4' , '5' , '6' ] ,
207223 } ) ;
208224
209225 console . log ( 'Campaign completed successfully!' ) ;
0 commit comments