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|
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|