-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
89 lines (80 loc) · 4 KB
/
Copy pathscript.js
File metadata and controls
89 lines (80 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Restaurant Signup
document.getElementById('restaurantSignupForm').addEventListener('submit', function(event) {
event.preventDefault();
const name = document.getElementById('restaurantName').value;
const email = document.getElementById('restaurantEmail').value;
const password = document.getElementById('restaurantPassword').value;
// Perform API request to send restaurant signup data
// Example: fetch('/api/restaurant/signup', { method: 'POST', body: JSON.stringify({ name, email, password }) })
// .then(response => response.json())
// .then(data => console.log(data))
// .catch(error => console.error('Error:', error));
});
// Customer Signup
document.getElementById('customerSignupForm').addEventListener('submit', function(event) {
event.preventDefault();
const name = document.getElementById('customerName').value;
const email = document.getElementById('customerEmail').value;
const password = document.getElementById('customerPassword').value;
// Perform API request to send customer signup data
// Example: fetch('/api/customer/signup', { method: 'POST', body: JSON.stringify({ name, email, password }) })
// .then(response => response.json())
// .then(data => console.log(data))
// .catch(error => console.error('Error:', error));
});
// Restaurant Add Dish
document.getElementById('addDishForm').addEventListener('submit', function(event) {
event.preventDefault();
const dishName = document.getElementById('dishName').value;
const description = document.getElementById('dishDescription').value;
const price = document.getElementById('dishPrice').value;
// Perform API request to add dish
// Example: fetch('/api/restaurant/addDish', { method: 'POST', body: JSON.stringify({ dishName, description, price }) })
// .then(response => response.json())
// .then(data => console.log(data))
// .catch(error => console.error('Error:', error));
});
// Customer Place Order
document.getElementById('placeOrderForm').addEventListener('submit', function(event) {
event.preventDefault();
const dishName = document.getElementById('dishName').value;
const quantity = document.getElementById('quantity').value;
// Perform API request to place order
// Example: fetch('/api/customer/placeOrder', { method: 'POST', body: JSON.stringify({ dishName, quantity }) })
// .then(response => response.json())
// .then(data => console.log(data))
// .catch(error => console.error('Error:', error));
});
// Fetch and display list of restaurants
fetch('/api/restaurants')
.then(response => response.json())
.then(restaurants => {
const restaurantsList = document.getElementById('restaurantsList');
restaurants.forEach(restaurant => {
const li = document.createElement('li');
li.textContent = restaurant.name;
li.addEventListener('click', function() {
// Fetch and display available dishes for the selected restaurant
fetch(`/api/restaurant/${restaurant.id}/dishes`)
.then(response => response.json())
.then(dishes => {
// Display dishes for the selected restaurant
})
.catch(error => console.error('Error:', error));
});
restaurantsList.appendChild(li);
});
})
.catch(error => console.error('Error:', error));
// Fetch and display list of orders for the restaurant
fetch('/api/restaurant/orders')
.then(response => response.json())
.then(orders => {
const ordersList = document.getElementById('ordersList');
orders.forEach(order => {
const li = document.createElement('li');
li.textContent = `Order ID: ${order.id}, Dish: ${order.dish}, Quantity: ${order.quantity}`;
ordersList.appendChild(li);
});
})
.catch(error => console.error('Error:', error));