Skip to content

Commit

Permalink
[ft #161859707] integrated admin view attendants
Browse files Browse the repository at this point in the history
  • Loading branch information
Easybuoy committed Nov 10, 2018
1 parent f98caa0 commit 00993b6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
7 changes: 4 additions & 3 deletions client/admin_view_attendants.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

</head>

<body>
<body onload="viewAllAttendants()">

<nav class="navbar">
<span class="open-slide">
Expand Down Expand Up @@ -52,7 +52,7 @@
<section id="productsection" class="topmargin">
<div class="container">

<div class="cardgroup">
<div class="cardgroup" id="adminviewattendants">

<div class="card">
<a href="view_product_details.html"><img src="../assets/uploads/users/default-avatar.png" class="cardimg"></a>
Expand Down Expand Up @@ -175,8 +175,9 @@ <h3 id="productname">Name: Attendant 1</h3>
<footer id="footer">
<p>Store Manager Copyright &copy; 2018</p>
</footer>

<script src="js/middleware.js"></script>
<script src="js/main.js"></script>
<script src="js/auth.js"></script>
</body>

</html>
54 changes: 53 additions & 1 deletion client/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,56 @@ const createAttendant = () => {
return alert('Error Creating User, Try again');
});
});
}
};

const viewAllAttendants = () => {
let status = 0;
request('/auth/attendants', 'GET')
.then(res => {
status = res.status;
return res.json();
})
.then(data => {
switch (status) {
case 200:
let adminviewattendants = document.getElementById('adminviewattendants');
let output = '';

data.data.map((attendant) => {
let attendant_image = `${this.base_url}${attendant.userimage}`;
output += `
<div class="card">
<a><img src="${attendant_image}" class="cardimg"></a>
<div class="text-center cardbody" >
<h3 id="productname">Name: ${attendant.name}</h3>
<p>Email: ${attendant.email}</p>
<p>Attendance: -</p>
<p>Product Sold: -</p>
<button class="button_3" >Promote</button>
<button class="button_2" >Delete</button>
</div>
</div>
`;

})

adminviewattendants.innerHTML = output;
break;
case 400:
alert(data.message);
break;
case 404:
alert(data.message);
break;
case 401:
alert('Kindly login to view attendants');
break;
default:
return alert('Error Fetching Attendants, Please try again');
}
console.log(data)

})
};

0 comments on commit 00993b6

Please sign in to comment.