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 let totalworth = userBalanceCents user + userStockCents user + userEscrowCents user loginLayout user $ [whamlet|
Current Balance: #{prettyISK $ userBalanceCents user} ISK.
Current Stock Worth: #{prettyISK $ userStockCents user} ISK.
Current Escrow Worth: #{prettyISK $ userEscrowCents user} ISK.
Current total Worth: #{prettyISK $ totalworth} ISK. |] getNotLoggedIn :: Handler Html getNotLoggedIn = do defaultLayout $ do setTitle "NEAT" [whamlet|