Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
SOD/routes/admin/orders/add.js

30 lines
975 B
JavaScript
Raw Normal View History

const express = require("express");
const router = express.Router();
const sessionCheck = require("../../../middlewares/sessionCheck");
const models = require("../../../models");
const addOrder = require("../../utils/addOrder");
router.get("/", sessionCheck(3), async (req, res) => {
res.render("admin/orders/add", {
title: "SOD - Orders administration",
departments: await models.Department.findAll(),
sandwiches: await models.Sandwich.findAll(),
users: await models.User.findAll()
});
}).post("/", sessionCheck(3), async (req, res) => {
await addOrder(req, res, {
department: req.body.department,
firstName: req.body.firstName,
lastName: req.body.lastName,
username: req.body.username,
sandwiches: req.body.sandwiches,
dates: req.body.dates,
paid: req.body.paid,
give: req.body.give
}, false);
res.redirect("/admin/orders");
});
module.exports = router;