@@ -26,20 +26,39 @@ export const DashboardGovernanceActionsVotedOn = ({
2626 const { t } = useTranslation ( ) ;
2727
2828 // TODO: Filtering here is some kind of craziness. It should be done on the backend.
29+
2930 const filteredData = useMemo ( ( ) => {
30- if ( votes . length && searchPhrase ) {
31- return votes
32- . map ( ( entry ) => ( {
31+ if ( ! votes ?. length ) return [ ] ;
32+ if ( ! searchPhrase ) return votes ;
33+ const lowerSearch = searchPhrase . toLowerCase ( ) ;
34+ return votes
35+ . map ( ( entry ) => {
36+ const filteredActions = entry . actions . filter ( ( action ) => {
37+ const hash = getFullGovActionId (
38+ action . proposal . txHash ,
39+ action . proposal . index ,
40+ ) . toLowerCase ( ) ;
41+
42+ const title = action . proposal . title ?. toLowerCase ( ) || "" ;
43+ const motivation = action . proposal . motivation ?. toLowerCase ( ) || "" ;
44+ const rationale = action . proposal . rationale ?. toLowerCase ( ) || "" ;
45+ const abstract = action . proposal . abstract ?. toLowerCase ( ) || "" ;
46+
47+ return (
48+ hash . includes ( lowerSearch ) ||
49+ title . includes ( lowerSearch ) ||
50+ motivation . includes ( lowerSearch ) ||
51+ rationale . includes ( lowerSearch ) ||
52+ abstract . includes ( lowerSearch )
53+ ) ;
54+ } ) ;
55+
56+ return {
3357 ...entry ,
34- actions : entry . actions . filter ( ( action ) =>
35- getFullGovActionId ( action . proposal . txHash , action . proposal . index )
36- . toLowerCase ( )
37- . includes ( searchPhrase . toLowerCase ( ) ) ,
38- ) ,
39- } ) )
40- . filter ( ( entry ) => entry . actions ?. length > 0 ) ;
41- }
42- return votes ;
58+ actions : filteredActions ,
59+ } ;
60+ } )
61+ . filter ( ( entry ) => entry . actions . length > 0 ) ;
4362 } , [ votes , searchPhrase , pendingTransaction . vote ] ) ;
4463
4564 return areDRepVotesLoading ? (
0 commit comments