Permalink
Browse files

HW walk through in-class

  • Loading branch information...
laustinr90 committed Feb 14, 2020
1 parent 01c7bd9 commit 270a0895f6e13ef0d123bd53e9bf913e2b642d6e
Showing with 24 additions and 10 deletions.
  1. +7 −4 controllers/shop.js
  2. +1 −1 server.js
  3. +5 −2 views/shops/create.hbs
  4. +11 −3 views/shops/shop.hbs
@@ -43,8 +43,11 @@ shopRouter.get('/new', function(req, res) {
})

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

shopRouter.post('/', function(req,res){
@@ -54,12 +57,12 @@ shopRouter.post('/', function(req,res){

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

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


@@ -35,7 +35,7 @@ app.use(express.urlencoded())
* ...to parse the body of the HTTP requests from a JSON string
* replace the above line with this
*/
app.use(express.json())
//app.use(express.json())

/* Step 3.b
*
@@ -1,7 +1,10 @@
<form method="POST" action="/shops">
<input type="text" value="{{<TODO: model.stringMember (e.g: account.name)}}" placeholder="name" name="<TODO: stringMember (e.g: name)>" />
Name:<input type="text" name="name" value="{{ shop.name }}" />

<input type="checkbox" name="<TODO: model.booleanMember (e.g: account.isActive)" value="true" />
Employees:<input type="number" name="employees" value="{{ shop.employees }}" />

currentlyOpen:<input type="checkbox" name="currentlyOpen"
{{#if shop.currentlyOpen }} checked {{/if}} />

<input type="submit" value="Create Shop" />
</form>
@@ -1,7 +1,15 @@
<form method="POST" action="/shops?_method=PUT">
<input type="text" value="{{<TODO: model.stringMember (e.g: account.name)}}" placeholder="name" name="<TODO: stringMember (e.g: name)>" />
<form method="POST" action="/shops/{{ index }}?_method=PUT">
Name:<input type="text" name="name" value="{{ shop.name }}" />

<input type="checkbox" name="<TODO: model.booleanMember (e.g: account.isActive)" value="true" />
Employees:<input type="number" name="employees" value="{{ shop.employees }}" />

currentlyOpen:<input type="checkbox" name="currentlyOpen"
{{#if shop.currentlyOpen }} checked {{/if}} />

<input type="submit" value="Create Shop" />
</form>


<form action="/shops/{{ index }}?_method=DELETE" method="POST">
<input type="submit" value="Delete Shop" >
</form>

0 comments on commit 270a089

Please sign in to comment.