module Handler.Home where import Import loginOrElse :: ((Key User, User) -> Handler Html) -> Handler Html -> Handler Html loginOrElse cont contElse = do maid <- maybeAuthId muid <- case maid of Just uid -> fmap ((,) uid) <$> runDB (get uid) Nothing -> return Nothing case muid of Nothing -> contElse Just (uid,u) -> cont (uid,u) getHomeR :: Handler Html getHomeR = do loginOrElse getLoggedIn getNotLoggedIn getLoggedIn :: (Key User, User) -> Handler Html getLoggedIn (uid, user) = do loginLayout user $ [whamlet|

Welcome back, #{userName user}.

Current Balance: #{prettyISK $ userBalanceCents user} ISK.

Current Stock Worth: ...

Current total Worth: ...

Profit in the last 7 days: ... |] getNotLoggedIn :: Handler Html getNotLoggedIn = do defaultLayout $ do setTitle "NEAT" [whamlet|

Welcome to NEAT.
Here we should present features, images and other stuff to get people hooked. |] {- (formWidget, formEnctype) <- generateFormPost sampleForm let submission = Nothing :: Maybe (FileInfo, Text) handlerName = "getHomeR" :: Text defaultLayout $ do aDomId <- newIdent setTitle "Welcome To Yesod!" $(widgetFile "homepage")-} postHomeR :: Handler Html postHomeR = do defaultLayout $ [whamlet|

nothing to see here. Stuff coming soon (tm). |] {- ((result, loginWidget), loginEnctype) <- runFormPost loginForm let loginfail err = defaultLayout $ do setTitle "NEAT" [whamlet|

Welcome to NEAT.