aboutsummaryrefslogtreecommitdiff
path: root/src/server/Controller/Payment.hs
diff options
context:
space:
mode:
authorJoris2015-09-11 10:36:27 +0200
committerJoris2015-09-11 10:36:27 +0200
commitd87dbd1360c14df83552fd757438c23e5d7b9f9c (patch)
tree8b28def0414205608bd964c9b38a98b9d6828655 /src/server/Controller/Payment.hs
parent73fa92aeffb27a98d8f316be157883ecefb1aed5 (diff)
downloadbudget-d87dbd1360c14df83552fd757438c23e5d7b9f9c.tar.gz
budget-d87dbd1360c14df83552fd757438c23e5d7b9f9c.tar.bz2
budget-d87dbd1360c14df83552fd757438c23e5d7b9f9c.zip
Using jsonObject to create on the fly json object responses
Diffstat (limited to 'src/server/Controller/Payment.hs')
-rw-r--r--src/server/Controller/Payment.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server/Controller/Payment.hs b/src/server/Controller/Payment.hs
index 7cbfb37..85e2a87 100644
--- a/src/server/Controller/Payment.hs
+++ b/src/server/Controller/Payment.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE OverloadedStrings #-}
+
module Controller.Payment
( getPaymentsAction
, getMonthlyPaymentsAction
@@ -16,18 +18,21 @@ import Database.Persist
import Control.Monad.IO.Class (liftIO)
import Data.Text (Text)
+import qualified Data.Aeson.Types as Json
import qualified Secure
import Model.Database
import Model.Payment
import Model.Frequency
-import Model.Json.Message
import Model.Json.Number
import qualified Model.Json.PaymentId as JP
import Model.Message
import Model.Message.Key (Key(PaymentNotDeleted))
+
+import Json (jsonObject)
+
getPaymentsAction :: Int -> Int -> ActionM ()
getPaymentsAction page perPage =
Secure.loggedAction (\_ -> do
@@ -56,7 +61,7 @@ deletePaymentAction paymentId =
status ok200
else do
status badRequest400
- json . Message . getMessage $ PaymentNotDeleted
+ jsonObject [("error", Json.String $ getMessage PaymentNotDeleted)]
)
getTotalPaymentsAction :: ActionM ()