From 225202aacb28eb57c7753fe2844735920dfd17fb Mon Sep 17 00:00:00 2001 From: James Pattinson Date: Sun, 12 Apr 2026 05:37:57 -0400 Subject: [PATCH] Minor UI tweaks --- frontend/app.js | 16 ++++++++++------ frontend/index.html | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/app.js b/frontend/app.js index 321d70c..2874cf8 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -1618,11 +1618,14 @@ async function handleAddDrug(e) { }); if (!drugResponse.ok) throw new Error('Failed to add drug'); + const createdDrug = await drugResponse.json(); document.getElementById('drugForm').reset(); - closeModal(document.getElementById('addModal')); + expandedDrugs.add(createdDrug.id); await loadDrugs(); - showToast('Drug added successfully!', 'success'); + closeModal(document.getElementById('addModal')); + openAddVariantModal(createdDrug.id); + showToast('Drug added successfully. Add the first variant next.', 'success'); } catch (error) { console.error('Error adding drug:', error); showToast('Failed to add drug. Check the console for details.', 'error'); @@ -1882,7 +1885,7 @@ function inferBaseUnitFromStrength(strength) { if (value.includes('/ml') || value.includes('ml')) return 'ml'; if (value.includes('tablet')) return 'tablets'; if (value.includes('capsule')) return 'capsules'; - return 'units'; + return 'tablets'; } function getVariantPackRowsContainer() { @@ -1928,7 +1931,7 @@ function appendVariantPackRow(prefill = {}) { const row = document.createElement('div'); row.className = 'delivery-line variant-pack-row'; - const selectedPackUnit = prefill.packUnit || 'bottle'; + const selectedPackUnit = prefill.packUnit || 'box'; const selectedSize = prefill.packSize || ''; const baseUnit = document.getElementById('variantUnit')?.value || 'units'; @@ -1983,7 +1986,7 @@ function initializeVariantPackRows() { variantUnitSelect.value = inferredBaseUnit; } - appendVariantPackRow({ packUnit: 'bottle' }); + appendVariantPackRow({ packUnit: 'box' }); } function appendEditVariantPackRow(prefill = {}) { @@ -2965,8 +2968,9 @@ function buildDeliveryPackOptions(variant, selectedPackId = '') { } function buildDeliveryLocationOptions(selectedLocationId = '') { + const fallbackLocationId = selectedLocationId || (deliveryLocations.length > 0 ? String(deliveryLocations[0].id) : ''); return [``, ...deliveryLocations.map(location => { - const selected = String(location.id) === String(selectedLocationId) ? ' selected' : ''; + const selected = String(location.id) === String(fallbackLocationId) ? ' selected' : ''; return ``; })].join(''); } diff --git a/frontend/index.html b/frontend/index.html index 6f3c9b5..9ae6ce3 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -274,7 +274,7 @@