feat(issue22): Sends confirmation email to client

Also, adds the JSON configuration in order to be sent to the client
as a "reminder" of what he sends
master
sovanna 2020-04-15 10:41:40 +09:00
parent a61ebbdff6
commit 0758e2d2ba
2 changed files with 22 additions and 2 deletions

View File

@ -32,6 +32,10 @@ def send_rfq():
resp = jsonify(error="missing body")
return make_response(resp, 400)
if "configuration" not in payload:
resp = jsonify(error="missing configuration")
return make_response(resp, 400)
recipient = current_app.config["MAIL_RECIPIENT"]
msg = Message(
@ -39,10 +43,25 @@ def send_rfq():
reply_to=recipient,
sender=payload["email"],
recipients=[recipient])
msg.body = payload["body"]
msg.html = payload["body"]
mail.send(msg)
msg_client_confirmation = Message(
"[M-Labs - Order Hardware]",
reply_to=recipient,
sender=recipient,
recipients=[payload["email"]])
msg_client_confirmation.body = "Hello! We've received your request and " \
"will be in contact soon. " \
"Here is a reminder of your configuration: {}" \
"Thank you!".format(payload["configuration"])
msg_client_confirmation.html = "Hello!<br />" \
"We've received your request and will be in contact soon.<br />" \
"Here is a reminder of your configuration: {}<br /><br />" \
"Thank you!".format(payload["configuration"])
with mail.connect() as conn:
conn.send(msg)
conn.send(msg_client_confirmation)
return jsonify("ok")

View File

@ -1860,6 +1860,7 @@ class Shop extends React.PureComponent {
axios.post(data.API_RFQ, {
email,
body,
configuration: JSON.stringify(crate),
headers: {'X-MLABS-OH': 'rlebcleu'}
}).then(response => {
this.setState({