# utils.py
from flask_mail import Message
from flask import current_app, request, url_for
# from .extensions import mail

# def send_email(subject, recipient, body):
#     msg = Message(subject, recipients=[recipient], body=body)
#     mail.send(msg)

def generate_breadcrumbs():
    breadcrumbs = [{'url': url_for('main.home'), 'text': 'Lanka Travel Bee'}]
    if request.endpoint != 'main.home':
        parts = request.path.split('/')
        url = ''
        for i, part in enumerate(parts[1:], 1):  # Skip the first empty part
            url += f'/{part}'
            endpoint = request.url_rule.endpoint if i == len(parts) - 1 else None
            text = part.replace('-', ' ').title()
            breadcrumbs.append({'url': url, 'text': text, 'endpoint': endpoint})
    return breadcrumbs
