diff --git a/src/store/dashboardStore.ts b/src/store/dashboardStore.ts
index e879c70..2525ff4 100644
--- a/src/store/dashboardStore.ts
+++ b/src/store/dashboardStore.ts
@@ -6,9 +6,16 @@ import { currentDate, getTagColor, getTagName, formatMinutes, parseISODate, toIS
// Re-export for easier access in Dashboard component
export { getTagColor, getTagName, formatMinutes };
-export const dashboardRange = ref<'today' | '7days' | '30days'>('today');
+export const dashboardRange = ref<'today' | '7days' | '30days' | 'custom'>('today');
export const dashboardStartDate = ref(currentDate.value);
export const dashboardEndDate = ref(currentDate.value);
+
+// Dedicated memory for custom dates so they don't get overwritten by auto modes
+export const customStartDate = ref(currentDate.value);
+export const customEndDate = ref(currentDate.value);
+
+export const isStartCalendarOpen = ref(false);
+export const isEndCalendarOpen = ref(false);
export const dashboardEvents = ref
([]);
export const dailyAverageMode = ref<'natural' | 'recorded'>('natural');
@@ -17,6 +24,13 @@ export const loadDashboardEvents = async () => {
};
watch([dashboardRange, currentDate], () => {
+ if (dashboardRange.value === 'custom') {
+ dashboardStartDate.value = customStartDate.value;
+ dashboardEndDate.value = customEndDate.value;
+ loadDashboardEvents();
+ return;
+ }
+
const end = parseISODate(currentDate.value);
let start = parseISODate(currentDate.value);
@@ -31,6 +45,15 @@ watch([dashboardRange, currentDate], () => {
loadDashboardEvents();
}, { immediate: true });
+// Specific trigger for custom range changes
+watch([customStartDate, customEndDate], () => {
+ if (dashboardRange.value === 'custom') {
+ dashboardStartDate.value = customStartDate.value;
+ dashboardEndDate.value = customEndDate.value;
+ loadDashboardEvents();
+ }
+});
+
// Auto-refresh dashboard when a refresh signal is received (event added/deleted)
watch(refreshSignal, () => {
if (viewMode.value === 'dashboard') {