From 0758e2d2bad909750a49f9278c5e7f6597eb4fbf Mon Sep 17 00:00:00 2001 From: sovanna Date: Wed, 15 Apr 2020 10:41:40 +0900 Subject: [PATCH] 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 --- server/app/api/routes.py | 23 +++++++++++++++++++++-- static/js/shop.jsx | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/server/app/api/routes.py b/server/app/api/routes.py index 1fe74b7..5664b0c 100644 --- a/server/app/api/routes.py +++ b/server/app/api/routes.py @@ -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!
" \ + "We've received your request and will be in contact soon.
" \ + "Here is a reminder of your configuration: {}

" \ + "Thank you!".format(payload["configuration"]) + + with mail.connect() as conn: + conn.send(msg) + conn.send(msg_client_confirmation) return jsonify("ok") diff --git a/static/js/shop.jsx b/static/js/shop.jsx index 8d903db..f21d796 100644 --- a/static/js/shop.jsx +++ b/static/js/shop.jsx @@ -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({