Spaces:
Running
Running
Update log.html
Browse files
log.html
CHANGED
|
@@ -5,8 +5,6 @@
|
|
| 5 |
<title>Log Surplus - NourishNet</title>
|
| 6 |
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
-
<script src="supabase.js"></script>
|
| 9 |
-
|
| 10 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
|
| 11 |
|
| 12 |
<style>
|
|
@@ -19,6 +17,7 @@ body {
|
|
| 19 |
transition: all 0.3s ease;
|
| 20 |
border: 1px solid #e5e7eb;
|
| 21 |
}
|
|
|
|
| 22 |
.card:hover {
|
| 23 |
transform: translateY(-6px);
|
| 24 |
border: 1px solid #10b981;
|
|
@@ -27,7 +26,6 @@ body {
|
|
| 27 |
|
| 28 |
.active-match {
|
| 29 |
border: 2px solid #10b981 !important;
|
| 30 |
-
box-shadow: 0 10px 25px rgba(16,185,129,0.2);
|
| 31 |
}
|
| 32 |
</style>
|
| 33 |
</head>
|
|
@@ -40,8 +38,8 @@ body {
|
|
| 40 |
|
| 41 |
<div class="hidden md:flex gap-10 font-medium items-center text-lg">
|
| 42 |
<a href="dashboard.html">Dashboard</a>
|
| 43 |
-
<a href="
|
| 44 |
-
<a href="
|
| 45 |
<a href="index.html" class="bg-white text-emerald-600 px-4 py-1 rounded-full font-semibold">Logout</a>
|
| 46 |
</div>
|
| 47 |
</nav>
|
|
@@ -54,15 +52,14 @@ body {
|
|
| 54 |
</p>
|
| 55 |
</section>
|
| 56 |
|
| 57 |
-
<!--
|
| 58 |
<section class="px-10 space-y-8">
|
| 59 |
|
| 60 |
-
<!-- INPUT -->
|
| 61 |
<div class="card bg-white p-8 rounded-xl">
|
| 62 |
|
| 63 |
<h2 class="text-2xl font-bold mb-6">Food Details</h2>
|
| 64 |
|
| 65 |
-
<label class="font-semibold
|
| 66 |
<select class="w-full mt-2 mb-5 p-3 border rounded-lg">
|
| 67 |
<option>Halal Cooked</option>
|
| 68 |
<option>Baked Goods</option>
|
|
@@ -71,12 +68,10 @@ body {
|
|
| 71 |
<option>Vegetarian/Vegan</option>
|
| 72 |
</select>
|
| 73 |
|
| 74 |
-
<label class="font-semibold
|
| 75 |
-
Portions: <span id="portionValue">50</span>
|
| 76 |
-
</label>
|
| 77 |
<input type="range" min="1" max="250" value="50" id="portions" class="w-full mt-2 mb-5">
|
| 78 |
|
| 79 |
-
<label class="font-semibold
|
| 80 |
<select id="expiry" class="w-full mt-2 p-3 border rounded-lg">
|
| 81 |
<option>Less than 6 hours</option>
|
| 82 |
<option>Within 24 hours</option>
|
|
@@ -90,162 +85,85 @@ body {
|
|
| 90 |
|
| 91 |
<h2 class="text-2xl font-bold">AI Recommendation</h2>
|
| 92 |
|
| 93 |
-
<p id="aiText" class="mt-4 text-gray-700 text-lg
|
| 94 |
-
|
| 95 |
</p>
|
| 96 |
|
| 97 |
-
<!--
|
| 98 |
-
<button onclick="runAI()"
|
| 99 |
-
class="mt-
|
| 100 |
-
|
| 101 |
</button>
|
| 102 |
|
| 103 |
</div>
|
| 104 |
|
| 105 |
-
<!-- RECIPIENTS -->
|
| 106 |
-
<div class="card bg-white p-8 rounded-xl">
|
| 107 |
-
|
| 108 |
-
<h2 class="text-2xl font-bold mb-4">Matched Recipients</h2>
|
| 109 |
-
|
| 110 |
-
<div class="space-y-4">
|
| 111 |
-
|
| 112 |
-
<div id="elderly" class="card p-5 rounded-lg hidden">
|
| 113 |
-
<p class="font-semibold text-lg">📍 Al Rahma Elderly Home</p>
|
| 114 |
-
<p class="text-gray-600 text-sm mt-1">2.1 km • Capacity: 80 • Halal Friendly</p>
|
| 115 |
-
</div>
|
| 116 |
-
|
| 117 |
-
<div id="refugee" class="card p-5 rounded-lg hidden">
|
| 118 |
-
<p class="font-semibold text-lg">📍 Hope Refugee Center</p>
|
| 119 |
-
<p class="text-gray-600 text-sm mt-1">4.5 km • Capacity: 150 • Mixed Distribution</p>
|
| 120 |
-
</div>
|
| 121 |
-
|
| 122 |
-
<div id="foodbank" class="card p-5 rounded-lg hidden">
|
| 123 |
-
<p class="font-semibold text-lg">📍 Dubai Food Bank</p>
|
| 124 |
-
<p class="text-gray-600 text-sm mt-1">6.2 km • Large Scale • Accepts All Types</p>
|
| 125 |
-
</div>
|
| 126 |
-
|
| 127 |
-
</div>
|
| 128 |
-
|
| 129 |
-
</div>
|
| 130 |
-
|
| 131 |
</section>
|
| 132 |
|
| 133 |
-
<!--
|
| 134 |
-
<section class="flex justify-center mt-12 mb-10">
|
| 135 |
-
<button id="confirmBtn"
|
| 136 |
-
class="bg-emerald-600 text-white px-12 py-4 rounded-full font-semibold text-lg hover:scale-105 transition shadow-lg">
|
| 137 |
-
Confirm Donation
|
| 138 |
-
</button>
|
| 139 |
-
</section>
|
| 140 |
-
|
| 141 |
-
<div id="footer"></div>
|
| 142 |
-
|
| 143 |
<script>
|
| 144 |
-
fetch("footer.html")
|
| 145 |
-
.then(res => res.text())
|
| 146 |
-
.then(data => {
|
| 147 |
-
document.getElementById("footer").innerHTML = data;
|
| 148 |
-
});
|
| 149 |
-
</script>
|
| 150 |
|
| 151 |
-
|
| 152 |
-
<script>
|
| 153 |
const portions = document.getElementById("portions");
|
| 154 |
-
const expiry = document.getElementById("expiry");
|
| 155 |
-
const aiText = document.getElementById("aiText");
|
| 156 |
const portionValue = document.getElementById("portionValue");
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
function updateAI() {
|
| 163 |
-
let p = parseInt(portions.value);
|
| 164 |
-
let e = expiry.value;
|
| 165 |
-
|
| 166 |
-
portionValue.innerText = p;
|
| 167 |
-
|
| 168 |
-
elderly.classList.add("hidden");
|
| 169 |
-
refugee.classList.add("hidden");
|
| 170 |
-
foodbank.classList.add("hidden");
|
| 171 |
-
|
| 172 |
-
let recipient = "";
|
| 173 |
-
let showCard = null;
|
| 174 |
-
|
| 175 |
-
if (p <= 80) {
|
| 176 |
-
recipient = "Al Rahma Elderly Home";
|
| 177 |
-
showCard = elderly;
|
| 178 |
-
} else if (p <= 150) {
|
| 179 |
-
recipient = "Hope Refugee Center";
|
| 180 |
-
showCard = refugee;
|
| 181 |
-
} else {
|
| 182 |
-
recipient = "Dubai Food Bank";
|
| 183 |
-
showCard = foodbank;
|
| 184 |
-
}
|
| 185 |
-
|
| 186 |
-
if (showCard) {
|
| 187 |
-
showCard.classList.remove("hidden");
|
| 188 |
-
showCard.classList.add("active-match");
|
| 189 |
-
}
|
| 190 |
-
|
| 191 |
-
aiText.innerHTML = `<b>Recommended:</b> ${recipient}`;
|
| 192 |
-
}
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
updateAI();
|
| 197 |
|
| 198 |
-
|
| 199 |
-
document.
|
| 200 |
-
const
|
| 201 |
-
foodType: document.querySelector("select").value,
|
| 202 |
-
portions: portions.value,
|
| 203 |
-
expiry: expiry.value
|
| 204 |
-
};
|
| 205 |
|
| 206 |
-
|
| 207 |
-
window.location.href = "confirmation.html";
|
| 208 |
-
});
|
| 209 |
-
</script>
|
| 210 |
|
| 211 |
-
|
| 212 |
-
<script>
|
| 213 |
-
async function runAI() {
|
| 214 |
|
| 215 |
-
const
|
|
|
|
| 216 |
|
| 217 |
-
|
| 218 |
-
let hours = 24;
|
| 219 |
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
|
|
|
| 223 |
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
try {
|
| 227 |
-
const response = await fetch("https://
|
| 228 |
method: "POST",
|
| 229 |
headers: {
|
| 230 |
-
"Content-Type": "application/json"
|
|
|
|
| 231 |
},
|
| 232 |
body: JSON.stringify({
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
| 234 |
})
|
| 235 |
});
|
| 236 |
|
| 237 |
-
const
|
| 238 |
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
`;
|
| 243 |
|
| 244 |
} catch (error) {
|
| 245 |
-
document.getElementById("aiText").innerText =
|
| 246 |
-
|
| 247 |
}
|
| 248 |
}
|
|
|
|
| 249 |
</script>
|
| 250 |
|
| 251 |
</body>
|
|
|
|
| 5 |
<title>Log Surplus - NourishNet</title>
|
| 6 |
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
|
|
|
|
|
|
| 8 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
|
| 9 |
|
| 10 |
<style>
|
|
|
|
| 17 |
transition: all 0.3s ease;
|
| 18 |
border: 1px solid #e5e7eb;
|
| 19 |
}
|
| 20 |
+
|
| 21 |
.card:hover {
|
| 22 |
transform: translateY(-6px);
|
| 23 |
border: 1px solid #10b981;
|
|
|
|
| 26 |
|
| 27 |
.active-match {
|
| 28 |
border: 2px solid #10b981 !important;
|
|
|
|
| 29 |
}
|
| 30 |
</style>
|
| 31 |
</head>
|
|
|
|
| 38 |
|
| 39 |
<div class="hidden md:flex gap-10 font-medium items-center text-lg">
|
| 40 |
<a href="dashboard.html">Dashboard</a>
|
| 41 |
+
<a href="impact.html">Impact</a>
|
| 42 |
+
<a href="leaderboard.html">Leaderboard</a>
|
| 43 |
<a href="index.html" class="bg-white text-emerald-600 px-4 py-1 rounded-full font-semibold">Logout</a>
|
| 44 |
</div>
|
| 45 |
</nav>
|
|
|
|
| 52 |
</p>
|
| 53 |
</section>
|
| 54 |
|
| 55 |
+
<!-- INPUT -->
|
| 56 |
<section class="px-10 space-y-8">
|
| 57 |
|
|
|
|
| 58 |
<div class="card bg-white p-8 rounded-xl">
|
| 59 |
|
| 60 |
<h2 class="text-2xl font-bold mb-6">Food Details</h2>
|
| 61 |
|
| 62 |
+
<label class="font-semibold">Food Type</label>
|
| 63 |
<select class="w-full mt-2 mb-5 p-3 border rounded-lg">
|
| 64 |
<option>Halal Cooked</option>
|
| 65 |
<option>Baked Goods</option>
|
|
|
|
| 68 |
<option>Vegetarian/Vegan</option>
|
| 69 |
</select>
|
| 70 |
|
| 71 |
+
<label class="font-semibold">Portions: <span id="portionValue">50</span></label>
|
|
|
|
|
|
|
| 72 |
<input type="range" min="1" max="250" value="50" id="portions" class="w-full mt-2 mb-5">
|
| 73 |
|
| 74 |
+
<label class="font-semibold">Expiry Window</label>
|
| 75 |
<select id="expiry" class="w-full mt-2 p-3 border rounded-lg">
|
| 76 |
<option>Less than 6 hours</option>
|
| 77 |
<option>Within 24 hours</option>
|
|
|
|
| 85 |
|
| 86 |
<h2 class="text-2xl font-bold">AI Recommendation</h2>
|
| 87 |
|
| 88 |
+
<p id="aiText" class="mt-4 text-gray-700 text-lg">
|
| 89 |
+
Click “Ask AI” to get recommendation...
|
| 90 |
</p>
|
| 91 |
|
| 92 |
+
<!-- 🔥 NEW BUTTON -->
|
| 93 |
+
<button onclick="runAI()"
|
| 94 |
+
class="mt-5 bg-emerald-600 text-white px-6 py-2 rounded-full">
|
| 95 |
+
Ask AI
|
| 96 |
</button>
|
| 97 |
|
| 98 |
</div>
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
</section>
|
| 101 |
|
| 102 |
+
<!-- SCRIPT -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
+
// UI update
|
|
|
|
| 106 |
const portions = document.getElementById("portions");
|
|
|
|
|
|
|
| 107 |
const portionValue = document.getElementById("portionValue");
|
| 108 |
|
| 109 |
+
portions.addEventListener("input", () => {
|
| 110 |
+
portionValue.innerText = portions.value;
|
| 111 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
+
// 🔥 GROQ LLM FUNCTION
|
| 114 |
+
async function runAI() {
|
|
|
|
| 115 |
|
| 116 |
+
const meals = document.getElementById("portions").value;
|
| 117 |
+
const foodType = document.querySelector("select").value;
|
| 118 |
+
const expiryText = document.getElementById("expiry").value;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
+
let hours = expiryText.includes("6") ? 3 : expiryText.includes("24") ? 12 : 30;
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
+
const distance = 5;
|
|
|
|
|
|
|
| 123 |
|
| 124 |
+
const prompt = `
|
| 125 |
+
You are an AI for food surplus redistribution in the UAE (NourishNet).
|
| 126 |
|
| 127 |
+
Analyze the data:
|
|
|
|
| 128 |
|
| 129 |
+
Meals: ${meals}
|
| 130 |
+
Hours left: ${hours}
|
| 131 |
+
Distance: ${distance}
|
| 132 |
+
Food type: ${foodType}
|
| 133 |
|
| 134 |
+
Return:
|
| 135 |
+
Priority (HIGH / MEDIUM / LOW)
|
| 136 |
+
Reason (short explanation)
|
| 137 |
+
Action (what should be done)
|
| 138 |
+
`;
|
| 139 |
|
| 140 |
try {
|
| 141 |
+
const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
|
| 142 |
method: "POST",
|
| 143 |
headers: {
|
| 144 |
+
"Content-Type": "application/json",
|
| 145 |
+
"Authorization": "Bearer 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"
|
| 146 |
},
|
| 147 |
body: JSON.stringify({
|
| 148 |
+
model: "llama-3.1-8b-instant",
|
| 149 |
+
messages: [
|
| 150 |
+
{ role: "user", content: prompt }
|
| 151 |
+
]
|
| 152 |
})
|
| 153 |
});
|
| 154 |
|
| 155 |
+
const data = await response.json();
|
| 156 |
|
| 157 |
+
const result = data.choices[0].message.content;
|
| 158 |
+
|
| 159 |
+
document.getElementById("aiText").innerText = result;
|
|
|
|
| 160 |
|
| 161 |
} catch (error) {
|
| 162 |
+
document.getElementById("aiText").innerText =
|
| 163 |
+
"AI failed. Check API key or internet connection.";
|
| 164 |
}
|
| 165 |
}
|
| 166 |
+
|
| 167 |
</script>
|
| 168 |
|
| 169 |
</body>
|