Skip to content

Commit

Permalink
ch[#161862452] Get sales record from api
Browse files Browse the repository at this point in the history
  • Loading branch information
ebenezerdon committed Nov 10, 2018
1 parent 210b161 commit 2868bfc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 49 deletions.
10 changes: 5 additions & 5 deletions UI/assets/js/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ const getProducts = () => {
.then(res => res.json())
.then((data) => {
let output;
data.forEach((user) => {
console.log(user.productimage);
data.forEach((product) => {
console.log(product.productimage);
output = `
<div class='product'>
<div class='product-item hover-effect'>
<a href="product-item.html">
<img src=${user.productimage} width='300'>
<img src=${product.productimage} width='300'>
</a>
<a href='product-item.html'>
<p>${user.productname}</p>
<p>${user.price}</p>
<p>${product.productname}</p>
<p>${product.price}</p>
</a>
<button>Add to cart</button>
<div>
Expand Down
26 changes: 26 additions & 0 deletions UI/assets/js/sales.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const getSales = () => {
fetch('https://newstoremanager.herokuapp.com/api/v1/sales', {
headers: {
'Content-Type': 'application/json',
accesstoken: localStorage.accesstoken,
},
})
.then(res => res.json())
.then((data) => {
let output;
data.forEach((sales) => {
output = `
<tr>
<td>${sales.created_at}</td>
<td>${sales.productname}</td>
<td>${sales.quantity}</td>
<td>${sales.price}</td>
<td>${sales.attendant_id}</td>
</tr>
`;
document.getElementById('sales-record').innerHTML += output;
});
});
};

window.onload = getSales();
46 changes: 2 additions & 44 deletions UI/pages/salesrecord.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,61 +39,19 @@
</header>

<main>
<table>
<table id="sales-record">
<tr>
<th>Date</th>
<th>Name of Product</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Attendant</th>
</tr>
<tr>
<td>8th July, 2018</td>
<td>Long Sleeve Hooded T Shirt</td>
<td>3</td>
<td>₦3,300</td>
<td>Josh Odogwu</td>
</tr>
<tr>
<td>8th July, 2018</td>
<td>Long Sleeve Hooded T Shirt</td>
<td>3</td>
<td>₦3,300</td>
<td>Josh Odogwu</td>
</tr>
<tr>
<td>8th July, 2018</td>
<td>Long Sleeve Hooded T Shirt</td>
<td>3</td>
<td>₦3,300</td>
<td>Josh Odogwu</td>
</tr>
<tr>
<td>8th July, 2018</td>
<td>Long Sleeve Hooded T Shirt</td>
<td>3</td>
<td>₦3,300</td>
<td>Josh Odogwu</td>
</tr>
<tr>
<td>8th July, 2018</td>
<td>Long Sleeve Hooded T Shirt</td>
<td>3</td>
<td>₦3,300</td>
<td>Josh Odogwu</td>
</tr>
<tr>
<td>8th July, 2018</td>
<td>Long Sleeve Hooded T Shirt</td>
<td>3</td>
<td>₦3,300</td>
<td>Josh Odogwu</td>
</tr>

</table>
</main>

<footer></footer>
<script type="text/javascript" src="../assets/js/sales.js"></script>
</body>

</html>

0 comments on commit 2868bfc

Please sign in to comment.