Skip to content

loyalty-score-sales-search#8034

Open
Khuslen122 wants to merge 5 commits into
mainfrom
loyalty-score-sales-search
Open

loyalty-score-sales-search#8034
Khuslen122 wants to merge 5 commits into
mainfrom
loyalty-score-sales-search

Conversation

@Khuslen122

@Khuslen122 Khuslen122 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added a “Status” filter to products (active/deleted), wired through query state.
    • Introduced product-group filtering UI (search, product selection, status) with a total-records count.
  • Bug Fixes
    • Improved deal search matching by reliably handling numeric identifiers stored as numbers during search.
    • Fixed pointer-events restoration when closing the deal selection sheet.
    • Updated sales tab behavior to re-open the deal selection sheet when already in Sales mode.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @Khuslen122, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 65fa492b-65fe-467b-8153-2cd859b45688

📥 Commits

Reviewing files that changed from the base of the PR and between f5a2c03 and fe221c0.

📒 Files selected for processing (1)
  • frontend/core-ui/src/modules/products/components/ProductsFilter.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/core-ui/src/modules/products/components/ProductsFilter.tsx

📝 Walkthrough

Walkthrough

Four independent changes: MongoDB deal search is fixed to coerce the numeric number field to a string before regex matching; a Status filter is added to the Products module end-to-end (hook type, GraphQL variable, UI components); the loyalty ChooseDealSheet pointer-events bug is patched and the sales tab trigger is made re-entrant; a new filter bar with search, product, status, and total count is introduced for the ProductGroup settings page.

Changes

Backend: Deal Number Search Coercion

Layer / File(s) Summary
MongoDB $expr string coercion for deal number search
backend/plugins/sales_api/src/modules/sales/graphql/resolvers/queries/deals.ts
Replaces direct regex on number with $expr/$regexMatch over $toString/$ifNull so numeric or null stored values match search input correctly.

Products Status Filter (core-ui)

Layer / File(s) Summary
Status variable in hook type and GraphQL query
frontend/core-ui/src/modules/products/hooks/useProducts.tsx, frontend/core-ui/src/modules/products/graphql/ProductsQueries.tsx
ProductsQueryVariables gains optional status; useMultiQueryState parses and maps it to query variables; ProductsMain declares $status: String and passes it to productsMain.
Status filter UI components and filter bar/popover wiring
frontend/core-ui/src/modules/products/components/ProductsFilter.tsx
Introduces reusable OptionFilterConfig model and implements OptionFilterItem, OptionFilterView, OptionFilterBar; adds PRODUCT_STATUS_FILTER configuration; wires status filtering into the filter bar and popover UI.

Loyalty UI: ChooseDealSheet pointer-events fix and tab trigger

Layer / File(s) Summary
ChooseDealSheet pointer-events restore and GiveScoreModal tab trigger
frontend/plugins/loyalty_ui/src/modules/loyalties/scores/components/ChooseDealSheet.tsx, frontend/plugins/loyalty_ui/src/modules/loyalties/scores/components/GiveScoreModal.tsx
ChooseDealSheet adds a useEffect that clears document.body.style.pointerEvents via a timeout when the sheet closes. GiveScoreModal adds an onClick to the Sales pipeline tab that reopens the sheet if targetType is already 'sales'.

ProductGroup Filter and Total Count (mongolian_ui)

Layer / File(s) Summary
Jotai atom, multi-query-state hook wiring, and total count effect
frontend/plugins/mongolian_ui/src/modules/ebarimt/settings/product-group/states/productGroupRowStates.ts, frontend/plugins/mongolian_ui/src/modules/ebarimt/settings/product-group/hooks/useProductGroupRows.tsx
Adds productGroupTotalCountAtom; useProductGroupRows reads searchValue, productId, and status from useMultiQueryState, passes them to the Apollo query, and writes totalCount into the atom after loading.
ProductGroupFilter, TotalCount, and page integration
frontend/plugins/mongolian_ui/src/modules/ebarimt/settings/product-group/components/ProductGroupFilter.tsx, frontend/plugins/mongolian_ui/src/modules/ebarimt/settings/product-group/components/ProductGroupTotalCount.tsx, frontend/plugins/mongolian_ui/src/pages/ProductGroupPage.tsx
Adds ProductGroupTotalCount (renders skeleton or count from atom), the full ProductGroupFilter (status options, cursor-reset hook, status filter bar/popover, composed Filter container), and mounts both on ProductGroupPage.

