Skip to content

feat(dashboard): period URL state + resolved range label + chart drill-down to Costs#605

Merged
barach6662001-bit merged 1 commit intomainfrom
chore/pr2-dashboard-period-drilldown
Apr 23, 2026
Merged

feat(dashboard): period URL state + resolved range label + chart drill-down to Costs#605
barach6662001-bit merged 1 commit intomainfrom
chore/pr2-dashboard-period-drilldown

Conversation

@barach6662001-bit
Copy link
Copy Markdown
Owner

Scope

PR 2 of 8 from the improvement roadmap. Covers the low-risk parts of P.2 (period UX) and P.3 (drill-down):

  • P.2 (URL state + range label) — the selected period (day / week / month / season) is persisted in the URL as ?period=…. Refresh, share and back-button now preserve the filter. A small monospace label under the segmented control shows the actual resolved date range (e.g. 23 квіт 2026, 17 – 23 квіт 2026, квіт 2026, Весь час).
  • P.3 (drill-down) — clicking any point on the revenue/cost chart on the dashboard navigates to /economics/costs?from=YYYY-MM-01&to=YYYY-MM-lastday, pre-filtered to that month. The Costs page now reads from / to from the URL, reflects them in the RangePicker, and writes manual range changes back to the URL.

Deferred to a later PR (require product input):

  • P.2's ‹ › anchor-date navigation (needs a decision on whether month/week should be anchored to a non-today date — dashboard backend currently only accepts from/to, so this needs a small API extension).
  • P.3 for the Sales/Revenue chart (RevenueAnalytics.tsx) — same pattern, different page, kept out to keep this PR focused.
  • P.6 totals-cards cross-page audit — the big Season=all-time fix already landed in fix(dashboard): honest numbers — remove demo margin fake, Season = all-time #602; a proper side-by-side reconciliation UI deserves its own PR.

Changes

Dashboard container

  • frontend/src/pages/Dashboard.tsx — period now comes from useSearchParams. season is the default and is stored as no query param (keeps URLs clean).

DashboardV2 (presentational)

  • Added a monospace range label under the segmented period control (.rangeLabel in DashboardV2.module.css, stacked layout).
  • New handleChartPointClick parses the point's YYYY-MM name and navigates to the Costs page with the whole month pre-selected.
  • Passes the new onPointClick prop into RevenueCostChart.

RevenueCostChart

  • New optional onPointClick(name) prop. Wired to Recharts' <AreaChart onClick>; the chart gains cursor: pointer only when a handler is supplied so the existing non-interactive embeds are unaffected.

Costs page

  • frontend/src/pages/Economics/CostRecords.tsx — reads ?from / ?to from the URL on mount (validated as YYYY-MM-DD), binds them to the AntD RangePicker, and writes user-driven range changes back to the URL with { replace: true }.

New util

  • frontend/src/utils/formatPeriodRange.ts — locale-aware label formatter shared between the dashboard and any future callers.

i18n

  • Added dashboard.allTime to both uk.ts ("Весь час") and en.ts ("All time").

Verification

  • cd frontend && npx tsc --noEmit — clean.
  • Manual: visit /dashboard?period=month → month tab is active and the range label reads the current month. Click a chart point for 2026-03 → lands on /economics/costs?from=2026-03-01&to=2026-03-31 with the RangePicker pre-filled.

@barach6662001-bit barach6662001-bit merged commit de451ff into main Apr 23, 2026
3 checks passed
@barach6662001-bit barach6662001-bit deleted the chore/pr2-dashboard-period-drilldown branch April 23, 2026 09:41
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: e3bb5ce904

ℹ️ 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".

case 'day':
return fmtDay(now);
case 'week': {
const weekAgo = new Date(now.getTime() - 6 * 24 * 60 * 60 * 1000);
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 Match week label to the actual 7-day query window

The new range label for period='week' is off by one day compared to the backend filter: formatPeriodRange subtracts 6 days, while periodToRange('week') subtracts 7 days before querying analytics. In practice, a dashboard filtered with the current week request can include data from an extra calendar day (e.g., Apr 16), but the UI label will display Apr 17 – Apr 23, which misstates the range users are interpreting.

Useful? React with 👍 / 👎.

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