tinkr 0.0.43

Tinkr is a web framework for quickly building full-stack web applications with Leptos.
Documentation
/// Email templates for ScratchFixPro
/// These templates match the v1 implementation for consistency

/// Generate HTML email for order payment confirmation
pub fn order_paid_email(client_name: &str, order_ref: &str) -> String {
    format!(
        r#"<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <style>
        body {{ font-family: 'Open Sans', 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; margin: 0; padding: 0; }}
        .container {{ max-width: 600px; margin: 0 auto; padding: 20px; }}
        .text {{ font-size: 16px; font-weight: 300; color: #404040; line-height: 26px; margin: 15px 0; }}
        .button {{ background-color: #3638bf; border-radius: 4px; color: #fff; font-size: 15px; text-decoration: none; text-align: center; display: inline-block; padding: 14px 30px; margin: 20px 0; }}
        img {{ max-width: 256px; margin-bottom: 20px; }}
    </style>
</head>
<body>
    <div class="container">
        <img src="https://scratchfixpro.co.za/_next/image?url=%2FemailLogo.jpeg&w=256&q=75" alt="Scratch Fix Pro Logo" />
        <p class="text">Hey {}, we have received your Scratch Fix Pro order.</p>
        <p class="text">Your order will be packed and shipped within 5-10 working days depending on your location. We will send you an email with your tracking number as soon as your order is shipped.</p>
        <p class="text"><strong>Order Ref: {}</strong></p>
        <p class="text">To view your order login to scratchfixpro.co.za and click on your profile icon and select my orders.</p>
        <a href="https://scratchfixpro.co.za" class="button">Go To Site</a>
        <p class="text">For support contact info@scratchfixpro.co.za</p>
    </div>
</body>
</html>"#,
        client_name, order_ref
    )
}

/// Generate HTML email for order tracking/shipping notification
pub fn order_tracking_email(
    client_name: &str,
    order_ref: &str,
    courier: &str,
    tracking_number: &str,
) -> String {
    format!(
        r#"<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <style>
        body {{ font-family: 'Open Sans', 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; margin: 0; padding: 0; }}
        .container {{ max-width: 600px; margin: 0 auto; padding: 20px; }}
        .text {{ font-size: 16px; font-weight: 300; color: #404040; line-height: 26px; margin: 15px 0; }}
        .tracking {{ font-size: 18px; font-weight: 500; color: #3638bf; margin: 10px 0; }}
        img {{ max-width: 256px; margin-bottom: 20px; }}
    </style>
</head>
<body>
    <div class="container">
        <img src="https://scratchfixpro.co.za/_next/image?url=%2FemailLogo.jpeg&w=256&q=75" alt="Scratch Fix Pro Logo" />
        <p class="text">Hey {}, your Scratch Fix Pro Order has been packed and shipped.</p>
        <p class="text"><strong>Order Ref: {}</strong></p>
        <p class="text">Your order has been shipped by {}</p>
        <p class="text">and your tracking number is</p>
        <p class="tracking">{}</p>
        <p class="text">For support contact info@scratchfixpro.co.za</p>
    </div>
</body>
</html>"#,
        client_name, order_ref, courier, tracking_number
    )
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_order_paid_email() {
        let email = order_paid_email("John Doe", "12345");
        assert!(email.contains("John Doe"));
        assert!(email.contains("12345"));
        assert!(email.contains("scratchfixpro.co.za"));
    }

    #[test]
    fn test_order_tracking_email() {
        let email = order_tracking_email("Jane Smith", "67890", "Courier Guy", "TRK123456");
        assert!(email.contains("Jane Smith"));
        assert!(email.contains("67890"));
        assert!(email.contains("Courier Guy"));
        assert!(email.contains("TRK123456"));
    }
}