Sequence Diagram(s)

sequenceDiagram
  rect rgba(173, 216, 230, 0.5)
    note over ProductGroupPage,ProductGroupTotalCount: ProductGroup filter and count data flow
    ProductGroupPage->>ProductGroupFilter: render filter bar
    ProductGroupFilter->>useProductGroupRows: searchValue, productId, status from useMultiQueryState
    useProductGroupRows->>GET_PRODUCT_GROUP: Apollo query with filter variables + cursor pagination
    GET_PRODUCT_GROUP-->>useProductGroupRows: rows + totalCount
    useProductGroupRows->>productGroupTotalCountAtom: setAtom(totalCount) when loading=false
    productGroupTotalCountAtom-->>ProductGroupTotalCount: useAtomValue → Skeleton or "{n} records found"
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • erxes/erxes#7847: Directly modifies the same deals.ts filter query construction logic that this PR replaces with $expr/$regexMatch.
  • erxes/erxes#7634: Extends ProductsFilter.tsx with additional query-state-driven filter items using the same pattern as this PR's status filter addition.
  • erxes/erxes#7947: Modifies the loyalty deal selection UI in ChooseDealSheet.tsx, directly related to this PR's pointer-events and tab-trigger fixes.

Poem

🐇 A rabbit hopped through fields of code,
Coercing numbers down the filter road,
The pointer-events bug? Cleared with a timeout's grace,
ProductGroup now sports a filter face,
Status checked, totals shown, all queries aligned—
A tidier warren left behind! 🌿

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title 'loyalty-score-sales-search' is vague and does not clearly convey the main purpose of the changeset. While it references loyalty and sales, it lacks specificity about what was actually implemented or changed. Revise the title to be more descriptive, such as 'Add product status filter and fix deal search logic' or 'Implement status filtering for products and sales deals' to better reflect the main changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch loyalty-score-sales-search

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

This commit fixes the style issues introduced in a36ec40 according to the output
from Prettier.

Details: #8034
@deepsource-io

deepsource-io Bot commented Jun 15, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 39842fe...fe221c0 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Jun 15, 2026 12:21p.m. Review ↗
Docker Jun 15, 2026 12:21p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread frontend/core-ui/src/modules/products/components/ProductsFilter.tsx Fixed
);
}

function ProductStatusFilterItem() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for function declaration `ProductStatusFilterItem`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

);
}

function ProductStatusFilterView() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for function declaration `ProductStatusFilterView`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

);
}

function ProductStatusFilterBar() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for function declaration `ProductStatusFilterBar`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

}: ChooseDealSheetProps) => {
const [selectedDeal, setSelectedDeal] = useState<IDeal | null>(null);

useEffect(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected to return a value at the end of arrow function


Any code paths that do not have explicit returns will return undefined. It is recommended to replace any implicit dead-ends that return undefined with a return null statement.

{ value: 'inactive', label: 'Inactive' },
];

const useResetProductGroupCursor = () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for arrow function `useResetProductGroupCursor`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

);
};

const StatusFilterBar = () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for arrow function `StatusFilterBar`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

);
};

const ProductGroupFilterPopover = () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for arrow function `ProductGroupFilterPopover`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

);

return (
<Filter.Popover scope={PRODUCT_GROUP_FILTER_ID}>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

JSX tree is too deeply nested. Found 6 levels of nesting


Nesting JSX elements too deeply can confuse developers reading the code. To make maintenance and refactoring easier, DeepSource recommends limiting the maximum JSX tree depth to 4.

);
};

