RUAQYIXI4G3RUD4L7536QFGFUFPWFAW7U4PTLFEDIW7FXNLRAMFAC
import Aftok.Api.Billing (BillableId, Billable, Recurrence(..), createBillable)
import Aftok.Api.Types (APIError(..))
import Aftok.HTML.Classes as C
import Aftok.Modals as Modals
import Aftok.Modals.ModalFFI as ModalFFI
import Aftok.Types (System, ProjectId)
import Aftok.Zcash (ZEC(..), toZatoshi)
import Aftok.Types (System, ProjectId)
import Aftok.HTML.Classes as C
import Aftok.Modals as Modals
import Aftok.Modals.ModalFFI as ModalFFI
import Aftok.Api.Types (APIError(..))
import Aftok.Api.Billing
( BillableId
, Billable
, Recurrence(..)
, createBillable
)
import Aftok.Zcash (ZEC(..), toZatoshi)
[ HH.label_
[ HH.input
([ P.type_ P.InputRadio
, P.name "recurType"
, E.onClick \_ -> Just (SetRecurrenceType RTAnnual)
] <> (if st.recurrenceType == RTAnnual then [P.checked true] else []))
, HH.text " Annual"
]
, HH.label_
[ HH.input
([ P.type_ P.InputRadio
, P.name "recurType"
, E.onClick \_ -> Just (SetRecurrenceType RTMonthly)
] <> (if st.recurrenceType == RTMonthly then [P.checked true] else []))
, HH.text " every "
[ formCheckGroup
{ id: "recurAnnual"
, checked: (st.recurrenceType == RTAnnual)
, labelClasses: []
}
(\_ -> Just (SetRecurrenceType RTAnnual))
[ HH.text "Annual" ]
, formCheckGroup
{ id: "recurMonthly"
, checked: (st.recurrenceType == RTMonthly)
, labelClasses: [C.formInline]
}
(\_ -> Just (SetRecurrenceType RTMonthly))
[ HH.text "Every"
, HH.input
[ P.type_ P.InputNumber
, P.classes [ C.formControl, C.formControlXs, C.formControlFlush, C.marginX2 ]
, P.value (if st.recurrenceType == RTMonthly
then maybe "" show st.recurrenceValue
else "")
, P.min 1.0
, P.max 12.0
, E.onValueInput (Just <<< SetRecurrenceMonths)
]
, HH.text "Months"]
, formCheckGroup
{ id: "recurWeekly"
, checked: (st.recurrenceType == RTWeekly)
, labelClasses: [C.formInline]
}
(\_ -> Just (SetRecurrenceType RTWeekly))
[ HH.text "Every"
, P.classes [ C.formControlSm ]
, P.value (if st.recurrenceType == RTMonthly
then maybe "" show st.recurrenceValue
else "")
, P.min 1.0
, P.max 12.0
, E.onValueInput (Just <<< SetRecurrenceMonths)
]
, HH.text " Months"
]
, HH.label_
[ HH.input
([ P.type_ P.InputRadio
, P.name "recurType"
, E.onClick \_ -> Just (SetRecurrenceType RTWeekly)
] <> (if st.recurrenceType == RTWeekly then [P.checked true] else []))
, HH.text " every "
, HH.input
[ P.type_ P.InputNumber
, P.classes [ C.formControlSm ]
, P.classes [ C.formControl, C.formControlXs, C.formControlFlush, C.marginX2 ]
]
, HH.text " Weeks"
]
, HH.label_
[ HH.input
([ P.type_ P.InputRadio
, P.name "recurType"
, E.onClick \_ -> Just (SetRecurrenceType RTOneTime)
] <> (if st.recurrenceType == RTOneTime then [P.checked true] else []))
, HH.text " One-Time"
]
, HH.text "Weeks"
[ HH.text "Amount" ]
, HH.input
[ P.type_ P.InputNumber
, P.classes [ C.formControlSm ]
, P.id_ "billableAmount"
, P.value (maybe "" (Fixed.toString <<< unwrap) st.amount)
, P.placeholder "1.0"
, P.min 0.0
, E.onValueInput (Just <<< SetBillingAmount)
]
[ HH.text "Amount" ]
[ P.classes [ ClassName "input-group-append" ] ]
[ HH.span [ P.classes [ ClassName "input-group-text" ] ] [ HH.text "ZEC" ] ]
[ P.classes [ ClassName "input-group", ClassName "input-group-sm" ] ]
[ HH.input
[ P.type_ P.InputNumber
, P.classes [ C.formControl ]
, P.id_ "billableAmount"
, P.value (maybe "" (Fixed.toString <<< unwrap) st.amount)
, P.placeholder "1.0"
, P.min 0.0
, E.onValueInput (Just <<< SetBillingAmount)
]
, HH.div
[ P.classes [ ClassName "input-group-append"] ]
[ HH.span
[ P.classes [ ClassName "input-group-text" ]
, P.style "height: auto;" -- fix bad calculated height from LandKit
]
[ HH.text "ZEC" ] ]
]
formCheckGroup :: forall i a.
{ id :: String
, checked :: Boolean
, labelClasses :: Array ClassName
}
-> (Unit -> Maybe a)
-> Array (HH.HTML i a)
-> HH.HTML i a
formCheckGroup { id, checked, labelClasses } onChange children =
HH.div
[ P.classes [C.formCheck] ]
[ HH.input
([ P.type_ P.InputRadio
, P.name "recurType"
, P.classes [C.formCheckInput]
, P.id_ id
, E.onClick \_ -> onChange unit
] <> (if checked then [P.checked true] else []))
, HH.label
[ P.classes ([C.formCheckLabel ] <> labelClasses)
, P.for id]
children
]
formControlXs :: ClassName
formControlXs = ClassName "form-control-xs"
formControlFlush :: ClassName
formControlFlush = ClassName "form-control-flush"
formCheck :: ClassName
formCheck = ClassName "form-check"
formCheckLabel :: ClassName
formCheckLabel = ClassName "form-check-label"
formCheckInput :: ClassName
formCheckInput = ClassName "form-check-input"
-- Sizing
marginX2 :: ClassName
marginX2 = ClassName "mx-2"