-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.html
80 lines (76 loc) · 2.12 KB
/
home.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>home</title>
</head>
<style>
.button {
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
margin-left: 20px;
text-align: center;
}
.hiddenButton {
color: #FF9900;
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
visibility: hidden;
}
h2 {
text-align: center;
}
input {
color: #232F3E;
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
}
</style>
<script>
async function uploadReceipt() {
// Upload receipt and retrieve dishes info
let receiptList = document.getElementById("receipt").files;
if (receiptList.length === 0) {
alert("No Receipt Uploaded");
return;
}
let receipt = receiptList[0]
let formData = new FormData();
formData.append("receipt", receipt)
fetch("/uploadReceipt", {
method: "POST",
body: formData
})
.then(response => {
if (!response.ok) {
throw new Error("Failed to upload receipt.");
}
console.log("File uploaded successfully.");
displayDishes(response.json())
})
.catch(error => {
console.error(error);
});
}
async function displayDishes(dishes) {
// Populate dish name and price based on receipt result
document.getElementById("dishName");
document.getElementById("dishName");
}
async function submitParticipants() {
}
</script>
<body>
<h2>Upload Receipt</h2>
<form style="text-align:center">
<input type="file" class="button" id="receipt">
<input type="submit" class="button" value="upload" onclick=uploadReceipt()>
</form>
<br>
<form>
<input type="hidden" id="dishName">
<input type="hidden" id="participants">
<input type="submit" class="hiddenButton" value="Submit" onclick="submitParticipants()">
</form>
</body>
</html>