From b325b3afa433aa17ad80ffd7988f94844a3f3941 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Sep 2025 13:17:42 +0000 Subject: [PATCH 1/2] Initial plan From bb3488c1574cbeeda3b792fb909f75607fabba6f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Sep 2025 13:25:28 +0000 Subject: [PATCH 2/2] Fix notes saving bug: export DaySummary interface and improve data initialization Co-authored-by: PStarH <176644217+PStarH@users.noreply.github.com> --- src/store/types.ts | 2 +- src/views/DaySummary.vue | 83 +++++++++++++++++++++++++--------------- 2 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/store/types.ts b/src/store/types.ts index 33ce2a8..d6a549d 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -35,7 +35,7 @@ export interface MediaItem { url: string } -interface DaySummary { +export interface DaySummary { date: string summary: string mood: string diff --git a/src/views/DaySummary.vue b/src/views/DaySummary.vue index 97dd6ea..2a3f338 100644 --- a/src/views/DaySummary.vue +++ b/src/views/DaySummary.vue @@ -252,10 +252,28 @@ watch(() => props.selectedDate, (newDate) => { watch(daySummary, (newSummary) => { if (newSummary) { - content.value = newSummary.summary + // Load all fields from existing summary + content.value = newSummary.summary || '' + mood.value = newSummary.mood || 'happy' + weather.value = { description: newSummary.weather || 'Partly cloudy, 22°C' } + habits.value = newSummary.habits || [] + dailyCheck.value = newSummary.dailyCheck || { energyLevel: 5, stressLevel: 5, productivity: 5 } + comfortZoneEntry.value = newSummary.comfortZoneEntry || '' + customSections.value = newSummary.customSections || [] + tags.value = newSummary.tags || [] + media.value = newSummary.media || [] updateQuillContent(content.value) } else { + // Initialize with default values for new entry content.value = '' + mood.value = 'happy' + weather.value = { description: 'Partly cloudy, 22°C' } + habits.value = [] + dailyCheck.value = { energyLevel: 5, stressLevel: 5, productivity: 5 } + comfortZoneEntry.value = '' + customSections.value = [] + tags.value = [] + media.value = [] updateQuillContent('') } }) @@ -312,6 +330,24 @@ onMounted(async () => { store.dispatch('loadSparks') store.dispatch('loadCalendarEntries') + // Initialize form data for the current date + const existingSummary = store.getters.getDaySummary(currentDate.value) + if (existingSummary) { + // Load all fields from existing summary + content.value = existingSummary.summary || '' + mood.value = existingSummary.mood || 'happy' + weather.value = { description: existingSummary.weather || 'Partly cloudy, 22°C' } + habits.value = existingSummary.habits || [] + dailyCheck.value = existingSummary.dailyCheck || { energyLevel: 5, stressLevel: 5, productivity: 5 } + comfortZoneEntry.value = existingSummary.comfortZoneEntry || '' + customSections.value = existingSummary.customSections || [] + tags.value = existingSummary.tags || [] + media.value = existingSummary.media || [] + } else { + // Initialize with default values for new entry + weather.value = { description: 'Partly cloudy, 22°C' } + } + setTimeout(() => { if (!weather.value.description || weather.value.description === 'Loading...') { weather.value = { description: 'Partly cloudy, 22°C' } @@ -321,18 +357,6 @@ onMounted(async () => { await initializeQuill() }) -watch(() => daySummary.value, async (newSummary) => { - if (newSummary) { - content.value = newSummary.summary || '' - await nextTick() - updateQuillContent(content.value) - } else { - content.value = '' - await nextTick() - updateQuillContent('') - } -}) - const cycleHabitStatus = (habit, status) => { habit.status = habit.status === status ? null : status } @@ -392,33 +416,32 @@ const saveAll = () => { media: media.value } - // Function to test serialization - const testSerialization = (key: string, value: any) => { - try { - JSON.stringify(value) - console.log(`✅ ${key} serialized successfully.`) - } catch (error) { - console.error(`❌ Error serializing ${key}:`, error) - } - } + console.log('📝 Attempting to save day summary:', summary) - // Test each field - Object.keys(summary).forEach(key => { - testSerialization(key, (summary as any)[key]) - }) + // Validate required fields + if (!summary.date) { + console.error('❌ Cannot save: date is required') + return + } - // Proceed to save only if all fields are serializable + // Test serialization first try { const serializedSummary = JSON.parse(JSON.stringify(summary)) + console.log('✅ Serialization successful') + + // Save to store store.dispatch('updateDaySummary', serializedSummary) .then(() => { - console.log('📦 Day summary saved successfully.') + console.log('✅ Day summary saved successfully to store') + alert('✅ Day summary saved successfully!') }) .catch((error) => { - console.error('⚠️ Failed to save day summary:', error) + console.error('❌ Failed to save day summary to store:', error) + alert('❌ Failed to save day summary: ' + error.message) }) } catch (serializationError) { - console.error('⚠️ Serialization failed. Summary not saved:', serializationError) + console.error('❌ Serialization failed. Summary not saved:', serializationError) + alert('❌ Failed to save: Data serialization error') } }