Browse Source

show result message with design

Outsider 9 years ago
parent
commit
bcb6b6634f
3 changed files with 40 additions and 14 deletions
  1. 15 2
      routes/index.js
  2. 10 12
      views/error.jade
  3. 15 0
      views/result.jade

+ 15 - 2
routes/index.js

@@ -24,9 +24,22 @@ router.post('/invite', function(req, res) {
         if (err) { return res.send('Error:' + err); }
         body = JSON.parse(body);
         if (body.ok) {
-          res.send('Success! Check "'+ req.body.email +'" for an invite from Slack.');
+          res.render('result', {
+            community: config.community,
+            message: 'Success! Check "'+ req.body.email +'" for an invite from Slack.'
+          });
         } else {
-          res.send('Failed! ' + body.error)
+          var error = body.error;
+          if (error === 'already_invited') {
+            error = 'You are already invited.'
+          } else if (error === 'invalid_email') {
+            error = 'The email you entered is an invalid email.'
+          }
+
+          res.render('result', {
+            community: config.community,
+            message: 'Failed! ' + error
+          });
         }
       });
   } else {

+ 10 - 12
views/error.jade

@@ -1,17 +1,15 @@
 doctype html
 html
   head
+    meta(http-equiv="Content-Type", content="text/html; charset=utf-8")
+    meta(name="viewport", content="width=device-width, initial-scale=1")
     title Join the #{community} community on Slack!
-    style.
-      body {
-        padding: 50px;
-        font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
-      }
-      input {
-        font-size: 24px;
-        width: 400px;
-      }
+    link(href="css/style.css", rel="stylesheet", type="text/css")
+    link(href="http://fonts.googleapis.com/css?family=Lato:300,400,700,900,700italic|Open+Sans:700italic,400,600,300,700,800", rel="stylesheet", type="text/css")
   body
-    h1= message
-    h2= error.status
-    pre #{error.stack}
+    #wrapper
+      .main
+        .header
+          h1= message
+          h2= error.status
+          pre #{error.stack}

+ 15 - 0
views/result.jade

@@ -0,0 +1,15 @@
+doctype html
+html
+  head
+    meta(http-equiv="Content-Type", content="text/html; charset=utf-8")
+    meta(name="viewport", content="width=device-width, initial-scale=1")
+    title Join the #{community} community on Slack!
+    link(href="css/style.css", rel="stylesheet", type="text/css")
+    link(href="http://fonts.googleapis.com/css?family=Lato:300,400,700,900,700italic|Open+Sans:700italic,400,600,300,700,800", rel="stylesheet", type="text/css")
+  body
+    #wrapper
+      .main
+        .header
+          h1
+            strong #{community}
+          h2= message