@@ -16,7 +16,9 @@ import Effect.Aff.Class (class MonadAff)
1616import Effect.Console (log )
1717import Halogen as H
1818import Halogen (ComponentHTML )
19- import Halogen.HTML (HTML , p , text , br , span , div , ul , li , h2 , h3 , table , tr , th , td , button )
19+ import Halogen.HTML (HTML , a , p , text , br , span , div , ul , li , h2 , h3 , h4 , nav , table , tr , th , td , button )
20+ import Halogen.HTML.Core (ClassName (..))
21+ import Halogen.HTML.Properties (classes )
2022import Halogen.HTML.Events (onClick , onValueInput )
2123import Halogen.Query.HalogenM (HalogenM )
2224
@@ -29,13 +31,22 @@ import Debug.Trace (spy)
2931-- TODO
3032fakeCustomerId = " TODO"
3133
32- type ApiKey = { hex :: Hex , name :: String }
3334type RootId = String -- TODO get from stbx-core
3435type TxHash = Hex -- TODO get from stbx-core
3536type Hex = String -- TODO get from stbx-core
3637
3738-- ------------------------------------------------------------------------------
3839
40+ type ApiKey =
41+ { name :: String
42+ , hex :: Hex
43+ , billingAccount :: Maybe BillingAccount
44+ }
45+
46+ type BillingAccount = Unit -- TODO tentative
47+
48+ -- ------------------------------------------------------------------------------
49+
3950-- | projects are collections of root-transactions and are used to manage the public keys associated to those.
4051type Project =
4152 { name :: String
@@ -223,35 +234,38 @@ render state =
223234
224235navMenuHtml :: ∀ m . MonadAff m => State -> ComponentHTML Action ChildSlots m
225236navMenuHtml state =
226- div []
227- [ button [ onClick \e -> Just $ SelectRoute $ Home ] [ text " Home" ]
228- , button [ onClick \e -> Just $ SelectRoute $ Projects ] [ text " Projects" ]
229- , button [ onClick \e -> Just $ SelectRoute $ APIKeys ] [ text " API Keys" ]
230- , button [ onClick \e -> Just $ SelectRoute $ Invoices fakeCustomerId ] [ text " Invoices" ]
231- , button [ onClick \e -> Just $ SelectRoute $ Subscription ] [ text " Subscriptions" ]
232- , button [ onClick \e -> Just $ SelectRoute $ Plan ] [ text " Plans" ]
237+ nav [ classes [ ClassName " stbx-menu" ] ]
238+ [ ul []
239+ [ text " Statebox Cloud Admin Console"
240+ , a [ onClick \e -> Just $ SelectRoute $ Home ] [ text " Home" ]
241+ , a [ onClick \e -> Just $ SelectRoute $ Projects ] [ text " Projects" ]
242+ , a [ onClick \e -> Just $ SelectRoute $ APIKeys ] [ text " API Keys" ]
243+ , a [ onClick \e -> Just $ SelectRoute $ Subscription ] [ text " Subscriptions" ]
244+ , a [ onClick \e -> Just $ SelectRoute $ Plan ] [ text " Plans" ]
245+ ]
233246 ]
234247
235248contentHtml :: ∀ m . MonadAff m => State -> ComponentHTML Action ChildSlots m
236249contentHtml state = case state.route of
237250 Home ->
238- div []
239- [ h2 [] [ text " Statebox Cloud Admin Console" ]
240-
241- , h3 [] [ text " Projects" ]
242- , ul [] $ Map .toUnfoldable state.projects <#> (\(projectId /\ project) ->
243- li [] [ button [ onClick \e -> Just $ SelectRoute $ ProjectR projectId ] [ text project.name ] ])
244-
245- , h3 [] [ text " Billing accounts" ]
246- , ul [] $ customers <#> \customer ->
247- li [] [ button [ onClick \e -> Just $ SelectRoute $ Account customer.id ] [ text $ fold customer.name ]
248- , text $ fold customer.description
251+ div [ classes [ ClassName " container" , ClassName " is-flex" , ClassName " has-rows" ] ]
252+ [ h4 [] [ text " Projects" ]
253+ , ul [ classes [ ClassName " stbx-cards" ] ] $ Map .toUnfoldable state.projects <#> \(projectId /\ project) ->
254+ li [ onClick \e -> Just $ SelectRoute $ ProjectR projectId ]
255+ [ h3 [] [ text project.name ] ]
256+
257+ , h4 [] [ text " Billing accounts" ]
258+ , ul [ classes [ ClassName " stbx-cards" ] ] $ customers <#> \customer ->
259+ li [ onClick \e -> Just $ SelectRoute $ Account customer.id ]
260+ [ h3 [] [ text $ fold customer.name ]
261+ , p [] [ text $ fold customer.description ]
262+ ]
263+
264+ , h4 [] [ text " API keys" ]
265+ , ul [ classes [ ClassName " stbx-cards" ] ] $ state.apiKeys <#> \key ->
266+ li [] [ h3 [] [ text key.name ]
267+ , p [] [ text key.hex ]
249268 ]
250-
251- , h3 [] [ text " API keys" ]
252- , ul [] $ state.apiKeys <#> \key -> li [] [ p [] [ text key.name ]
253- , p [] [ text key.hex ]
254- ]
255269 ]
256270 where
257271 -- TODO in reality we should have multiple customers
@@ -281,6 +295,7 @@ contentHtml state = case state.route of
281295 , p [] [ button [ onClick \e -> Just $ CreateApiKey ] [ text " Create new API key" ] ]
282296 , ul [] $ state.apiKeys <#> \key -> li [] [ p [] [ text key.name ]
283297 , p [] [ text key.hex ]
298+ , p [] [ text $ show key.billingAccount ]
284299 , p [] [ button [ onClick \e -> Just $ DeprecateApiKey key ] [ text " Deprecate" ] ]
285300 ]
286301 , p [] [ text " * Assign to a root" ]
@@ -296,7 +311,8 @@ contentHtml state = case state.route of
296311 ]
297312 Account customerId ->
298313 div []
299- [ h2 [] [ text " Customer" ]
314+ [ button [ onClick \e -> Just $ SelectRoute $ Invoices fakeCustomerId ] [ text " Invoices" ]
315+ , h2 [] [ text " Customer" ]
300316 , div [] (maybe [] (pure <<< customerHtml) state.customer)
301317 , h3 [] [ text " Customer's payment methods" ]
302318 , div [] (state.paymentMethods <#> paymentMethodHtml)
0 commit comments