Commit 264dd152 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[SearchBar] fix api backend.

parent b8c1e90b
......@@ -12,7 +12,7 @@ import Gargantext.Config (urlPlease, End(Back))
import URI.Query as Q
searchUrl :: SearchQuery -> String
searchUrl q = urlPlease Back $ "search" <> Q.print (toQuery q)
searchUrl q = urlPlease Back $ "new" <> Q.print (toQuery q)
search :: forall a. DecodeJson a => SearchQuery -> Aff a
search q = do
......
......@@ -47,7 +47,7 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
cpt props _ = do
let search = maybe defaultSearch identity (fst props.search)
term <- R.useState $ \_ -> pure search.term
db <- R.useState $ \_ -> pure Nothing
db <- R.useState $ \_ -> pure Nothing
pure $
div { className: "search-field" }
[ databaseInput db props.databases
......
......@@ -52,7 +52,7 @@ instance showSearchOrder :: Show SearchOrder where
show ScoreDesc = "ScoreDesc"
newtype SearchQuery = SearchQuery
{ query :: Array String
{ query :: String
, databases :: Array Database
, corpus_id :: Maybe Int
, offset :: Maybe Int
......@@ -63,7 +63,7 @@ derive instance newtypeSearchQuery :: Newtype SearchQuery _
defaultSearchQuery :: SearchQuery
defaultSearchQuery = SearchQuery
{ query: []
{ query: ""
, databases: allDatabases
, corpus_id: Nothing
, offset: Nothing
......
......@@ -57,7 +57,7 @@ onSearchChange (search /\ setSearch) =
(r :: Unit) <- Ajax.search (searchQuery q)
liftEffect $ log2 "Return:" r
liftEffect $ modalShow "addCorpus"
searchQuery {term} = over SearchQuery (_ {query=[term]}) defaultSearchQuery
searchQuery {term} = over SearchQuery (_ {query=term}) defaultSearchQuery
toggleButton :: R.State Boolean -> R.Element
toggleButton open =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment