From bd1ceee1ad188dd9a549492c43a64ca909ceeed7 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Wed, 9 Apr 2025 19:50:49 -0400 Subject: [PATCH] Added check in case the Journal Entry creation fails --- src/routes/journals/[journal_id]/+layout.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/routes/journals/[journal_id]/+layout.svelte b/src/routes/journals/[journal_id]/+layout.svelte index cbdfbf3d..bda2ccfe 100644 --- a/src/routes/journals/[journal_id]/+layout.svelte +++ b/src/routes/journals/[journal_id]/+layout.svelte @@ -243,12 +243,18 @@ async function handle_update_journal() { }).then((results) => { console.log('New journal entry created:', results); $journals_slct.journal_entry_id = results?.journal_entry_id_random; + // $journals_loc.entry.edit = true; + $journals_loc.entry.edit_kv[$journals_slct.journal_entry_id] = true; // alert(`Journal entry created successfully! ${$journals_slct.journal_entry_id}`); }).catch((error) => { console.error('Error updating journal entry:', error); alert('Failed to update journal entry.'); }).finally(() => { - goto(`/journals/${$lq__journal_obj?.journal_id}/entry/${$journals_slct.journal_entry_id}`); + if ($journals_slct.journal_entry_id) { + goto(`/journals/${$lq__journal_obj?.journal_id}/entry/${$journals_slct.journal_entry_id}`); + } else { + alert('Failed to create new journal entry.'); + } }); }} class="