SearchBar.purs 1.5 KB
Newer Older
1
module Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar
2 3
  ( Props
  , searchBar
4
  ) where
5

6
import Data.Tuple.Nested ((/\))
7
import Effect (Effect)
8 9 10
import Reactix as R
import Reactix.DOM.HTML as H

11
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (searchField)
12 13
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types -- (Database, SearchQuery(..), defaultSearchQuery, performSearch, Lang(..))
import Gargantext.Components.Lang (Lang)
14
import Gargantext.Prelude (Unit, pure, ($))
15
import Gargantext.Sessions (Session)
16
import Gargantext.Types as GT
17
import Gargantext.Utils.Reactix as R2
18

19 20
here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar"
21

22 23
type Props = ( langs     :: Array Lang
             , onSearch  :: GT.AsyncTaskWithType -> Effect Unit
24
             , search    :: R.State Search
25
             , session   :: Session
26
             )
27 28

searchBar :: Record Props -> R.Element
29
searchBar props = R.createElement searchBarCpt props []
30

31
searchBarCpt :: R.Component Props
32
searchBarCpt = here.component "searchBar" cpt
33
  where
34
    cpt {langs, onSearch, search: search@(s /\ _), session} _ = do
35
      --onSearchChange session s
36
      pure $ H.div { className: "search-bar" }
37 38 39 40 41 42 43
                   [ searchField { databases:allDatabases
                                 , langs
                                 , onSearch
                                 , search
                                 , session
                                 }
                   ]