Skip to content

Instantly share code, notes, and snippets.

@s9gf4ult
Created January 30, 2017 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s9gf4ult/3c39756d4b41bc91a246c3ac31ab45cf to your computer and use it in GitHub Desktop.
Save s9gf4ult/3c39756d4b41bc91a246c3ac31ab45cf to your computer and use it in GitHub Desktop.
renderCreditCard :: DispatchCreditCard -> CreditCardForm -> ReactRender ()
renderCreditCard dispatch ccf = div_ $ do
let
tf :: Text -> (Text -> CreditCardAction) -> Fold CreditCardForm Text -> ReactRender ()
tf hint action l = textField_ $ TextField
{ _tfValue = fromMaybe "" $ ccf ^? l
, _tfHint = Just hint
, _tfType = TFTText
, _tfOnChange = Just $ dispatch . action
}
div_ $ do
tf "Credit card number" CCANumber ccfNumber
tf "Owner name" CCAOwnver ccfOwnver
div_ $ do
tf "Month" CCAMonth $ ccfMonth . _Just . to show'
elemText "/"
tf "Year" CCAYear $ ccfYear . _Just . to show'
div_ $ do
tf "CVV" CCACvv $ ccfCVV . _Just . to show'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment