# By: Riasat Ullah
# This file contains content for account specific notifications.

from notices import general_notices
from translators import label_translator as _lt
from utils import mail_content_labels as mcl, url_paths

font_family = 'sans-serif'
header_color = '#404040'


def new_account_verification_content(lang, email: str, code: str):
    '''
    The email content of a new account verification notice.
    :param lang: content language
    :param email: email address of the person requesting to open the new account
    :param code: the verification code
    :return: (str) subject, message
    '''
    subject = 'TaskCall - {0}'.format(_lt.get_label(mcl.mcl_sbj_new_account_verification, lang))
    notice = '''
    <div>
        <h2 style="font-family: {0}; color: {1};"> {2} </h2>
        <p style="font-family: {0}; font-size: 14px;"> {3}: {6} </p>
        <p style="font-family: {0}; font-size: 14px;"> {4}: <b> {7} </b> </p>
        <p style="font-family: {0}; font-size: 12px;"> {5} </p>
    </div>
             '''.format(font_family, header_color,
                        _lt.get_label(mcl.mcl_sbj_new_account_verification, lang),
                        _lt.get_label(mcl.mcl_body_new_account_requested, lang),
                        _lt.get_label(mcl.mcl_body_code_to_verify_with, lang),
                        _lt.get_label(mcl.mcl_body_reg_code_validity_20_minutes, lang),
                        email, code)
    content = general_notices.mail_content(lang, notice)
    return subject, content


def new_member_verification_content(lang, org_name: str, email: str, code: str):
    '''
    The email content of a new account verification notice.
    :param lang: content language
    :param org_name: name of the organization
    :param email: email address of the person requesting to open the new account
    :param code: the verification code
    :return: (str) subject, message
    '''
    subject = 'TaskCall - {0}'.format(_lt.get_label(mcl.mcl_sbj_new_account_verification, lang))
    notice = '''
    <div>
        <h2 style="font-family: {0}; color: {1};"> {2} </h2>
        <p style="font-family: {0}; font-size: 14px;"> {3} {8} {4}: {9} </p>
        <p style="font-family: {0}; font-size: 14px;"> {5}: <b> {10} </b> </p>
        <p style="font-family: {0}; font-size: 14px;"> {6} <a href="{11}"> {11} </a> </p>
        <p style="font-family: {0}; font-size: 12px;"> {7} </p>
    </div>
             '''.format(font_family, header_color,
                        _lt.get_label(mcl.mcl_sbj_new_account_verification, lang),
                        _lt.get_label(mcl.mcl_body_new_member_account_requested, lang),
                        _lt.get_label(mcl.mcl_sm_for_your_email_address, lang),
                        _lt.get_label(mcl.mcl_body_code_to_verify_with, lang),
                        _lt.get_label(mcl.mcl_body_reg_complete_address, lang),
                        _lt.get_label(mcl.mcl_body_reg_code_validity_2_days, lang),
                        org_name, email, code, url_paths.web_register_member)
    content = general_notices.mail_content(lang, notice)
    return subject, content


def account_closure_verification_content(lang, org_name: str, code: str,):
    '''
    The email verification notice content for account closure.
    :param lang: content language
    :param org_name: the name of the organization
    :param code: the verification code
    :return: (str) subject, message
    '''
    subject = 'TaskCall - {0}'.format(_lt.get_label(mcl.mcl_sbj_account_closure_verification, lang))
    notice = '''
    <div>
        <h2 style="font-family: {0}; color: {1};"> {2} </h2>
        <p style="font-family: {0}; font-size: 14px;"> {3} - {6}. <br/> {4} </p>
        <p style="font-family: {0}; font-size: 14px;"> {5}: <b> {7} </b> </p>
    </div>
             '''.format(font_family, header_color,
                        _lt.get_label(mcl.mcl_sbj_account_closure_verification, lang),
                        _lt.get_label(mcl.mcl_body_request_to_close_account, lang),
                        _lt.get_label(mcl.mcl_body_sorry_to_see_you_go, lang),
                        _lt.get_label(mcl.mcl_body_code_to_verify_with, lang),
                        org_name, code)
    content = general_notices.mail_content(lang, notice)
    return subject, content


