{-|
Module: IHP.Modal.ControllerFunctions
Description: Controller Helper Functions to use modals
Copyright: (c) digitally induced GmbH, 2020
-}
module IHP.Modal.ControllerFunctions (setModal) where

import IHP.Prelude
import IHP.Controller.Context
import IHP.Modal.Types
import qualified IHP.ViewSupport as ViewSupport

setModal :: (?context :: ControllerContext, ViewSupport.View view) => view -> IO ()
setModal :: forall view.
(?context::ControllerContext, View view) =>
view -> IO ()
setModal view
view = do
    Html
html <- do
        ControllerContext
context <- ControllerContext -> IO ControllerContext
freeze ?context::ControllerContext
ControllerContext
?context
        let ?context = ?context::ControllerContext
ControllerContext
context
        let ?view = view
?view::view
view
        Html -> IO Html
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Html -> IO Html) -> Html -> IO Html
forall a b. (a -> b) -> a -> b
$ view -> Html
forall theView.
(View theView, ?context::ControllerContext, ?view::theView) =>
theView -> Html
ViewSupport.html view
view
        
    ModalContainer -> IO ()
forall value.
(?context::ControllerContext, Typeable value) =>
value -> IO ()
putContext (Html -> ModalContainer
ModalContainer Html
html)