File size: 5,811 Bytes
dcadfe6
 
 
 
 
b67fc0a
dcadfe6
 
 
 
 
 
 
 
 
 
693c27c
 
 
 
 
 
dcadfe6
 
 
777400d
22892e7
dcadfe6
 
 
 
22892e7
dcadfe6
 
 
 
 
 
 
 
 
 
 
b67fc0a
22892e7
 
 
 
777400d
 
 
 
 
 
 
 
 
 
 
 
dcadfe6
 
 
 
 
f617545
3e2ef6a
 
 
 
 
 
 
 
 
 
 
dcadfe6
3e2ef6a
 
 
 
 
 
 
dcadfe6
f617545
dcadfe6
 
b67fc0a
dcadfe6
b67fc0a
 
dcadfe6
 
b67fc0a
 
 
dcadfe6
 
b67fc0a
f617545
 
 
dcadfe6
b67fc0a
 
dcadfe6
b67fc0a
dcadfe6
b67fc0a
 
 
 
 
 
 
dcadfe6
 
 
 
f617545
dcadfe6
f617545
b67fc0a
f617545
dcadfe6
f617545
b67fc0a
dcadfe6
 
f617545
dcadfe6
 
f617545
dcadfe6
f617545
b67fc0a
f617545
dcadfe6
f617545
dcadfe6
 
f617545
dcadfe6
f617545
 
dcadfe6
 
 
 
 
fa43e60
3e2ef6a
dcadfe6
472ac92
ed84006
b67fc0a
 
ed84006
f617545
b67fc0a
 
293542e
f08379b
f617545
ed84006
 
b67fc0a
 
 
 
 
 
 
 
 
 
 
 
 
 
08ca8a7
 
08ff806
ed84006
 
b67fc0a
777400d
ed84006
777400d
 
 
ed84006
f617545
 
 
08ff806
22892e7
 
ed84006
08ff806
f617545
777400d
f617545
 
 
 
 
 
 
 
 
 
 
b67fc0a
ed84006
b67fc0a
 
a01929c
 
f617545
ed84006
b67fc0a
 
f617545
 
a01929c
 
f617545
ed84006
b67fc0a
 
a01929c
 
f617545
ed84006
f617545
 
 
777400d
f617545
 
777400d
f617545
 
 
 
 
 
 
 
 
 
 
 
680f02d
 
f617545
b67fc0a
 
 
a01929c
 
08ff806
ed84006
f617545
 
 
 
08ff806
 
 
 
 
 
b67fc0a
ed84006
a01929c
fa43e60
 
 
 
 
 
 
 
 
dcadfe6
 
 
 
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>NourishNet</title>

<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">

<style>
body{
  font-family:'Inter',sans-serif;
  background:#F7F5F0;
}

.card, .card *{
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}

.card{
  background:white;
  border-radius:16px;
  padding:28px;
  margin-bottom:22px;
  border:1px solid #e5e7eb;
}

.btn{
  padding:10px 16px;
  border-radius:999px;
  font-weight:600;
  cursor:pointer;
}

