From 166cd04e4b28770ede854dafc9ae30eae64102fe Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 28 Mar 2016 17:51:14 +0200 Subject: Create an empty but reachable user page --- src/server/Design/Header.hs | 2 +- src/server/Main.hs | 59 ++++++++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 26 deletions(-) (limited to 'src/server') diff --git a/src/server/Design/Header.hs b/src/server/Design/Header.hs index 8a348ad..a06a830 100644 --- a/src/server/Design/Header.hs +++ b/src/server/Design/Header.hs @@ -23,7 +23,7 @@ headerDesign = marginBottom blockMarginBottom position relative - button ? do + ((".title" |> h1) <> ".user" <> ".icon") ? do color C.white backgroundColor C.red hover & backgroundColor darkenedRed diff --git a/src/server/Main.hs b/src/server/Main.hs index 4f74f8e..e4ad9f6 100644 --- a/src/server/Main.hs +++ b/src/server/Main.hs @@ -20,6 +20,7 @@ import Controller.Income import Model.Database (runMigrations) import Model.Frequency +import Conf (Conf) import qualified Conf main :: IO () @@ -35,7 +36,9 @@ main = do middleware $ staticPolicy (noDots >-> addBase "public") - get "/" $ + api conf + + notFound $ ( do signInToken <- param "signInToken" :: ActionM Text successOrError <- validateSignIn conf signInToken @@ -46,37 +49,43 @@ main = do (getIndex conf Nothing) ) `rescue` (\_ -> getIndex conf Nothing) - post "/signOut" signOut - -- SignIn +api :: Conf -> ScottyM () +api conf = do + -- Sign + + post "/api/signIn" $ do + email <- param "email" :: ActionM Text + signIn conf email + + post "/api/signOut" signOut + + -- Users - post "/signIn" $ do - email <- param "email" :: ActionM Text - signIn conf email + get "/api/users" getUsers + get "/api/whoAmI" whoAmI - -- Users + -- Incomes - get "/users" getUsers - get "/whoAmI" whoAmI - get "/incomes" getIncomes - post "/income" $ do - amount <- param "amount" :: ActionM Int - setIncome amount + get "/api/incomes" getIncomes + post "/api/income" $ do + amount <- param "amount" :: ActionM Int + setIncome amount - -- Payments + -- Payments - get "/payments" getPayments + get "/api/payments" getPayments - get "/monthlyPayments" getMonthlyPayments + get "/api/monthlyPayments" getMonthlyPayments - post "/payment/add" $ do - name <- param "name" :: ActionM Text - cost <- param "cost" :: ActionM Text - frequency <- param "frequency" :: ActionM Frequency - createPayment name cost frequency + post "/api/payment/add" $ do + name <- param "name" :: ActionM Text + cost <- param "cost" :: ActionM Text + frequency <- param "frequency" :: ActionM Frequency + createPayment name cost frequency - post "/payment/delete" $ do - paymentId <- param "id" :: ActionM Text - deletePayment paymentId + post "/api/payment/delete" $ do + paymentId <- param "id" :: ActionM Text + deletePayment paymentId - get "/payments/count" getPaymentsCount + get "/api/payments/count" getPaymentsCount -- cgit v1.2.3