@@ -41,7 +41,7 @@ export interface DuoSynergyForm extends Omit<GetDuoSynergyListOptions, 'champion
4141
4242export interface FilteredChampionItem {
4343 id : number
44- enName : string
44+ normalizedName : string
4545 alias : string [ ]
4646}
4747
@@ -103,17 +103,20 @@ const DuoSynergyTable = ({ className }: DuoSynergyTableProps) => {
103103 useEffect ( ( ) => {
104104 const championNameAlias = t ( 'league.championNameAlias' , { returnObjects : true } )
105105
106+ const query = search . replaceAll ( ' ' , '' ) . toLowerCase ( )
107+
106108 const filteredChampions =
107- ! championNames || ! search . trim ( ) . length
109+ ! championNames || ! query . length
108110 ? [ ]
109111 : Object . keys ( championNames ) . reduce < FilteredChampionItem [ ] > ( ( acc , id ) => {
110- const enName = championNames [ id ] . en
112+ const { en : enName , ko : name } = championNames [ id ]
111113 const alias = championNameAlias [ enName ] ?? [ ]
114+ const normalizedName = name . replaceAll ( ' ' , '' ) . toLowerCase ( )
112115
113- if ( includesByCho ( search , enName ) || alias . some ( x => includesByCho ( search , x ) ) ) {
116+ if ( includesByCho ( query , normalizedName ) || alias . some ( x => includesByCho ( query , x ) ) ) {
114117 acc . push ( {
115118 id : + id ,
116- enName ,
119+ normalizedName ,
117120 alias,
118121 } )
119122 }
@@ -122,12 +125,12 @@ const DuoSynergyTable = ({ className }: DuoSynergyTableProps) => {
122125 } , [ ] )
123126
124127 const distanceChampionNames : string [ ] = correctByDistance (
125- search ,
126- filteredChampions . map ( x => x . enName ) ,
128+ query ,
129+ filteredChampions . map ( x => x . normalizedName ) ,
127130 )
128131
129132 const filteredChampionId : number | null = distanceChampionNames . length
130- ? filteredChampions . find ( x => x . enName === distanceChampionNames [ 0 ] ) ! . id
133+ ? filteredChampions . find ( x => x . normalizedName === distanceChampionNames [ 0 ] ) ! . id
131134 : filteredChampions . length === 1
132135 ? filteredChampions [ 0 ] . id
133136 : null
0 commit comments