diff --git a/crates/email/src/lib.rs b/crates/email/src/lib.rs index bec3a10..207aaa5 100644 --- a/crates/email/src/lib.rs +++ b/crates/email/src/lib.rs @@ -326,6 +326,30 @@ impl Mailer { self.send_html(to, "Lead Request Accepted!", html).await } + pub async fn send_lead_rejected_email(&self, to: &str, name: &str, requirement_title: &str) -> Result<()> { + let frontend_url = env::var("FRONTEND_URL").unwrap_or_else(|_| "https://nxtgauge.com".to_string()); + let lead_url = format!("{}/dashboard/leads", frontend_url); + + let vars = HashMap::from([ + ("first_name", name), + ("requirement_title", requirement_title), + ("lead_url", &lead_url), + ]); + + // Reuse the lead-expired template as a safe fallback for rejection notifications. + let html = self + .template_engine + .render("lead-expired", vars) + .unwrap_or_else(|_| { + format!( + "

Hi {},

Your lead request for {} was rejected.

You can view details here: View Leads

", + name, requirement_title, lead_url + ) + }); + + self.send_html(to, "Lead Request Rejected", html).await + } + pub async fn send_new_lead_request_email(&self, to: &str, customer_name: &str, requirement_title: &str, professional_name: &str, profession: &str) -> Result<()> { let frontend_url = env::var("FRONTEND_URL").unwrap_or_else(|_| "https://nxtgauge.com".to_string()); let now = chrono::Local::now().format("%B %d, %Y at %I:%M %p").to_string(); @@ -497,6 +521,25 @@ impl Mailer { ).await } + pub async fn send_lead_accepted_professional_email( + &self, + to: &str, + professional_name: &str, + customer_name: &str, + customer_email: &str, + customer_phone: &str, + ) -> Result<()> { + self.send_html( + to, + "Customer Contact Details", + format!( + "

Customer Contact

Hi {},

Your request for {} was accepted.

Email: {}

Phone: {}

", + professional_name, customer_name, customer_email, customer_phone + ), + ) + .await + } + pub async fn send_manual_credit_email(&self, to: &str, name: &str, amount: i32, reason: &str) -> Result<()> { let frontend_url = env::var("FRONTEND_URL").unwrap_or_else(|_| "https://nxtgauge.com".to_string()); let wallet_url = format!("{}/dashboard/wallet", frontend_url);