diff --git a/apps/web/src/common/modules/widgets/_composables/use-widget-date-range.ts b/apps/web/src/common/modules/widgets/_composables/use-widget-date-range.ts index 687e950a1b..1a5853bce9 100644 --- a/apps/web/src/common/modules/widgets/_composables/use-widget-date-range.ts +++ b/apps/web/src/common/modules/widgets/_composables/use-widget-date-range.ts @@ -39,7 +39,7 @@ export const useWidgetDateRange = (options: UseWidgetDateRangeOptions): UseWidge const state = reactive({ granularity: computed(() => _granularityInfo.value?.granularity ?? 'MONTHLY'), isInherit: computed(() => !!options.dateRangeFieldValue.value?.inherit), - dateRangeOptions: computed(() => options.dateRangeFieldValue.value?.options || 'auto'), + dateRangeOptions: computed(() => options.dateRangeFieldValue.value?.options || { value: 'auto' }), baseOnDate: computed(() => (state.isInherit ? _baseOnDate.value : undefined)), dateRange: computed(() => { const dateRangePresetKey = state.dateRangeOptions?.value || 'auto'; @@ -123,7 +123,7 @@ export const useWidgetDateRange = (options: UseWidgetDateRangeOptions): UseWidge const _date = baseDate.date(); const isEndOfMonth = _date === baseDate.endOf('month').date(); - _start = baseDate.subtract(isEndOfMonth ? baseMonthDayCount - 1 : 29, 'day').format('YYYY-MM-DD'); + _start = isEndOfMonth ? baseDate.subtract(baseMonthDayCount - 1, 'day').format('YYYY-MM-DD') : baseDate.subtract(1, 'month').add(1, 'day').format('YYYY-MM-DD'); _end = baseDate.format('YYYY-MM-DD'); } else if (relativeDateRangeValue === 'today') { _start = baseDate.format('YYYY-MM-DD');