feat(sales): Added stageChanged date range fixed enddate bug and fixed infinite loading totalcount - #8294
#8294feat(sales): Added stageChanged date range fixed enddate bug and fixed infinite loading totalcount#8294munkhsaikhan merged 2 commits intomainerxes/erxes:mainfrom feature/deals-filters-and-counterxes/erxes:feature/deals-filters-and-countCopy head branch name to clipboard
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe PR replaces the single "End date" sales filter with two dedicated date filters—"Close date" and "Stage changed"—wiring them through the type, constants, query variable parsing, and all UI layers. It also introduces Jotai-backed deal count tracking: per-column counts are written by ChangesNew Close Date and Stage Changed Date Filters
Jotai Deal Count Tracking
Possibly Related PRs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/plugins/sales_ui/src/modules/deals/cards/hooks/useDeals.tsx (1)
147-160: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
totalCountcan drift from the actual list during subscription updates.
totalCountis adjusted only byaction, even whenupdatedListdid not change (duplicateadd/ missingremove), and arithmetic can run on an undefined prior count. This can produce incorrect totals (including negative/invalid values).Proposed fix
return { ...prev, deals: { ...prev.deals, list: updatedList, pageInfo: prev.deals.pageInfo, - totalCount: - action === 'add' - ? prev.deals.totalCount + 1 - : action === 'remove' - ? prev.deals.totalCount - 1 - : prev.deals.totalCount, + totalCount: Math.max( + 0, + (prev.deals.totalCount ?? currentList.length) + + (updatedList.length - currentList.length), + ), }, };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/plugins/sales_ui/src/modules/deals/cards/hooks/useDeals.tsx` around lines 147 - 160, The totalCount calculation in the state updater function uses arithmetic based on the action type, which can cause drift from the actual list size when there are duplicate operations or when prior count is undefined. Instead of incrementing or decrementing totalCount based on the action, replace the conditional arithmetic logic with a direct assignment that sets totalCount to the length of updatedList. This ensures the count always reflects the actual size of the list being managed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/plugins/sales_ui/src/modules/deals/utils/queryVariables.ts`:
- Around line 19-24: The DATE_UPPER_BOUND_KEYS set contains an incorrect key
name mismatch. On line 23, the entry is `stateChangedEndDate`, but the actual
filter state and query keys use `stageChangedEndDate` (note the difference:
"stage" vs "state"). This mismatch causes resolveParam to not recognize the
upper-bound key when it should, leading to incorrect variable key forwarding to
the backend. In the DATE_UPPER_BOUND_KEYS set definition, change the
`stateChangedEndDate` entry to `stageChangedEndDate` to match the actual filter
state keys used throughout the application.
---
Outside diff comments:
In `@frontend/plugins/sales_ui/src/modules/deals/cards/hooks/useDeals.tsx`:
- Around line 147-160: The totalCount calculation in the state updater function
uses arithmetic based on the action type, which can cause drift from the actual
list size when there are duplicate operations or when prior count is undefined.
Instead of incrementing or decrementing totalCount based on the action, replace
the conditional arithmetic logic with a direct assignment that sets totalCount
to the length of updatedList. This ensures the count always reflects the actual
size of the list being managed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6746e762-77e1-432a-840b-2512702c97eb
📒 Files selected for processing (7)
frontend/plugins/sales_ui/src/modules/deals/actionBar/components/SalesFilter.tsxfrontend/plugins/sales_ui/src/modules/deals/actionBar/constants/Filters.tsfrontend/plugins/sales_ui/src/modules/deals/actionBar/types/actionBarTypes.tsfrontend/plugins/sales_ui/src/modules/deals/boards/components/DealsBoard.tsxfrontend/plugins/sales_ui/src/modules/deals/boards/components/DealsBoardColumn.tsxfrontend/plugins/sales_ui/src/modules/deals/cards/hooks/useDeals.tsxfrontend/plugins/sales_ui/src/modules/deals/utils/queryVariables.ts
…d infinite loading totalcount
6c12ad7 to
9bd6412
Compare
|
…d infinite loading totalcount (#8294)
Summary by CodeRabbit
Release Notes