Skip to content

Commit

Permalink
Update SearchBar.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw-zakrzewski committed Oct 23, 2024
1 parent e950071 commit 5e04403
Showing 1 changed file with 8 additions and 34 deletions.
42 changes: 8 additions & 34 deletions verification/curator-service/ui/src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,42 +122,16 @@ export default function SearchBar({


const handleNavigating = (q: string) => {
const encodedQ = encodeURIComponent(q);
if (encodedQ === '') {
if (location.search.includes('?q=')) {
navigate({
pathname: '/cases',
search: '',
});
} else if(location.search.includes('&q=')) {
navigate({
pathname: '/cases',
search: location.search.split('&q=')[0],
});
} else {
navigate({
pathname: '/cases',
search: location.search,
});
}
const searchParams = new URLSearchParams(location.search);
if (q !== '') {
searchParams.set('q', q);
} else {
if (location.search.includes('?q=') || location.search === '') {
navigate({
pathname: '/cases',
search: `?q=${encodedQ}`,
});
} else if(location.search.includes('&q=')) {
navigate({
pathname: '/cases',
search: `${location.search.split('&q=')[0]}&q=${encodedQ}`,
});
} else {
navigate({
pathname: '/cases',
search: `${location.search}&q=${encodedQ}`,
});
}
searchParams.delete('q');
}
navigate({
pathname: '/cases',
search: searchParams.toString(),
});
}

// Apply filter parameters after delay
Expand Down

0 comments on commit 5e04403

Please sign in to comment.