Merge pull request #2 from kbenestad/claude/fix-form-layout-P8uHa

Fix crash: state initialized before CFG is loaded
This commit is contained in:
Kristian Benestad 2026-05-13 16:33:40 +07:00 committed by GitHub
commit cae6416ffd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -140,7 +140,7 @@ async function loadConfig() {
} }
// ========== STATE ========== // ========== STATE ==========
const state = { staff: '', periodFrom: '', periodTo: '', baseCurrency: CFG['currency-base'], fxRateMemory: {}, items: [], _grandTotal: 0 }; const state = { staff: '', periodFrom: '', periodTo: '', baseCurrency: '', fxRateMemory: {}, items: [], _grandTotal: 0 };
function newItem() { return { id: uid(), name: '', lines: [newLine()], _subtotal: 0 }; } function newItem() { return { id: uid(), name: '', lines: [newLine()], _subtotal: 0 }; }
function newLine() { function newLine() {
@ -848,6 +848,7 @@ async function onGenerate() {
async function init() { async function init() {
try { try {
await loadConfig(); await loadConfig();
state.baseCurrency = CFG['currency-base'];
state.items.push(newItem()); state.items.push(newItem());
render(); render();
} catch (e) { } catch (e) {