Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

fix(cashflow): use Turbo.visit for donut chart deep-link navigation (#2166)

Will Wilson7dbb54847955
diff --git a/app/javascript/controllers/donut_chart_controller.js b/app/javascript/controllers/donut_chart_controller.js
index 0e9219141d..9392d94590 100644
--- a/app/javascript/controllers/donut_chart_controller.js
+++ b/app/javascript/controllers/donut_chart_controller.js
@@ -1,5 +1,6 @@
import { Controller } from "@hotwired/stimulus";
import * as d3 from "d3";
+import { buildCategoryTransactionsUrl } from "utils/transactions_filter_url";
// Connects to data-controller="donut-chart"
export default class extends Controller {
@@ -250,14 +251,15 @@ export default class extends Controller {
// Handles click on segment (optional, controlled by enableClick value)
#handleClick(segment) {
- if (!segment.name || !this.startDateValue || !this.endDateValue) return;
-
- const segmentName = encodeURIComponent(segment.name);
- const startDate = this.startDateValue;
- const endDate = this.endDateValue;
-
- const url = `/transactions?q[categories][]=${segmentName}&q[start_date]=${startDate}&q[end_date]=${endDate}`;
- window.location.href = url;
+ if (!segment.name) return;
+
+ Turbo.visit(
+ buildCategoryTransactionsUrl({
+ name: segment.name,
+ startDate: this.startDateValue,
+ endDate: this.endDateValue,
+ }),
+ );
}
// Public methods for external highlighting (e.g., from category list hover)