Delete.purs 1.46 KB
Newer Older
1 2 3 4 5 6 7 8 9
module Gargantext.Components.Forest.Tree.Node.Action.Delete
  where

import Data.Maybe (Maybe(..))
import Gargantext.Prelude
import Effect.Aff (Aff)
import Gargantext.Types  as GT
import Gargantext.Sessions (Session, delete)
import Gargantext.Routes (SessionRoute(..))
10 11 12
import Gargantext.Types (NodeType(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Reactix as R
13
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel)
14
import Reactix.DOM.HTML as H
15 16 17 18 19

-- TODO Delete with asyncTaskWithType
deleteNode :: Session -> GT.ID -> Aff GT.ID
deleteNode session nodeId = delete session $ NodeAPI GT.Node (Just nodeId) ""

20 21 22
-- | Action : Delete
actionDelete :: NodeType -> (Action -> Aff Unit) -> R.Hooks R.Element
actionDelete NodeUser _ = do
23 24 25 26 27 28 29 30
  pure $ panel [ H.div { style: {margin: "10px"}}
                       [ H.text $ "Yes, we are RGPD compliant!"
                      <> " But you can not delete User Node yet."
                      <> " We are still on development."
                      <> " Thanks for your comprehensin."
                       ]
               ]
               (H.div {} [])
31 32

actionDelete _ dispatch = do
33 34 35 36 37 38
  pure $ panel [ H.div {style: {margin: "10px"}} 
                (map (\t -> H.p {} [H.text t]) 
                     [ "Are your sure you want to delete it ?"
                     , "If yes, click again below."
                     ]
                )
39
               ]
40
               (submitButton DeleteNode dispatch)
41 42 43



44