.high{background:#ef4444;color:white;}
.medium{background:#f59e0b;color:white;}
.low{background:#10b981;color:white;}

.title{font-size:22px;font-weight:800;}
.small{font-size:14px;color:#6b7280;}
.big{font-size:16px;}

.card div{
  line-height:1.5;
}

.recipient-card {
  border: 1px solid #e5e7eb;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 16px;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.recipient-card:hover {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.25);
}
</style>
</head>

<body>

<!-- HEADER -->
 <nav class="flex justify-between items-center px-10 py-5 bg-emerald-600 text-white">

  <a href="log.html" class="text-2xl font-extrabold">
    NourishNet
  </a>

  <div class="hidden md:flex gap-10 font-medium items-center">

    <a href="dashboard.html">Dashboard</a>
    <a href="impact.html" class="hover:opacity-80">Impact</a>
    <a href="leaderboard.html" class="hover:opacity-80">Leaderboard</a>

    <a href="index.html" class="bg-white text-emerald-600 px-4 py-1 rounded-full font-semibold">
      Logout
    </a>

  </div>

</nav>

<!-- INPUT -->
<div class="card">

<h2 class="title">Food Input</h2>

<label>Food Type</label>
<select id="foodType" class="w-full border p-3 rounded-lg mt-2 mb-3">
  <option>Cooked</option>
  <option>Baked</option>
  <option>Vegetarian</option>
  <option>Non-Vegetarian</option>
  <option>Raw Ingredients</option>
</select>

<label>Name / Food Label</label>
<input id="foodName"
class="w-full border p-3 rounded-lg mt-2 mb-3"
placeholder="e.g. biryani, sandwich, raw ingredients">

<label>Portions: <span id="pval">50</span></label>
<input type="range" min="1" max="250" value="50" id="portions" class="w-full">

<label>Expiry</label>
<select id="expiry" class="w-full border p-3 rounded-lg mt-2">
  <option>2-4 hours</option>
  <option>4-6 hours</option>
  <option>6-8 hours</option>
  <option>8-10 hours</option>
  <option>10-12 hours</option>
  <option>24 hours</option>
  <option>48 hours</option>
</select>

</div>

<!-- AI -->
<div class="card">

<h2 class="title">AI Recommendations</h2>

<div id="aiBox">Click Ask AI</div>

<button onclick="runAI()" class="mt-3 bg-emerald-600 text-white px-5 py-2 rounded-full">
Ask AI
</button>

</div>

<!-- MATCHED -->
<div class="card">

<h2 class="title">Matched Recipients</h2>

<div id="matchedBox">No matches yet</div>

</div>

<!-- CONFIRM -->
<div class="text-center">
<button onclick="confirmDonation()"
class="bg-emerald-600 text-white px-8 py-3 rounded-full font-bold">
Confirm Donation
</button>
</div>

</div>
  
 

<script>

let current=[], accepted=[];
const API="https://Infinity-1995-NourishAI.hf.space/analyze";

/* slider */
document.getElementById("portions").oninput=e=>{
document.getElementById("pval").innerText=e.target.value;
};

/* AI */
async function runAI(){

const res=await fetch(API,{
method:"POST",
headers:{"Content-Type":"application/json"},
body:JSON.stringify({
meals:portions.value,
foodType:foodType.value,
foodName:foodName.value,
expiry:expiry.value,
seed:Date.now()
})
});

current=await res.json();
renderAI();
}

/* AI LIST */
function renderAI(){

aiBox.innerHTML=current.map((x,i)=>`
<div class="recipient-card">

<div class="font-bold text-lg mb-1">${x.recipient}</div>
<div class="small mb-2">${x.km} km</div>
<div class="mb-3">${x.reason}</div>

<span class="btn ${
x.priority=="High"?"high":
x.priority=="Medium"?"medium":"low"
}" style="display:inline-block;margin-bottom:16px;">
${x.priority}
</span>

<div class="flex gap-3 flex-wrap">

<button class="btn"
style="background:#10b981;color:white"
onclick="accept(${i})">
Accept
</button>

<button class="btn"
style="background:#ef4444;color:white"
onclick="rejectAI(${i})">
Reject
</button>

</div>

</div>
`).join("");
}

/* accept */
function accept(i){
accepted.push(current[i]);
current.splice(i,1);
renderAI();
renderAccepted();
}

/* reject */
function rejectAI(i){
current.splice(i,1);
renderAI();
}

/* matched */
function renderAccepted(){

matchedBox.innerHTML=accepted.length?
accepted.map((a,i)=>`
<div class="recipient-card" style="display:flex;justify-content:space-between;align-items:center;">

<div>
<div class="font-bold mb-1">${a.recipient}</div>
<div class="small">${a.km} km</div>
</div>

<button class="btn"
style="background:#ef4444;color:white"
onclick="remove(${i})">
Reject
</button>

</div>
`).join("")
:"No matches yet";
}

/* remove matched */
function remove(i){
accepted.splice(i,1);
renderAccepted();
}

/* CHANGED: also save portions, foodType, foodName */
function confirmDonation(){
if(accepted.length==0){
alert("Select recipients");
return;
}
localStorage.setItem("donationData", JSON.stringify({
  accepted,
  portions: document.getElementById("portions").value,
  foodType: document.getElementById("foodType").value,
  foodName: document.getElementById("foodName").value
}));
location.href="confirmation.html";
}

</script>
  <div id="footer"></div>

<script>
fetch("footer.html")
  .then(res => res.text())
  .then(data => {
    document.getElementById("footer").innerHTML = data;
  });
</script>

</body>
</html>