Skip to content

Bug: preset date ranges emit mixed value types and break consumers #7

@niyazmft

Description

@niyazmft

Problem

The shared date range picker emits inconsistent payload types depending on how the user selects the range.

  • Manual selection can yield Date objects.
  • Preset selection (Last 30 Days, This Month, This Year, etc.) currently writes YYYY-MM-DD strings into the picker state and emits those strings on apply.

Downstream consumers assume they always receive Date objects and call toISOString() via utils.formatDateForInput(), which crashes when the payload is already a string.

Confirmed impact

Affected consumers include at least:

  • frontend/src/views/TransactionsView.vue
  • frontend/src/components/Dashboard/HistoryPanel.vue

Both call:

utils.formatDateForInput(start)
utils.formatDateForInput(end)

formatDateForInput() is currently:

export const formatDateForInput = (date) => {
  return date.toISOString().split('T')[0];
};

When a preset range is applied, this can throw:

date.toISOString is not a function

Root cause

In frontend/src/components/Shared/DateRangePicker.vue, preset application does this:

tempRange.value.start = start.toISOString().split('T')[0];
tempRange.value.end = end.toISOString().split('T')[0];

That means preset flows emit strings while other flows may emit Date objects.

Reproduction

  1. Open a view that uses the shared date range picker.
  2. Click the date range trigger.
  3. Select a preset such as Last 30 Days or This Year.
  4. Click Apply.
  5. The consumer attempts to serialize the returned values as Date objects and the flow breaks.

Expected behavior

The picker should emit a single, stable data contract for all selection paths.

Suggested fix

Choose one contract and enforce it consistently:

Option A — always emit normalized strings

  • normalize both manual and preset selections to YYYY-MM-DD
  • update consumers so they do not call formatDateForInput() on already-formatted strings

Option B — always emit Date objects

  • keep preset selections as Date instances
  • only serialize when constructing API request params

Acceptance criteria

  • preset selection no longer crashes
  • manual and preset flows emit the same payload type
  • Transactions view updates correctly after preset apply
  • Dashboard History updates correctly after preset apply
  • tests added for preset paths, especially Last 30 Days and This Year

Notes

The shared picker currently includes Last 30 Days, Last 90 Days, This Month, Last Month, and This Year. If a 60-day preset is desired, that would be a separate enhancement unless added as part of this fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions