All checks were successful
Build and deploy / Validate source (push) Successful in 49s
Build and deploy / Integration suite on a real stack (push) Successful in 3m23s
Build and deploy / Secret scan and release gate (push) Successful in 10s
Build and deploy / Publish images (push) Successful in 1m17s
The account e-mails (signup and e-mail change codes, new password, an address that already has an account, the changed-e-mail notice) gain an HTML version beside their plain text: the DROPSTAR header, a white card, orange buttons, the customer greeted by first name. Built with tables and inline styles only, so Gmail, Outlook and phone apps show it the same. A paid order now also e-mails the customer "Recebemos seu pedido #N": the items, delivery and total, the stages to come, and a link to the order in the account. Not for an operator's test order. A code's or a recovery link's HTML is erased with its text once sent. The team's alerts stay plain text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
204 lines
11 KiB
Python
204 lines
11 KiB
Python
"""The customer e-mails' HTML, next to the plain text every message keeps.
|
|
|
|
Built for mail clients, not browsers: tables for layout, every style inline,
|
|
no web fonts or images (Outlook ignores flex, many clients block images until
|
|
asked), so it reads the same in Gmail, Outlook and phone apps. The look is
|
|
the Site's: the DROPSTAR wordmark in orange on black, a white card, orange
|
|
buttons. Every value put in is escaped here; callers pass plain text.
|
|
"""
|
|
from html import escape
|
|
|
|
ORANGE, INK, DARK_ORANGE = '#FFA81A', '#03060B', '#C25E00'
|
|
TEXT, MUTED, LINE = '#3A3733', '#5E5A54', '#ECE8E2'
|
|
FONT = "Inter, 'Helvetica Neue', Helvetica, Arial, sans-serif"
|
|
WHATSAPP = 'https://wa.me/5516994280056'
|
|
|
|
|
|
def greeting(name):
|
|
first = (name or '').split()
|
|
return f'Olá, {first[0]}!' if first else 'Olá!'
|
|
|
|
|
|
def layout(preheader, label, blocks):
|
|
"""The whole message: the dark header, the card holding `blocks` (already
|
|
HTML), and the footer. The preheader is the line inboxes show after the
|
|
subject."""
|
|
rows = ''.join(f'<tr><td style="padding:0 0 20px 0">{block}</td></tr>' for block in blocks)
|
|
return f'''<!doctype html>
|
|
<html lang="pt-BR">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<meta name="color-scheme" content="light">
|
|
<title>DTF Dropstar</title>
|
|
</head>
|
|
<body style="margin:0;padding:0;background:#EEEBE6">
|
|
<div style="display:none;max-height:0;overflow:hidden;opacity:0">{escape(preheader)}</div>
|
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:#EEEBE6">
|
|
<tr><td align="center" style="padding:32px 12px">
|
|
<table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="width:100%;max-width:600px;font-family:{FONT}">
|
|
<tr><td style="background:{INK};border-radius:16px 16px 0 0;padding:22px 32px">
|
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
|
|
<td style="font-family:{FONT};font-size:24px;font-weight:800;font-style:italic;letter-spacing:-0.5px;color:{ORANGE}">DROPSTAR
|
|
<span style="font-size:12px;font-style:normal;letter-spacing:1px;color:{INK};background:{ORANGE};border-radius:6px;padding:3px 7px;vertical-align:middle">DTF</span></td>
|
|
<td align="right" style="font-family:{FONT};font-size:12px;font-weight:600;letter-spacing:0.7px;text-transform:uppercase;color:#B9B4AC">{escape(label)}</td>
|
|
</tr></table>
|
|
</td></tr>
|
|
<tr><td style="background:#FFFFFF;border-radius:0 0 16px 16px;padding:36px 36px 16px 36px">
|
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">{rows}</table>
|
|
</td></tr>
|
|
<tr><td align="center" style="padding:22px 8px 0 8px;font-family:{FONT};font-size:12.5px;line-height:19px;color:{MUTED}">
|
|
DTF Dropstar · Franca-SP · WhatsApp <a href="{WHATSAPP}" style="color:{MUTED}">16 99428-0056</a><br>
|
|
E-mail automático, não precisa responder.
|
|
</td></tr>
|
|
</table>
|
|
</td></tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
'''
|
|
|
|
|
|
def title(text):
|
|
return (f'<h1 style="margin:0;font-family:{FONT};font-size:26px;line-height:32px;font-weight:800;'
|
|
f'color:{INK}">{escape(text)}</h1>')
|
|
|
|
|
|
def para(text):
|
|
return f'<p style="margin:0;font-family:{FONT};font-size:16px;line-height:25px;color:{TEXT}">{escape(text)}</p>'
|
|
|
|
|
|
def small(text, html=''):
|
|
return (f'<p style="margin:0;font-family:{FONT};font-size:13.5px;line-height:21px;color:{MUTED}">'
|
|
f'{escape(text)}{html}</p>')
|
|
|
|
|
|
def pill(text, tone='ok'):
|
|
background, color = {'ok': ('#E7F4EA', '#1E6B34'), 'info': ('#FFF4E0', DARK_ORANGE)}[tone]
|
|
return (f'<span style="display:inline-block;font-family:{FONT};font-size:12.5px;font-weight:700;'
|
|
f'letter-spacing:0.7px;text-transform:uppercase;background:{background};color:{color};'
|
|
f'border-radius:999px;padding:5px 11px">{escape(text)}</span>')
|
|
|
|
|
|
def code_box(code):
|
|
spaced = ' '.join(escape(code))
|
|
return (f'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">'
|
|
f'<tr><td align="center" style="background:#FFF4E0;border:1px solid #F5D9A8;border-radius:12px;padding:22px">'
|
|
f'<div style="font-family:{FONT};font-size:12px;font-weight:700;letter-spacing:1.2px;'
|
|
f'text-transform:uppercase;color:{DARK_ORANGE}">Seu código</div>'
|
|
f'<div style="font-family:{FONT};font-size:38px;line-height:48px;font-weight:800;letter-spacing:6px;'
|
|
f'color:{INK}">{spaced}</div></td></tr></table>')
|
|
|
|
|
|
def button(text, url, dark=False):
|
|
background, color = (INK, ORANGE) if dark else (ORANGE, '#241703')
|
|
return (f'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center">'
|
|
f'<a href="{escape(url, quote=True)}" style="display:inline-block;background:{background};color:{color};'
|
|
f'font-family:{FONT};font-size:16px;font-weight:800;text-decoration:none;border-radius:10px;'
|
|
f'padding:15px 30px">{escape(text)}</a></td></tr></table>')
|
|
|
|
|
|
def facts(rows):
|
|
cells = ''.join(
|
|
f'<tr><td style="{"" if i == 0 else f"border-top:1px solid {LINE};"}padding:12px 16px;width:92px;'
|
|
f'vertical-align:top;font-family:{FONT};font-size:15px;font-weight:600;color:{MUTED}">{escape(key)}</td>'
|
|
f'<td style="{"" if i == 0 else f"border-top:1px solid {LINE};"}padding:12px 16px 12px 0;'
|
|
f'font-family:{FONT};font-size:15px;line-height:22px;font-weight:500;color:{INK};white-space:pre-line">{escape(value)}</td></tr>'
|
|
for i, (key, value) in enumerate(rows))
|
|
return (f'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" '
|
|
f'style="border:1px solid {LINE};border-radius:12px;border-collapse:separate">{cells}</table>')
|
|
|
|
|
|
def callout(heading, text, warn=False):
|
|
background, border, color = ('#FFF1EC', '#F4C7B6', '#8A2A0A') if warn else ('#F4F2EE', '#E4DFD8', TEXT)
|
|
return (f'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tr>'
|
|
f'<td style="background:{background};border:1px solid {border};border-radius:12px;padding:16px 18px">'
|
|
f'<div style="font-family:{FONT};font-size:15px;font-weight:700;color:{color}">{escape(heading)}</div>'
|
|
f'<div style="font-family:{FONT};font-size:14.5px;line-height:22px;color:{TEXT};padding-top:4px">'
|
|
f'{escape(text)}</div></td></tr></table>')
|
|
|
|
|
|
def steps(items):
|
|
"""The order's stages: (label, hint, done)."""
|
|
rows = []
|
|
for i, (label, hint, done) in enumerate(items):
|
|
top = '' if i == 0 else 'border-top:1px solid #F1EDE7;'
|
|
mark = (f'<div style="width:24px;height:24px;line-height:24px;border-radius:12px;background:{ORANGE};'
|
|
f'color:#241703;font-family:{FONT};font-size:14px;font-weight:800;text-align:center">✓</div>'
|
|
if done else
|
|
'<div style="width:20px;height:20px;border-radius:12px;border:2px solid #D9D3CB;background:#FFFFFF"></div>')
|
|
rows.append(f'<tr><td style="{top}padding:11px 14px 11px 0;width:24px;vertical-align:middle">{mark}</td>'
|
|
f'<td style="{top}padding:11px 0;font-family:{FONT}">'
|
|
f'<div style="font-size:15px;font-weight:{700 if done else 500};color:{INK if done else MUTED}">'
|
|
f'{escape(label)}</div><div style="font-size:13px;line-height:19px;color:{MUTED}">{escape(hint)}</div>'
|
|
f'</td></tr>')
|
|
return (f'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" '
|
|
f'style="border:1px solid {LINE};border-radius:12px;border-collapse:separate;padding:4px 16px">'
|
|
f'{"".join(rows)}</table>')
|
|
|
|
|
|
# The messages ---------------------------------------------------------------
|
|
|
|
def code(name, heading, purpose, digits, minutes, ignore):
|
|
return layout(f'{digits} é o seu código', 'Sua conta', [
|
|
title(heading),
|
|
para(f'{greeting(name)} Use o código abaixo para {purpose}.'),
|
|
code_box(digits),
|
|
small(f'O código vale por {minutes} minutos. Se não foi você que pediu, ignore este e-mail: {ignore}'),
|
|
])
|
|
|
|
|
|
def reset(name, link, minutes):
|
|
hours = 'por 1 hora' if minutes == 60 else f'por {minutes} minutos'
|
|
return layout('Clique no botão para criar uma nova senha.', 'Sua conta', [
|
|
title('Crie uma nova senha'),
|
|
para(f'{greeting(name)} Recebemos um pedido para criar uma nova senha na sua conta. '
|
|
'É só clicar no botão abaixo.'),
|
|
button('Criar nova senha', link),
|
|
small(f'O link vale {hours} e funciona uma vez só. Se não foi você, ignore este e-mail: '
|
|
'sua senha continua a mesma.'),
|
|
small('O botão não abriu? Copie este endereço no navegador: ',
|
|
f'<br><a href="{escape(link, quote=True)}" style="color:{DARK_ORANGE};word-break:break-all">'
|
|
f'{escape(link)}</a>'),
|
|
])
|
|
|
|
|
|
def account_exists(name, login_link):
|
|
return layout('Este e-mail já tem conta no DTF Dropstar.', 'Sua conta', [
|
|
title('Este e-mail já tem uma conta'),
|
|
para(f'{greeting(name)} Alguém tentou criar uma conta no DTF Dropstar com este e-mail, mas ele já está '
|
|
'cadastrado. Para ver seus pedidos, é só entrar.'),
|
|
button('Entrar na minha conta', login_link),
|
|
callout('Esqueceu a senha?', 'Na página de entrada, clique em “Esqueci minha senha” e enviamos um link '
|
|
'para criar outra.'),
|
|
small('Se não foi você, ignore este e-mail: nada muda na sua conta.'),
|
|
])
|
|
|
|
|
|
def email_changed(name, old, new):
|
|
return layout('O e-mail da sua conta foi trocado.', 'Sua conta', [
|
|
title('O e-mail da sua conta foi trocado'),
|
|
para(f'{greeting(name)} A partir de agora, sua conta no DTF Dropstar entra com outro e-mail:'),
|
|
facts([('Antes', old), ('Agora', new)]),
|
|
callout('Não foi você?', 'Fale com a Dropstar agora pelo WhatsApp: a gente ajuda a recuperar a conta.',
|
|
warn=True),
|
|
button('Falar no WhatsApp', WHATSAPP, dark=True),
|
|
])
|
|
|
|
|
|
def order_paid(name, number, rows, link):
|
|
return layout(f'Pagamento aprovado. O pedido #{number} já está com a nossa equipe.', 'Seu pedido', [
|
|
pill('Pagamento aprovado'),
|
|
title(f'Recebemos seu pedido #{number}'),
|
|
para(f'{greeting(name)} Seu pagamento foi aprovado e o pedido já está com a nossa equipe. Agora a gente '
|
|
'confere a arte e coloca na fila de impressão.'),
|
|
facts(rows),
|
|
steps([('Pagamento aprovado', 'Pedido recebido pela equipe', True),
|
|
('Arte conferida', 'A equipe confere se está tudo certo para imprimir', False),
|
|
('Impressão', 'Seu filme entra na máquina', False),
|
|
('Pronto', 'Você recebe o aviso pelo WhatsApp', False)]),
|
|
button('Ver meu pedido', link),
|
|
small('Acompanhe cada etapa em Minha conta. Ainda não tem conta? Crie com este e-mail e o mesmo CPF/CNPJ '
|
|
'do pedido: ele aparece lá na hora.'),
|
|
])
|