diff --git a/routes/index.js b/routes/index.js index e260bad..06782a0 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,9 +1,11 @@ let express = require("express"); let router = express.Router(); +let models = require("../models"); -/* GET home page. */ -router.get("/", (req, res) => { - res.render("index", { title: "SOD" }); +router.get("/", async (req, res) => { + let departments = await models.Department.findAll(); + let sandwichs = await models.Sandwich.findAll(); + res.render("index", { title: "SOD", departments: departments, sandwichs: sandwichs }); }); module.exports = router; diff --git a/views/index.pug b/views/index.pug index 6cd81cc..f215b47 100644 --- a/views/index.pug +++ b/views/index.pug @@ -6,14 +6,11 @@ block content p Welcome to Sandwiches Order Doua form#command(action="/command" method="POST") div.field - label(for="department") Department: + label(for="sandwich") Department: input#department(type="list" list="department-list" name="department" required) datalist#department-list - option(value="Info") - option(value="Bio") - option(value="Chimi") - option(value="GC") - option(value="GEA") + each department in departments + option(value=department.name) div.field label(for="firstname") First name: @@ -39,13 +36,14 @@ block content input#send(type="submit" value="Pay") datalist#sandwich-list - option(value="Jambon beurre") + each sandwich in sandwichs + option(value=sandwich.name) datalist#date-list option(value="14/08/2020") div#more - a(href="#about") About - a(href="#contact") Contact + a About + a Contact div#dark.hide div#about.card.hide