Skip to content

feat(sales): monthly revenue chart drill-down + URL-state for SalesList filters#606

Merged
barach6662001-bit merged 1 commit intomainfrom
chore/pr3-sales-drilldown
Apr 23, 2026
Merged

feat(sales): monthly revenue chart drill-down + URL-state for SalesList filters#606
barach6662001-bit merged 1 commit intomainfrom
chore/pr3-sales-drilldown

Conversation

@barach6662001-bit
Copy link
Copy Markdown
Owner

Scope

Finishes the drill-down work deferred from #605 — the monthly revenue bar chart on /sales/analytics is now clickable and lands on the Sales list pre-filtered to that month.

Changes

frontend/src/pages/Sales/RevenueAnalytics.tsx

  • Added useNavigate.
  • Each monthly-chart datapoint now carries explicit year / month fields (in addition to the localised label), so the drill-down doesn't have to re-parse the UI string.
  • New handleMonthlyBarClick handler → navigate('/sales?from=YYYY-MM-01&to=YYYY-MM-lastDay').
  • The <BarChart> gets onClick={handleMonthlyBarClick} and cursor: pointer.

frontend/src/pages/Sales/SalesList.tsx

Verification

  • cd frontend && npx tsc --noEmit — clean.
  • Manual: open /sales/analytics, click any bar for e.g. Бер 2026 → lands on /sales?from=2026-03-01&to=2026-03-31 with the range + RangePicker pre-filled.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@barach6662001-bit barach6662001-bit merged commit f2d80d9 into main Apr 23, 2026
3 checks passed
@barach6662001-bit barach6662001-bit deleted the chore/pr3-sales-drilldown branch April 23, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant