-
Notifications
You must be signed in to change notification settings - Fork 5
Product fix #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Product fix #273
Changes from 25 commits
d59d5dc
0dd4b76
8b81027
7ad9d3c
b14cfc0
2e5fd2a
478173d
16ffd7a
5958f1a
76cd8c5
191b0e3
6526b4b
daa1b4e
0ea3d73
5678117
7cb64ee
1620153
6d86584
f2fef86
1cf5e91
35a9f77
efd2267
1a309db
08054bd
ff8b238
a708f0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,7 @@ export const GET_COMPANIES = gql` | |
| ownerId | ||
| tagIds | ||
| score | ||
| cursor | ||
| } | ||
| ${GQL_PAGE_INFO} | ||
| } | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,38 +1,80 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { ProductHotKeyScope } from '@/products/types/ProductsHotKeyScope'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { IconSearch } from '@tabler/icons-react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Combobox, Command, Filter } from 'erxes-ui'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { TagsFilter } from 'ui-modules'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Combobox, Command, Filter, useMultiQueryState } from 'erxes-ui'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { TagsFilter, SelectBrand, SelectCategory } from 'ui-modules'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { PRODUCTS_CURSOR_SESSION_KEY } from '../constants/productsCursorSessionKey'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const ProductsFilter = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [queries] = useMultiQueryState<{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| searchValue: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| created: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updated: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lastSeen: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }>(['searchValue', 'created', 'updated', 'lastSeen']); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { searchValue } = queries || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add missing 'brand' to query state type The Apply this diff to include the missing type: const [queries] = useMultiQueryState<{
searchValue: string;
created: string;
updated: string;
lastSeen: string;
+ brand: string;
- }>(['searchValue', 'created', 'updated', 'lastSeen']);
+ }>(['searchValue', 'created', 'updated', 'lastSeen', 'brand']);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Filter id="products-filter" sessionKey={PRODUCTS_CURSOR_SESSION_KEY}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Filter.Bar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {searchValue && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Filter.BarItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Filter.BarName> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <IconSearch /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Filter.BarName> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Filter.BarButton filterKey="searchValue" inDialog> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {searchValue} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Filter.BarButton> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Filter.BarClose filterKey="searchValue" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Filter.BarItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <TagsFilter.Bar tagType="core:product" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <SelectBrand.FilterBar /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <SelectCategory.FilterBar /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ProductsFilterPopover /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Filter.Bar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Filter> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const ProductsFilterPopover = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ProductsFilterPopover = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use named export for ProductsFilterPopover Per the coding guidelines, components should use named exports rather than local constants. Apply this diff to export the component: -const ProductsFilterPopover = () => {
+export const ProductsFilterPopover = () => {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [queries] = useMultiQueryState<{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| searchValue: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| created: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updated: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lastSeen: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }>(['searchValue', 'created', 'updated', 'lastSeen']); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [queries] = useMultiQueryState<{ | |
| searchValue: string; | |
| created: string; | |
| updated: string; | |
| lastSeen: string; | |
| }>(['searchValue', 'created', 'updated', 'lastSeen']); | |
| // In frontend/core-ui/src/modules/products/components/ProductsFilter.tsx | |
| // --- Parent component: lift the hook up and pass queries down --- | |
| export function ProductsFilter() { | |
| const [queries] = useMultiQueryState<{ | |
| searchValue: string; | |
| created: string; | |
| updated: string; | |
| lastSeen: string; | |
| }>(['searchValue', 'created', 'updated', 'lastSeen']); | |
| return ( | |
| <div> | |
| {/* other filter UI */} | |
| - <ProductsFilterPopover /> | |
| + <ProductsFilterPopover queries={queries} /> | |
| </div> | |
| ); | |
| } | |
| // --- Child component: accept queries as a prop instead of re-calling the hook --- | |
| interface ProductsFilterPopoverProps { | |
| queries: { | |
| searchValue: string; | |
| created: string; | |
| updated: string; | |
| lastSeen: string; | |
| }; | |
| } | |
| export function ProductsFilterPopover({ queries }: ProductsFilterPopoverProps) { | |
| // Removed duplicate useMultiQueryState call here— | |
| // use the `queries` prop directly to render your filters. | |
| return ( | |
| <div> | |
| {/* render filter inputs, e.g.: */} | |
| <input value={queries.searchValue} /* … */ /> | |
| {/* etc. */} | |
| </div> | |
| ); | |
| } |
🤖 Prompt for AI Agents
In frontend/core-ui/src/modules/products/components/ProductsFilter.tsx around
lines 41 to 46, the useMultiQueryState hook is called redundantly both here and
in ProductsFilterPopover with the same parameters. To fix this, remove the
duplicate useMultiQueryState call from ProductsFilterPopover and instead pass
the queries state obtained here as props to ProductsFilterPopover. Update
ProductsFilterPopover to accept these props and use them directly, eliminating
the redundant hook invocation.
Uh oh!
There was an error while loading. Please reload this page.