var tonicExpress = require("@runkit/runkit/express-endpoint/1.0.0");
// Just provide the exports object to the tonicExpress helper
var app = tonicExpress(module.exports);
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: true}));
app.get("/", (req, res) => {
res.send(`
<html>
<body>
<div style="width:400px;padding:40px;font-family: Arial, Helvetica, sans-serif;margin:0 auto;border:1px solid #000;text-align:center;">
<img width="200" height="60" src="https://asset.woopit.fr/woop_logo.png">
<form action="/signature" method="post">
<p><label for="firstname" style="width:100px;display:inline-block;">Prénom*</label>
<input type="text" id="firstname" name="firstname" required minlength="4" size="25" required /></p>
<p><label for="name" style="width:100px;display:inline-block;">Nom*</label>
<input type="text" id="name" name="name" required minlength="4" size="25" required /></p>
<p><label for="email" style="width:100px;display:inline-block;">Email*</label>
<input type="text" id="email" name="email" required minlength="4" size="25" required /></p>
<p><label for="tel" style="width:100px;display:inline-block;">Tel</label>
<input type="text" id="tel" name="tel" value="+33.6." size="25" /></p>
<p><label for="fonc" style="width:100px;display:inline-block;">Poste*</label>
<input type="text" id="fonc" name="fonc" required minlength="2" size="25" required /></p>
<input type="submit" value="Envoyer" />
<br><br>
<span style="font-size: 12px">* : Champ obligatoire</span>
</form>
</div>
</body>
</html>
`);
});
app.post("/signature", (req, res) => {
const name = req.body.name;
const firstname = req.body.firstname;
const email = req.body.email;
const fonc = req.body.fonc;
const tel = req.body.tel;
res.send(`
<div style="padding:80px;">
<table cellpadding="0" cellspacing="0" border="0" style="background:none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td style="width:25%; text-align: center; padding-top: 0; padding-bottom: 5px; padding-right: 20px; border-top: 0; border-bottom: 0; border-left: 0;border-right:5px solid #FFE000;">
<img width="219" height="70" src="https://asset.woopit.fr/logo-woopV2.png">
<br>
<br>
<img width="230" height="48" src="https://asset.woopit.fr/woop-signature-trophees.png">
</td>
<td style="min-width:75%; width: 350px; padding-top: 0; padding-bottom: 0; padding-left: 20px; padding-right: 20px;">
<p style="margin: 5px; font-size: 17px; font-family: Arial, Helvetica, sans-serif; font-weight:bold;">${firstname} <span style="text-transform: uppercase;">${name}</span></p>
<p style="margin: 5px; font-size: 14px; font-family: Arial, Helvetica, sans-serif;font-weight:300;text-transform: uppercase;">${fonc}</p>
<p style="margin: 5px; font-size: 12px; font-family: Arial, Helvetica, sans-serif;">${tel}</p>
<p style="margin-top: 5px;margin-left:5px; margin-bottom:0; font-size: 12px; font-family: Arial, Helvetica, sans-serif;"><a style="color:#000;text-decoration:none!important;font-weight:bold;" href="mailto:${email}" target="_blank">${email}</a></p>
<p style="margin-bottom: 5px; margin-top:0; margin-left:5px; font-size: 12px; font-family: Arial, Helvetica, sans-serif;"><a style="color:#000;text-decoration:none!important;font-weight:bold;" href="https://www.woopit.fr/" target="_blank">woopit.fr</a></p>
<p style="margin: 5px;"><a style="color:#000;" href="https://www.linkedin.com/company/woopit/mycompany/" target="_blank"><img width="20px" height="20px" src="https://asset.woopit.fr/32x32-linkedin.png" /></a> <a style="color:#000;" href="https://www.facebook.com/WOOP-101457364954719/" target="_blank"><img width="20px" height="20px" src="https://asset.woopit.fr/32x32-facebook.png" /></a> <a style="color:#000;" href="https://twitter.com/letswoopit" target="_blank"><img width="20px" height="20px" src="https://asset.woopit.fr/32x32-twitter.png" /></a>
</td>
</tr>
</table>
<!--<p style="margin:20px 0 0 0;"><a href="https://www.trophees.ecommercemag.fr/content/prix-du-public-votes" target="_blank"><img src="https://asset.woopit.fr/woop_signature-tropheev3.gif" /></a></p>-->
</div>
`);
});