-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Housekeeping, added order history page for customer. Needs work.
- Loading branch information
Showing
13 changed files
with
299 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{% extends 'dashboard-layout.html' %} | ||
{% block head %} | ||
<title>Dashboard: Active Orders</title> | ||
<link href="/styles/dashboard-customerorders.css" rel="stylesheet" type="text/css"> | ||
<link href="/styles/order-page-orders.css" rel="stylesheet" type="text/css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/> | ||
{% endblock %} | ||
|
||
{% block body %} | ||
<div class="title"> | ||
<h2>Order History</h2> | ||
<!-- will prob display different stuff here based on employee --> | ||
</div> | ||
<div class="orderlist" id="orderlist"></div> | ||
<div class="displayblock" id="displayblock" onclick="closeModel()"> | ||
</div> | ||
<div class="ordermodel" id="ordermodel" onclick=""> | ||
<div class="order-container"> | ||
<h1 class="order-id"></h1> | ||
<div class="order-items" id="order-items"></div> | ||
<div class="order-cost" id="order-cost"></div> | ||
<div class="order-status" id="order-status"></div> | ||
<div class="ratingscontainer"> | ||
<div class ="stars"> | ||
<input type="radio" name="rate" id ="rate5"> | ||
<label for="rate5" class="fas fa-star"></label> | ||
<input type="radio" name="rate" id ="rate4"> | ||
<label for="rate4" class="fas fa-star"></label> | ||
<input type="radio" name="rate" id ="rate3"> | ||
<label for="rate3" class="fas fa-star"></label> | ||
<input type="radio" name="rate" id ="rate2"> | ||
<label for="rate2" class="fas fa-star"></label> | ||
<input type="radio" name="rate" id ="rate1"> | ||
<label for="rate1" class="fas fa-star"></label> | ||
</div> | ||
<form action="#"> | ||
<div class="textarea"> | ||
<textarea cols="30"></textarea> | ||
</div> | ||
<div class="btn"> | ||
<button type="submit">Submit Rating</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
<div> | ||
<button onclick="closeModel()">Close</button> | ||
</div> | ||
</div> | ||
<!-- <script src="/scripts/showstatus.js"></script> --> | ||
<script src="/scripts/dashboard-customerorders.js"></script> | ||
<script src="/scripts/order-page-orders.js"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,5 +48,5 @@ function reload() { | |
reload(); | ||
|
||
setInterval(() => { | ||
reload(); | ||
if (!doNotReload) reload(); | ||
}, 10000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
async function getCurrentOrders() { | ||
const response = await fetch('/api/order/fromcustomer'); | ||
const data = await response.json(); | ||
console.log(data['response']); | ||
|
||
return data['response']; | ||
} | ||
|
||
async function showOrders() { | ||
let container = document.getElementById('orderlist'); | ||
|
||
let orders = await getCurrentOrders(); | ||
|
||
if (orders.length > 0) { | ||
orders.forEach(order => { | ||
let orderdiv = createElement("a", {class: `orderdiv ${order['status']}`, href: "javascript:void(0)", onclick: `loadOrder(${order['orderID']})`}); | ||
Array.from(["orderID", "datetime", "deliveryMethod", "status", "cost"]).forEach(attrib => { | ||
let element = createElement("p", {text: `${attrib.charAt(0).toUpperCase() + attrib.slice(1)} : ${order[attrib]}`, class: attrib}); | ||
orderdiv.appendChild(element); | ||
}); | ||
container.appendChild(orderdiv); | ||
}); | ||
} | ||
else { | ||
let textdiv = createElement("div", {class : "noOrders"}); | ||
let text = createElement("p", {text: "There are no active orders available. Please check back in a minute.", class: "noOrdersText"}); | ||
textdiv.appendChild(text); | ||
container.appendChild(textdiv); | ||
} | ||
} | ||
|
||
function eraseOrders() { | ||
let orders = document.getElementsByClassName('orderdiv'); | ||
if (orders.length > 0){ | ||
Array.from(orders).forEach(element => { | ||
element.remove(); | ||
}); | ||
} | ||
} | ||
|
||
showOrders(); | ||
// function reload() { | ||
// eraseOrders(); | ||
// showOrders(); | ||
// } | ||
|
||
// reload(); | ||
|
||
// setInterval(() => { | ||
// if (!doNotReload) reload(); | ||
// }, 10000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Information update == customers Only for now. | ||
|
||
async function updateCustomerInfo(){ | ||
let data = parseInfo(); | ||
if (confirm("Are you sure you want to update your information?")) { | ||
response = await updateInfoDB(data); | ||
if (data['name'] == response['name'] && data['number'] == response['number']) { | ||
alert("Your information has been updated successfuly!"); | ||
} | ||
else{ | ||
alert("There's been an error updating your information, changes have been made."); | ||
} | ||
location.reload(); | ||
} | ||
} | ||
|
||
function parseInfo() { | ||
let name = document.getElementById("fullname").value; | ||
let number = document.getElementById("phone").value; | ||
|
||
return {name, number}; | ||
} | ||
|
||
async function filltextboxes() { | ||
let data = await getCustomerInfo(); | ||
document.getElementById("fullname").value = data['name']; | ||
document.getElementById("phone").value = data['number']; | ||
} | ||
|
||
async function getCustomerInfo() { | ||
const response = await fetch("/api/customer/editcustomer"); | ||
const data = await response.json(); | ||
return data['response']; | ||
} | ||
|
||
async function updateInfoDB(newinfo) { | ||
const response = await fetch("/api/customer/editcustomer", { | ||
method: 'PUT', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(newinfo), | ||
}); | ||
const data = await response.json(); | ||
return data['response']; | ||
} | ||
|
||
filltextboxes(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.