feat(sales): monthly revenue chart drill-down + URL-state for SalesList filters#606
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d42c56154c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Sales revenue chart (and any other deep link) pre-fill the filters and | ||
| // survive refresh / sharing. | ||
| const [searchParams, setSearchParams] = useSearchParams(); | ||
| const isIsoDate = (v: string | null): v is string => !!v && /^\d{4}-\d{2}-\d{2}$/.test(v); |
There was a problem hiding this comment.
Validate calendar dates before accepting URL filters
isIsoDate only checks the YYYY-MM-DD shape, so impossible values like 2026-02-31 are treated as valid and copied into dateRange. Those values are then sent to getSales(...), while the API endpoint binds dateFrom/dateTo as DateTime? (src/AgroPlatform.Api/Controllers/SalesController.cs), which can reject malformed calendar dates and break deep links with a typo. Use strict calendar validation (e.g., strict dayjs parse) before initializing filters from query params.
Useful? React with 👍 / 👎.
Scope
Finishes the drill-down work deferred from #605 — the monthly revenue bar chart on
/sales/analyticsis now clickable and lands on the Sales list pre-filtered to that month.Changes
frontend/src/pages/Sales/RevenueAnalytics.tsxuseNavigate.year/monthfields (in addition to the localised label), so the drill-down doesn't have to re-parse the UI string.handleMonthlyBarClickhandler →navigate('/sales?from=YYYY-MM-01&to=YYYY-MM-lastDay').<BarChart>getsonClick={handleMonthlyBarClick}andcursor: pointer.frontend/src/pages/Sales/SalesList.tsx?from,?to,?searchfrom the URL on mount (dates validated asYYYY-MM-DD).Inputand dateRangePickerare now controlled and write changes back to the URL with{ replace: true }, matching the pattern already shipped on the Costs page in feat(dashboard): period URL state + resolved range label + chart drill-down to Costs #605.Verification
cd frontend && npx tsc --noEmit— clean./sales/analytics, click any bar for e.g.Бер 2026→ lands on/sales?from=2026-03-01&to=2026-03-31with the range + RangePicker pre-filled.