Permalink
Browse files

updated

  • Loading branch information...
BellaJCo
BellaJCo committed Feb 14, 2020
1 parent 788d9a3 commit 7369b2e1265d0972652a656607e60c2c2d1b0b1a
Showing with 18 additions and 16 deletions.
  1. +8 −6 controllers/shop.js
  2. 0 { → views/shops}/create.hbs
  3. +9 −0 views/shops/shop.hbs
  4. +1 −10 views/shops/shops.hbs
@@ -32,17 +32,18 @@ const shopRouter = express.Router()
/* Step 4
*
*/

//s1-3
shopRouter.get('/', function(req,res) {
res.render(shopsApi.getShops());
res.render('/shops/shops', { shops: shopsApi.getShops()});
})

shopRouter.get('/new', function(req, res) {
res.render(shops:createShop(req.params.index));
res.render('shops/create', {shop: shopsApi.createShop() });
})

shopRouter.get('/shops/shop', function(req,res){
res.send(shopsApi.getShop(req.params.index));
shopRouter.get('/:index', function(req,res){
const index = req.params.index
res.render('shops/shop', {shop: shopsApi.getShop(index), index});
})

shopRouter.post('/', function(req,res){
@@ -56,9 +57,10 @@ shopRouter.put('/:index', function(req,res){
res.status(200).end();
})

shopRouter.delete('/shops', function(req,res){
shopRouter.delete('/:index', function(req,res){
shopsApi.deleteShop(req.params.index)
res.status(200).end();
res.redirect('/shops')
})


File renamed without changes.
@@ -0,0 +1,9 @@
<form action="/shops?_method=PUT" method="POST">
<input type="text" name="description" placeholder="Enter todo description">
<input type="submit" value="Sign Up" class="btn">
</form>

<form action="/shops?_method=DELETE" method="POST">
<input type="text" name="description" placeholder="Enter todo description">
<input type="submit" value="Sign Up" class="btn">
</form>
@@ -1,15 +1,6 @@
<ul>
{{#each shops}}
<li>{{ shop }}</li>
<li><a href="/shops/{{@index}}">{{name}}</a></li>
{{/each}}
</ul>

<form action="/shops?_method=PUT" method="POST">
<input type="text" name="description" placeholder="Enter todo description">
<input type="submit" value="Sign Up" class="btn">
</form>

<form action="/shops?_method=DELETE" method="POST">
<input type="text" name="description" placeholder="Enter todo description">
<input type="submit" value="Sign Up" class="btn">
</form>

0 comments on commit 7369b2e

Please sign in to comment.