export const ProductGroupFilter = () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for arrow function `ProductGroupFilter`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

import { useAtomValue } from 'jotai';
import { productGroupTotalCountAtom } from '@/ebarimt/settings/product-group/states/productGroupRowStates';

export const ProductGroupTotalCount = () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for arrow function `ProductGroupTotalCount`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/mongolian_ui/src/modules/ebarimt/settings/product-group/hooks/useProductGroupRows.tsx`:
- Around line 57-61: The useEffect hook in useProductGroupRows currently only
updates the productGroupTotalCount atom after loading completes, leaving the
previous count visible during refetch or filter changes instead of showing a
loading state. Modify the useEffect callback to set the productGroupTotalCount
atom to null when loading becomes true, then set it to the actual totalCount
value when loading becomes false. This ensures the UI displays a loading
skeleton during data fetches rather than stale count information.
🪄 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: 8f818a69-7b44-481d-bef7-2f385ac645ea

📥 Commits

Reviewing files that changed from the base of the PR and between 39842fe and 3d17deb.

📒 Files selected for processing (11)
  • backend/plugins/sales_api/src/modules/sales/graphql/resolvers/queries/deals.ts
  • frontend/core-ui/src/modules/products/components/ProductsFilter.tsx
  • frontend/core-ui/src/modules/products/graphql/ProductsQueries.tsx
  • frontend/core-ui/src/modules/products/hooks/useProducts.tsx
  • frontend/plugins/loyalty_ui/src/modules/loyalties/scores/components/ChooseDealSheet.tsx
  • frontend/plugins/loyalty_ui/src/modules/loyalties/scores/components/GiveScoreModal.tsx
  • frontend/plugins/mongolian_ui/src/modules/ebarimt/settings/product-group/components/ProductGroupFilter.tsx
  • frontend/plugins/mongolian_ui/src/modules/ebarimt/settings/product-group/components/ProductGroupTotalCount.tsx
  • frontend/plugins/mongolian_ui/src/modules/ebarimt/settings/product-group/hooks/useProductGroupRows.tsx
  • frontend/plugins/mongolian_ui/src/modules/ebarimt/settings/product-group/states/productGroupRowStates.ts
  • frontend/plugins/mongolian_ui/src/pages/ProductGroupPage.tsx

Comment thread frontend/core-ui/src/modules/products/components/ProductsFilter.tsx Fixed
};

function ProductTypeFilterItem() {
function OptionFilterItem({ config }: { config: OptionFilterConfig }) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for function declaration `OptionFilterItem`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]


function ProductTypeFilterView() {
const [type, setType] = useQueryState<string>('type');
function OptionFilterView({ config }: { config: OptionFilterConfig }) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for function declaration `OptionFilterView`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]


function ProductTypeFilterBar() {
const [type, setType] = useQueryState<string>('type');
function OptionFilterBar({ config }: { config: OptionFilterConfig }) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for function declaration `OptionFilterBar`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

Khuslen122 and others added 2 commits June 15, 2026 19:59
- ProductsFilter: drop redundant value fallback in OptionFilterBar
- useProductGroupRows: reset total-count atom while loading

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Resolves sonar react/prefer-read-only-props findings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
type OptionFilterProps = Readonly<{ config: OptionFilterConfig }>;

function ProductTypeFilterItem() {
function OptionFilterItem({ config }: OptionFilterProps) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Documentation comment not found for function declaration `OptionFilterItem`


It is recommended to have documentation comments above, or right inside a function/class declaration.
This helps developers, users and even the author understand the purpose of a code snippet or API function in the future.

NOTE: If you want to stop this issue from getting raised on certain constructs (arrow functions, class expressions, methods etc.), consider using the skip_doc_coverage option under the analyzers.meta property in your .deepsource.toml file.
For example, the following configuration will silence this issue for class expressions and method definitions:

[analyzers.meta]
    skip_doc_coverage = ["class-expression", "method-definition"]

@sonarqubecloud

Copy link
Copy Markdown

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