@@ -16,7 +16,9 @@ import Effect.Aff.Class (class MonadAff)
16
16
import Effect.Console (log )
17
17
import Halogen as H
18
18
import 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 )
20
22
import Halogen.HTML.Events (onClick , onValueInput )
21
23
import Halogen.Query.HalogenM (HalogenM )
22
24
@@ -29,13 +31,22 @@ import Debug.Trace (spy)
29
31
-- TODO
30
32
fakeCustomerId = " TODO"
31
33
32
- type ApiKey = { hex :: Hex , name :: String }
33
34
type RootId = String -- TODO get from stbx-core
34
35
type TxHash = Hex -- TODO get from stbx-core
35
36
type Hex = String -- TODO get from stbx-core
36
37
37
38
-- ------------------------------------------------------------------------------
38
39
40
+ type ApiKey =
41
+ { name :: String
42
+ , hex :: Hex
43
+ , billingAccount :: Maybe BillingAccount
44
+ }
45
+
46
+ type BillingAccount = Unit -- TODO tentative
47
+
48
+ -- ------------------------------------------------------------------------------
49
+
39
50
-- | projects are collections of root-transactions and are used to manage the public keys associated to those.
40
51
type Project =
41
52
{ name :: String
@@ -223,35 +234,38 @@ render state =
223
234
224
235
navMenuHtml :: ∀ m . MonadAff m => State -> ComponentHTML Action ChildSlots m
225
236
navMenuHtml 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
+ ]
233
246
]
234
247
235
248
contentHtml :: ∀ m . MonadAff m => State -> ComponentHTML Action ChildSlots m
236
249
contentHtml state = case state.route of
237
250
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 ]
249
268
]
250
-
251
- , h3 [] [ text " API keys" ]
252
- , ul [] $ state.apiKeys <#> \key -> li [] [ p [] [ text key.name ]
253
- , p [] [ text key.hex ]
254
- ]
255
269
]
256
270
where
257
271
-- TODO in reality we should have multiple customers
@@ -281,6 +295,7 @@ contentHtml state = case state.route of
281
295
, p [] [ button [ onClick \e -> Just $ CreateApiKey ] [ text " Create new API key" ] ]
282
296
, ul [] $ state.apiKeys <#> \key -> li [] [ p [] [ text key.name ]
283
297
, p [] [ text key.hex ]
298
+ , p [] [ text $ show key.billingAccount ]
284
299
, p [] [ button [ onClick \e -> Just $ DeprecateApiKey key ] [ text " Deprecate" ] ]
285
300
]
286
301
, p [] [ text " * Assign to a root" ]
@@ -296,7 +311,8 @@ contentHtml state = case state.route of
296
311
]
297
312
Account customerId ->
298
313
div []
299
- [ h2 [] [ text " Customer" ]
314
+ [ button [ onClick \e -> Just $ SelectRoute $ Invoices fakeCustomerId ] [ text " Invoices" ]
315
+ , h2 [] [ text " Customer" ]
300
316
, div [] (maybe [] (pure <<< customerHtml) state.customer)
301
317
, h3 [] [ text " Customer's payment methods" ]
302
318
, div [] (state.paymentMethods <#> paymentMethodHtml)
0 commit comments