from django.template.loader import get_template

from base.base_mail_serivce import BaseMailService


def send_reset_password_mail(user, password_link):
    subject = "EV Chargy - Reset your password!"
    to_emails = [user.email]
    text_template = get_template("text/forgot_password_mail.txt")
    html_template = get_template("mail/forgot_password_mail.html")
    context = {"link": password_link, "name": user.name}
    body = text_template.render(context)
    html_content = html_template.render(context)
    BaseMailService.send_main(subject, body, to_emails, html_content)


def send_opt_verification_mail(user):
    subject = "EV Chargy - One-Time Password (OTP) Verification"
    to_emails = [user.user.email]
    text_template = get_template("text/user_otp_mail.txt")
    html_template = get_template("mail/user_otp_mail.html")
    context = {"otp_code": user.code}
    body = text_template.render(context)
    html_content = html_template.render(context)
    BaseMailService.send_main(subject, body, to_emails, html_content)
