20260316d: Sort dashboard sections - opened by remaining qty asc, expiring/expired already correct

This commit is contained in:
dadaloop82
2026-03-16 07:51:05 +00:00
parent c6a3ae6e63
commit 4d9fd8638e
3 changed files with 15 additions and 1 deletions
+14
View File
@@ -865,6 +865,11 @@ async function loadDashboard() {
const openedSection = document.getElementById('alert-opened');
const openedList = document.getElementById('opened-list');
if (statsData.opened && statsData.opened.length > 0) {
// Sort by remaining fraction ascending (least remaining first)
statsData.opened.sort((a, b) => {
const fA = openedFraction(a), fB = openedFraction(b);
return fA - fB;
});
openedSection.style.display = 'block';
openedList.innerHTML = statsData.opened.map(item => {
const locInfo = LOCATIONS[item.location] || { icon: '📦', label: item.location };
@@ -918,6 +923,15 @@ async function loadDashboard() {
}
}
function openedFraction(item) {
const qty = parseFloat(item.quantity);
const pkgSize = parseFloat(item.default_quantity);
if (item.unit === 'conf') {
return qty - Math.floor(qty + 0.001);
}
return (qty - Math.floor(qty / pkgSize + 0.001) * pkgSize) / pkgSize;
}
function quickRecipeSuggestion() {
// Navigate to chat and auto-send a prompt about expiring products
showPage('chat');
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -911,6 +911,6 @@
</div>
</div>
<script src="assets/js/app.js?v=20260316c"></script>
<script src="assets/js/app.js?v=20260316d"></script>
</body>
</html>