File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -25,23 +25,22 @@ export function SearcherBar({ className }: { className?: string }) {
2525 slug : string ,
2626 value : string
2727 ) => {
28- const entityToRoute : Record < string , string > = {
28+ const route = Object . entries ( {
2929 deal : 'deal' ,
3030 task : 'task' ,
3131 dataset : 'dataset' ,
3232 app : 'app' ,
3333 workerpool : 'workerpool' ,
3434 account : 'address' ,
3535 transaction : 'tx' ,
36- } ;
36+ } ) . find ( ( [ entityKey ] ) => data [ entityKey ] ) ;
3737
38- for ( const [ entityKey , routePath ] of Object . entries ( entityToRoute ) ) {
39- if ( data [ entityKey ] ) {
40- navigate ( { to : `/${ slug } /${ routePath } /${ value } ` } ) ;
41- return ;
42- }
38+ if ( route ) {
39+ const [ , routePath ] = route ;
40+ navigate ( { to : `/${ slug } /${ routePath } /${ value } ` } ) ;
41+ } else {
42+ throw new Error ( 'An error occurred please try again' ) ;
4343 }
44- throw new Error ( 'An error occurred please try again' ) ;
4544 } ;
4645
4746 const { mutate, isPending, isError, error } = useMutation ( {
You can’t perform that action at this time.
0 commit comments