Skip to content

Commit 022bd9f

Browse files
committed
console: Visually clean up Address rendering. #376
1 parent 20e2cc3 commit 022bd9f

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

console/src/Statebox/Console.purs

+31-31
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,22 @@ invoiceSummaries invoices =
124124

125125
customerHtml :: m. MonadAff m => Stripe.Customer -> ComponentHTML Action ChildSlots m
126126
customerHtml c =
127-
table []
127+
table [] $
128128
[ tr [] [ th [] [ text "name" ]
129129
, td [] [ text $ fold c.name ]
130130
]
131+
, tr [] [ th [] [ text "description" ]
132+
, td [] [ text $ fold c.description ]
133+
]
131134
, tr [] [ th [] [ text "email" ]
132135
, td [] [ text $ fold c.email ]
133136
]
134137
, tr [] [ th [] [ text "phone" ]
135138
, td [] [ text $ fold c.phone ]
136139
]
137-
, tr [] [ th [] [ text "description" ]
138-
, td [] [ text $ fold c.description ]
139-
]
140-
, tr [] [ th [] [ text "address" ]
141-
, td [] [ maybe (text "no address") addressHtml c.address ]
142-
]
143-
, tr [] [ th [] [ text "balance" ]
140+
] <>
141+
foldMap addressRowsHtml c.address <>
142+
[ tr [] [ th [] [ text "balance" ]
144143
, td [] [ text $ c.currency <> " " <> show c.balance <> " cents" ]
145144
]
146145
, tr [] [ th [] [ text "tax ids" ]
@@ -174,7 +173,7 @@ billingDetailsHtml bd = nameAddressPhoneHtml bd
174173

175174
nameAddressPhoneHtml :: r m. MonadAff m => { | Stripe.NameAddressPhoneRow () } -> ComponentHTML Action ChildSlots m
176175
nameAddressPhoneHtml x =
177-
table []
176+
table [] $
178177
[ tr [] [ th [] [ text "name" ]
179178
, td [] [ text $ fold x.name ]
180179
]
@@ -184,30 +183,31 @@ nameAddressPhoneHtml x =
184183
, tr [] [ th [] [ text "phone" ]
185184
, td [] [ text $ fold x.phone ]
186185
]
187-
, tr [] [ th [] [ text "address" ]
188-
, td [] [ maybe (text "no address") addressHtml x.address ]
189-
]
190-
]
186+
] <>
187+
foldMap addressRowsHtml x.address
191188

192189
addressHtml :: m. MonadAff m => Stripe.Address -> ComponentHTML Action ChildSlots m
193-
addressHtml a =
194-
table []
195-
[ tr [] [ th [] [ text "address" ]
196-
, td [] [ text $ fold a.line1, br [], text $ fold a.line2 ]
197-
]
198-
, tr [] [ th [] [ text "city" ]
199-
, td [] [ text $ fold a.city ]
200-
]
201-
, tr [] [ th [] [ text "postal code" ]
202-
, td [] [ text $ fold a.postal_code ]
203-
]
204-
, tr [] [ th [] [ text "state" ]
205-
, td [] [ text $ fold a.state ]
206-
]
207-
, tr [] [ th [] [ text "country" ]
208-
, td [] [ text $ fold a.country ]
209-
]
210-
]
190+
addressHtml a = table [] (addressRowsHtml a)
191+
192+
addressRowsHtml :: m. MonadAff m => Stripe.Address -> Array (ComponentHTML Action ChildSlots m)
193+
addressRowsHtml a =
194+
[ tr [] [ th [] [ text "address" ]
195+
, td [] [ text $ fold a.line1, br [], text $ fold a.line2 ]
196+
]
197+
, tr [] [ th [] [ text "city" ]
198+
, td [] [ text $ fold a.city ]
199+
]
200+
, tr [] [ th [] [ text "postal code" ]
201+
, td [] [ text $ fold a.postal_code ]
202+
]
203+
, tr [] [ th [] [ text "state" ]
204+
, td [] [ text $ fold a.state ]
205+
]
206+
, tr [] [ th [] [ text "country" ]
207+
, td [] [ text $ fold a.country ]
208+
]
209+
]
210+
211211

212212
cardHtml :: m. MonadAff m => Stripe.Card -> ComponentHTML Action ChildSlots m
213213
cardHtml c =

0 commit comments

Comments
 (0)