Skip to content

Conversation

@cubic-dev-local
Copy link

@cubic-dev-local cubic-dev-local bot commented Nov 18, 2025

## What does this PR do?

This PR removes the usage of useInsightsParameters() from /insights/routing and uses useInsightsRoutingParameters() instead.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A - I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

nothing changes on /insights/routing

---

Based on: calcom/cal.com#25020

Summary by cubic

Refactored Insights Routing to remove useInsightsParameters and rely on useInsightsRoutingParameters/useInsightsOrgTeams. Behavior stays the same and date handling is centralized.

  • Refactors
    • Removed hooks/useInsightsParameters.ts and all usages.
    • Updated RoutingFormResponsesTable to use useInsightsOrgTeams and read routingFormId via useFilterValue; enabled DateRangeFilter options.convertToTimeZone.
    • Simplified useInsightsRoutingParameters by dropping timezone conversion helper and keeping start/end via dayjs. No UI or API changes.

Written for commit 7a49f7a. Summary will update automatically on new commits.

@sanxroz
Copy link

sanxroz commented Nov 18, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz Sorry, I encountered an error while trying to start the review. Please try again later.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Copy link
Author

@cubic-dev-local cubic-dev-local bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/features/insights/hooks/useInsightsRoutingParameters.ts">

<violation number="1" location="packages/features/insights/hooks/useInsightsRoutingParameters.ts:14">
This refactoring breaks encapsulation by removing timezone logic from `useInsightsRoutingParameters` and shifting responsibility to the UI component. Any component using this hook is now implicitly dependent on being rendered with a `DateRangeFilter` that has the `convertToTimeZone: true` option. Since only one of the many consuming components was updated, this is an incomplete refactor that will likely cause incorrect data to be displayed in other insight components.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

}, [createdAtRange?.endDate])
);

const startDate = useMemo(() => {
Copy link
Author

@cubic-dev-local cubic-dev-local bot Nov 18, 2025

Choose a reason for hiding this comment

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

This refactoring breaks encapsulation by removing timezone logic from useInsightsRoutingParameters and shifting responsibility to the UI component. Any component using this hook is now implicitly dependent on being rendered with a DateRangeFilter that has the convertToTimeZone: true option. Since only one of the many consuming components was updated, this is an incomplete refactor that will likely cause incorrect data to be displayed in other insight components.

Prompt for AI agents
Address the following comment on packages/features/insights/hooks/useInsightsRoutingParameters.ts at line 14:

<comment>This refactoring breaks encapsulation by removing timezone logic from `useInsightsRoutingParameters` and shifting responsibility to the UI component. Any component using this hook is now implicitly dependent on being rendered with a `DateRangeFilter` that has the `convertToTimeZone: true` option. Since only one of the many consuming components was updated, this is an incomplete refactor that will likely cause incorrect data to be displayed in other insight components.</comment>

<file context>
@@ -11,23 +10,18 @@ export function useInsightsRoutingParameters() {
-    }, [createdAtRange?.endDate])
-  );
+
+  const startDate = useMemo(() =&gt; {
+    return dayjs(createdAtRange?.startDate ?? getDefaultStartDate().toISOString())
+      .startOf(&quot;day&quot;)
</file context>

[internal] Confidence score: 9/10

[internal] Posted by: System Design Agent

Fix with Cubic

@github-actions
Copy link

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions bot added the Stale label Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants