-
Notifications
You must be signed in to change notification settings - Fork 0
Bug: preset date ranges emit mixed value types and break consumers #7
Description
Problem
The shared date range picker emits inconsistent payload types depending on how the user selects the range.
- Manual selection can yield
Dateobjects. - Preset selection (
Last 30 Days,This Month,This Year, etc.) currently writesYYYY-MM-DDstrings 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.vuefrontend/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
- Open a view that uses the shared date range picker.
- Click the date range trigger.
- Select a preset such as Last 30 Days or This Year.
- Click Apply.
- The consumer attempts to serialize the returned values as
Dateobjects 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
Dateinstances - 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 DaysandThis 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.