@@ -57,33 +57,36 @@ export default function Page() {
5757
5858 const totalElements = data ?. pages [ 0 ] ?. meta . totalElements ?? 0 ;
5959
60- const findCategoryPath = (
61- categories : ItemCategory [ ] ,
62- targetId : string ,
63- currentPath : ItemCategory [ ] = [ ] ,
64- ) : ItemCategory [ ] => {
65- for ( const category of categories ) {
66- const newPath = [ ...currentPath , category ] ;
67- if ( category . id === targetId ) {
68- return newPath ;
69- }
70- if ( category . children ) {
71- const foundPath = findCategoryPath (
72- category . children ,
73- targetId ,
74- newPath ,
75- ) ;
76- if ( foundPath . length > 0 ) {
77- return foundPath ;
60+ const findCategoryPath = useCallback (
61+ (
62+ categories : ItemCategory [ ] ,
63+ targetId : string ,
64+ currentPath : ItemCategory [ ] = [ ] ,
65+ ) : ItemCategory [ ] => {
66+ for ( const category of categories ) {
67+ const newPath = [ ...currentPath , category ] ;
68+ if ( category . id === targetId ) {
69+ return newPath ;
70+ }
71+ if ( category . children ) {
72+ const foundPath = findCategoryPath (
73+ category . children ,
74+ targetId ,
75+ newPath ,
76+ ) ;
77+ if ( foundPath . length > 0 ) {
78+ return foundPath ;
79+ }
7880 }
7981 }
80- }
81- return [ ] ;
82- } ;
82+ return [ ] ;
83+ } ,
84+ [ ] ,
85+ ) ;
8386
8487 const categoryPath = useMemo (
8588 ( ) => findCategoryPath ( categories , selectedCategory ) ,
86- [ selectedCategory , categories ] ,
89+ [ selectedCategory , categories , findCategoryPath ] ,
8790 ) ;
8891
8992 useEffect ( ( ) => {
@@ -231,7 +234,6 @@ export default function Page() {
231234 params . itemOptionSearchRequest = { } ;
232235
233236 filters . forEach ( ( filter ) => {
234- const conditionKeys = Object . keys ( filter . searchCondition ) ;
235237 Object . entries ( filter . values ) . forEach ( ( [ key , value ] ) => {
236238 if ( value === undefined || value === "" ) return ;
237239
0 commit comments