Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SSHOC
sshoc-marketplace-frontend
Commits
72f54499
Commit
72f54499
authored
Mar 05, 2021
by
Stefan Probst
Browse files
fix: remove empty query string
parent
87a5ae54
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/modules/search/ItemSearchForm.tsx
View file @
72f54499
import
{
useRouter
}
from
'
next/router
'
import
{
ReactNode
,
useMemo
,
useState
}
from
'
react
'
import
{
useAutocompleteItems
,
useGetItemCategories
}
from
'
@/api/sshoc
'
import
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ItemCategory
,
ItemSearchQuery
}
from
'
@/api/sshoc/types
'
import
{
Button
}
from
'
@/elements/Button/Button
'
import
{
HighlightedText
}
from
'
@/elements/HighlightedText/HighlightedText
'
import
{
useDebouncedState
}
from
'
@/lib/hooks/useDebouncedState
'
...
...
@@ -26,16 +26,16 @@ export default function ItemSearchForm(
const
router
=
useRouter
()
function
onSubmit
(
values
:
SearchFormValues
)
{
router
.
push
({
pathname
:
'
/search
'
,
query
:
{
q
:
values
.
q
!==
undefined
&&
values
.
q
.
length
>
0
?
values
.
q
:
undefined
,
categories
:
values
.
category
!==
undefined
&&
values
.
category
.
length
>
0
?
[
values
.
category
]
:
undefined
,
},
})
const
query
:
ItemSearchQuery
=
{}
if
(
values
.
q
!==
undefined
&&
values
.
q
.
length
>
0
)
{
query
.
q
=
values
.
q
}
if
(
values
.
category
!==
undefined
&&
values
.
category
.
length
>
0
)
{
query
.
categories
=
[
values
.
category
]
}
router
.
push
({
pathname
:
'
/search
'
,
query
})
}
return
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment