Skip to content
Snippets Groups Projects
Commit a20dc64f authored by Mamadu-lamarana Bah's avatar Mamadu-lamarana Bah :speech_balloon:
Browse files

code review

parent f3560584
Branches
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ const addToList = (show,list) => { ...@@ -42,7 +42,7 @@ const addToList = (show,list) => {
list.appendChild(node); list.appendChild(node);
} }
// fetch DELETE to delete one task with given task id // fetch DELETE to delete one task with given show id
const deleteShow = const deleteShow =
async showId => { async showId => {
const requestOptions = { const requestOptions = {
...@@ -59,7 +59,7 @@ const deleteShow = ...@@ -59,7 +59,7 @@ const deleteShow =
} }
} }
// fetch POST to create one task // fetch POST to create one show
const createShow = const createShow =
async () => { async () => {
const newShowData = { const newShowData = {
......
...@@ -28,7 +28,7 @@ const displayShowList = async () => { ...@@ -28,7 +28,7 @@ const displayShowList = async () => {
const requestOptions = { const requestOptions = {
method: 'GET' method: 'GET'
}; };
const response = await fetch('/admin/items', requestOptions) const response = await fetch('/items', requestOptions)
if (response.ok) { if (response.ok) {
const allShows = await response.json(); const allShows = await response.json();
//(ici : code exploitation de allShows) //(ici : code exploitation de allShows)
......
const displayList = async () => {
const requestOptions = {
method : 'GET'
};
const response = await fetch('/items', requestOptions)
const allShows = await response.json();
//(ici : code exploitation de allShows)
const list = document.getElementById('list');
list.textContent = '';
allShows.forEach( show => addToList(show, list) );
}
const addToList = (show,list) => {
const node = document.createElement('div');
node.className = 'show';
node.textContent = `${show.description} (${show.places})`;
//
//node.addEventListener('mouseover', () => getTask(show._id));
//
const deleteButton = document.createElement('button');
deleteButton.className = 'ticket';
deleteButton.addEventListener('click', () => deleteShow(show._id));
deleteButton.textContent = '+1 tickets';
node.appendChild(deleteButton);
//
list.appendChild(node);
}
module.exports.displayList = displayList;
\ No newline at end of file
...@@ -8,11 +8,15 @@ div { ...@@ -8,11 +8,15 @@ div {
margin: auto; margin: auto;
padding: 2px; padding: 2px;
text-align: center; text-align: center;
overflow: hidden;
box-sizing: border-box;
border: solid thin #999;
} }
div label { div label {
padding: 7px; padding: 7px;
} }
input { input {
text-align: center; text-align: center;
} }
...@@ -20,6 +24,7 @@ input { ...@@ -20,6 +24,7 @@ input {
#place { #place {
width: 10px; width: 10px;
} }
button { button {
padding: 3px; padding: 3px;
width: 100px; width: 100px;
...@@ -28,14 +33,16 @@ button { ...@@ -28,14 +33,16 @@ button {
} }
#shows, #tickets { #shows, #tickets {
margin : 10px;
padding: 4px; padding: 4px;
border: solid thin #999; border: solid thin #999;
} }
#list, #shows { #list, #shows {
padding: 2px; padding: 2px;
margin : 4px 4px; }
#list, #showTickets{
overflow: auto;
} }
.tickets { .tickets {
...@@ -50,11 +57,12 @@ div.reservation:nth-of-type(even), div.show:nth-of-type(even) { ...@@ -50,11 +57,12 @@ div.reservation:nth-of-type(even), div.show:nth-of-type(even) {
#userdata { #userdata {
background-color: #DDD; background-color: #DDD;
} }
#userdata div { #userdata div {
text-align: center; text-align: center;
margin: 2px; margin: 2px;
} }
#controls { #controls {
margin-top: 10px; margin-top: 10px;
} }
...@@ -8,11 +8,15 @@ div { ...@@ -8,11 +8,15 @@ div {
margin: auto; margin: auto;
padding: 2px; padding: 2px;
text-align: center; text-align: center;
overflow: hidden;
box-sizing: border-box;
border: solid thin #999;
} }
div label { div label {
padding: 7px; padding: 7px;
} }
input { input {
text-align: center; text-align: center;
} }
...@@ -20,6 +24,7 @@ input { ...@@ -20,6 +24,7 @@ input {
#place { #place {
width: 10px; width: 10px;
} }
button { button {
padding: 3px; padding: 3px;
width: 100px; width: 100px;
...@@ -28,14 +33,16 @@ button { ...@@ -28,14 +33,16 @@ button {
} }
#shows, #tickets { #shows, #tickets {
margin : 10px;
padding: 4px; padding: 4px;
border: solid thin #999; border: solid thin #999;
} }
#list, #shows { #list, #shows {
padding: 2px; padding: 2px;
margin : 4px 4px; }
#list, #showTickets{
overflow: auto;
} }
.tickets { .tickets {
...@@ -50,11 +57,12 @@ div.reservation:nth-of-type(even), div.show:nth-of-type(even) { ...@@ -50,11 +57,12 @@ div.reservation:nth-of-type(even), div.show:nth-of-type(even) {
#userdata { #userdata {
background-color: #DDD; background-color: #DDD;
} }
#userdata div { #userdata div {
text-align: center; text-align: center;
margin: 2px; margin: 2px;
} }
#controls { #controls {
margin-top: 10px; margin-top: 10px;
} }
...@@ -6,10 +6,8 @@ const authMiddleware = require('../middlewares/authentication.middleware'); ...@@ -6,10 +6,8 @@ const authMiddleware = require('../middlewares/authentication.middleware');
router.get('/', adminController.home ); router.get('/', adminController.home );
router.get('/me', authMiddleware.validToken, adminController.me ); router.get('/items', authMiddleware.validToken, authMiddleware.isAdmin, adminController.list);
router.get('/items', authMiddleware.validToken, adminController.list);
router.post('/items', authMiddleware.validToken, authMiddleware.isAdmin, adminController.create); router.post('/items', authMiddleware.validToken, authMiddleware.isAdmin, adminController.create);
router.delete('/:showId', authMiddleware.validToken, authMiddleware.isAdmin, adminController.deleteShow); router.delete('/:showId', authMiddleware.validToken, authMiddleware.isAdmin, adminController.deleteShow);
// router.put('/me', authMiddleware.validToken, adminController.update );
module.exports = router; module.exports = router;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment