20260316d: Sort dashboard sections - opened by remaining qty asc, expiring/expired already correct
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user