def trial_ending_email_content(days: int, first_name: str):
    '''
    This is the email content that will be sent out when the trial period is about to expire.
    :param days: (int) number of days left before trial ends
    :param first_name: (str) first name of the person who the email will be sent to
    :return: (tuple) -> email subject, email body
    '''
    days = str(days)

    subject = 'Your TaskCall trial ends in {0} days'.format(days)
    content = '''
    <html>
        <body style="background-color: #DCDCDC; padding-left: 8%; padding-right: 8%; padding-top: 3%;
            padding-bottom: 3%; font-family: sans-serif; font-weight: 500; color: #606060; font-size: 15px;">
            <div style="background-color: white; border-radius: 5px; padding-bottom: 60px;">
                <div style="border-radius: 5px 5px 0 0;">
                    <div style="text-align: center; padding-top: 30; margin: auto; width: 50%;">
                        <img style="max-width: 175px; height: 30px; margin-top: 40px;"
                            src="https://taskcallapp.com/images/logos/TaskCallCombinedLogo.png">
                    </div>

                    <div style="text-align: center; padding: 20px; padding-top: 0px; color: #606060;
                        margin-bottom: 20px;">
                        <br/>
                        <h2 style="font-weight: 600;"> Your trial ends in {0} days </h2>
                    </div>
                </div>

                <div style="text-align: left; padding-left: 50px; padding-right: 50px;">
                    <p style="padding-bottom: 10px;"> Hi {1}, </p>
                    <p style="padding-bottom: 10px; font-weight: 500;">
                        We hope you were able to explore TaskCall over the last few days and see how it can help improve
                        your incident response and management.
                    </p>

                    <p style="padding-bottom: 10px; font-weight: 500;">
                        <span style="color: #404040;; font-weight: 600;">Your trial ends in {0} days.</span> After your
                        trial expires, you will still be able to maintain your account. Your account will be
                        automatically converted to the Free plan. Any features and configurations you utilized that are
                        not within the scope of the Free plan will be removed. To retain those features,
                        please upgrade to the required plan.
                    </p>

                    <p style="font-weight: 500;"> The paid plans are: </p>
                    <ul>
                        <li> Starter </li>
                        <li> Business </li>
                        <li> Digital Operations </li>
                    </ul>

                    <p style="padding-top: 25px; padding-bottom: 50px;">
                        Learn more about our <a href="https://www.taskcallapp.com/pricing"> subscription plans</a>.
                    </p>

                    <p style="text-align: center;">
                        <a style="background-color: #4D4DFF; padding: 15px; color: white; font-weight: 600;
                            font-family: sans-serif; border-radius: 5px; text-decoration: none;"
                            href="{2}" role="button">
                            Upgrade Plan
                        </a>
                    </p>

                </div>
            </div>

            <p style="text-align: center;">
                <a href="https://www.linkedin.com/company/taskcall" target="_blank" class="pr-2" role="button"
                    style="text-decoration: none;">
                    <img src="https://taskcallapp.com/images/vendors/linkedin/LinkedInBlackIconRound.png"
                        alt="LinkedIn Icon" height="20" width="20">
                </a>
                <a href="https://twitter.com/taskcallapp" target="_blank" class="pr-2" role="button"
                    style="text-decoration: none;">
                    <img src="https://taskcallapp.com/images/vendors/twitter/TwitterBlackIconRound.png"
                        alt="Twitter Icon" height="20" width="20">
                </a>
            </p>
            <p style="text-align: center; font-size: 10px; padding-left: 25px; padding-right: 25px;">
                This message was produced and distributed by TaskCall. TaskCall is a service owned and provided by
                TaskCall Inc. To help keep your account secure, please do not forward this email.
            </p>
        </body>
    </html>
    '''.format(days, first_name, url_paths.web_organization)
    return subject, content


def account_blacklisted_email_content(lang, first_name, org_name):
    '''
    The email content of a dispatch event notice.
    :param lang: content language
    :param first_name: first name of the recipient
    :param org_name: name of the organization
    :return: (tuple) -> email subject, email body
    '''
    subject = 'TaskCall - {0} {1}'.format(org_name, _lt.get_label(mcl.mcl_sbj_account_blacklisted, lang))
    notice = '''
             <p> Hi {0}, </p>
             <p>{1}</p>
             <p><strong>{2}</strong></p>
             {3}
             '''.format(first_name,
                        _lt.get_label(mcl.mcl_body_blacklisted_reason, lang),
                        _lt.get_label(mcl.mcl_body_blacklisted_resolve, lang),
                        general_notices.mail_footer(lang))
    return subject, notice


def password_reset_verification_content(lang, email: str, code: str):
    '''
    The email content of a password reset verification notice.
    :param lang: content language
    :param email: email address of the person requesting to reset their password
    :param code: the verification code
    :return: (str) subject, message
    '''
    subject = 'TaskCall - {0}'.format(_lt.get_label(mcl.mcl_sbj_password_reset_verification, lang))
    notice = '''
    <div>
        <h2 style="font-family: {0}; color: {1};"> {2} </h2>
        <p style="font-family: {0}; font-size: 14px;"> {3}: {6} </p>
        <p style="font-family: {0}; font-size: 14px;"> {4}: <b> {7} </b> </p>
        <p style="font-family: {0}; font-size: 14px;"> {5} </p>
    </div>
             '''.format(font_family, header_color,
                        _lt.get_label(mcl.mcl_sbj_password_reset_verification, lang),
                        _lt.get_label(mcl.mcl_body_password_reset_attempt, lang),
                        _lt.get_label(mcl.mcl_body_code_to_verify_with, lang),
                        _lt.get_label(mcl.mcl_body_if_you_did_not_request, lang),
                        email, code)
    content = general_notices.mail_content(lang, notice)
    return subject, content


def forgot_subdomain_content(lang, subdomain: str):
    '''
    The email content of a notice sent to users when they forget their subdomain
    and requests for it to be emailed to them.
    :param lang: content language
    :param subdomain: subdomain of the organization the user is associated to
    :return: (str) subject, message
    '''
    subject = 'TaskCall - {0}'.format(_lt.get_label(mcl.mcl_sbj_subdomain_forgotten, lang))
    notice = '''
    <div>
        <h2 style="font-family: {0}; color: {1};"> {2} </h2>
        <p style="font-family: {0}; font-size: 14px;"> {3}: <b> {5} </b> </p>
        <p style="font-family: {0}; font-size: 14px;"> {4} </p>
    </div>
             '''.format(font_family, header_color,
                        _lt.get_label(mcl.mcl_sbj_subdomain_forgotten, lang),
                        _lt.get_label(mcl.mcl_body_subdomain_requested, lang),
                        _lt.get_label(mcl.mcl_body_if_you_did_not_request, lang),
                        subdomain)
    content = general_notices.mail_content(lang, notice)
    return subject, content


########################
# Support/Contact us
########################

def non_user_contact_form_email_content(lang, email: str, first_name: str, contact_subject: str, contact_body: str):
    '''
    Gets the email content for an upcoming on-call email.
    :param lang: content language
    :param email: email address of the sender
    :param first_name: first name of the user
    :param contact_subject: subject of the contact request
    :param contact_body: body of the contact request
    :return: (tuple) -> email subject, email body
    '''
    subject = 'TaskCall Support - {0}'.format(contact_subject)
    notice = '''
    <div>
        <p style="font-family: {0}; font-size: 14px;"> Hi {3}, </p>
        <p style="font-family: {0}; font-size: 14px;">
            We have received your message. We will get back to you within the next 4 hours.
        </p>
        <br/>

        <p style="padding: 10px;">
            <i>
                From: {2}
                <br/>
                {4}
            </i>
        </p>

        <br/>
        <p style="font-family: {0}; font-size: 14px;">
            Thank you, <br/>
            TaskCall Support Team
        </p>
    </div>
             '''.format(font_family, header_color, email, first_name, contact_body)
    content = general_notices.mail_content(lang, notice)
    return subject, content
