Factor out billing create component.
[?]
Feb 3, 2021, 2:23 AM
T2DN23M7W53UMRV46SKDP6UDMCZB7VG2J772LXKMAJNL6NA62MKACDependencies
- [2]
27H4DECZAdd billing create API call. - [3]
WRPIYG3EUse project listing functionality to check for whether we have a cookie. - [4]
SAESJLLYInitial experiments in hash routing. - [5]
QMEYU4MWAdd display for prior intervals. - [6]
NAFJ6RB3Minor module reorg. - [7]
PPW6ROC5Render project data - [8]
ANDJ6GEYAdd billing component skeleton. - [9]
O2BZOX7MAdd signup form, captcha check. - [10]
VTZT2ILUWire up billing navigation. - [11]
NJNMO72SAdd zcash.com submodule and update client to modern halogen. - [*]
EA5BFM5GSplit Login component into its own module.
Change contents
- replacement in client/spago.dhall at line 2[3.294970]→[3.294970:295116](∅→∅),[3.295116]→[3.2:20](∅→∅),[3.20]→[3.157:173](∅→∅),[3.295116]→[3.157:173](∅→∅),[3.173]→[3.376:389](∅→∅),[3.295116]→[3.376:389](∅→∅),[3.389]→[3.128:147](∅→∅),[3.147]→[3.389:405](∅→∅),[3.389]→[3.389:405](∅→∅),[3.405]→[3.2:17](∅→∅),[3.17]→[3.293:336](∅→∅),[3.17]→[3.295116:295122](∅→∅),[3.336]→[3.295116:295122](∅→∅),[3.405]→[3.295116:295122](∅→∅),[3.295116]→[3.295116:295122](∅→∅)
, dependencies =[ "console", "effect", "halogen", "psci-support", "affjax", "halogen-css", "argonaut-codecs", "rationals", "routing", "uuid", "validation", "js-date", "format", "formatters", "fixed-precision"], dependencies =[ "affjax", "argonaut-codecs", "console", "effect", "fixed-precision", "format", "formatters", "halogen", "halogen-css", "halogen-formless", "js-date", "psci-support", "rationals", "routing", "uuid", "validation"] - replacement in client/src/Aftok/Api/Billing.purs at line 22
-- import Data.Time.Duration (Hours(..), Days(..))import Data.Time.Duration (Hours(..), Days(..)) - replacement in client/src/Aftok/Api/Billing.purs at line 80
, gracePeriod :: Duration, expiryPeriod :: Duration, gracePeriod :: Hours, expiryPeriod :: Hours - edit in client/src/Aftok/Api/Types.purs at line 18[3.6328]
newtype Stored i t = Stored{ dbid :: i, value :: t} - file addition: Billing[13.1]
- file addition: Create.purs[0.454]
module Aftok.Billing.Create whereimport Preludeimport Control.Monad.Trans.Class (lift)-- import Data.DateTime (DateTime, date)import Data.Either (Either(..))import Data.Foldable (all)import Data.Maybe (Maybe(..))-- import Data.Unfoldable as Uimport Data.Time.Duration (Hours(..))import Data.Traversable (traverse)import Data.Tuple (Tuple)import Effect.Aff (Aff)-- import Effect.Class (liftEffect)-- import Effect.Now (nowDateTime)import Halogen as Himport Halogen.HTML.Core (ClassName(..))import Halogen.HTML as HHimport Halogen.HTML.Events as Eimport Halogen.HTML.Properties as Pimport Aftok.ProjectList as ProjectListimport Aftok.Types (System, ProjectId)import Aftok.Api.Types (APIError(..))import Aftok.Api.Project (Project)import Aftok.Api.Billing( BillableId, Billable, PaymentRequestId, PaymentRequest, createBillable, listProjectBillables, listUnpaidPaymentRequests)data RType= RTAnnual| RTMonthly| RTWeekly| RTOneTimetype CState ={ projectId :: ProjectId, name :: Maybe String, description :: Maybe String, message :: Maybe String, recurrenceType :: Maybe RType, recurrenceValue :: Maybe Int, amount :: Maybe Number, gracePeriod :: Maybe Hours, requestExpiry :: Maybe Hours}data Query a= Tell atype Input = ProjectIdtype Output = Tuple BillableId Billabledata Action= ProjectChanged ProjectId| SetName String| SetDesc String| SetMessage String| SetRecurrenceType RType| SetRecurrenceDuration Number| SetBillingAmount Numbertype Slot id= H.Slot Query Output idtype Capability (m :: Type -> Type)= { createBillable :: ProjectId -> Billable -> m (Either APIError BillableId)}component ::forall m.Monad m =>System m ->Capability m ->H.Component HH.HTML Query Input Output mcomponent system caps =H.mkComponent{ initialState, render, eval:H.mkEval$ H.defaultEval{ handleAction = eval, receive = Just <<< ProjectChanged}}whereinitialState :: Input -> CStateinitialState input ={ projectId: input, name : Nothing, description : Nothing, message : Nothing, recurrenceType : Nothing, recurrenceValue : Nothing, amount : Nothing, gracePeriod : Nothing, requestExpiry : Nothing}render :: forall slots. CState -> H.ComponentHTML Action slots mrender st =HH.div[ P.classes (ClassName <$> ["card-body"]) ][ HH.form_[HH.div[ P.classes (ClassName <$> ["form-group"]) ][ HH.label [ P.for "billableName" ] [ HH.text "Bill Name:" ], HH.input[ P.type_ P.InputText, P.classes (ClassName <$> [ "form-control" ]), P.id_ "billableName", P.placeholder "A name for the product or service you want to bill for", P.required true, P.autofocus true, E.onValueInput (Just <<< SetName)], HH.label [ P.for "billableDesc" ] [ HH.text "Bill Description:" ], HH.input[ P.type_ P.InputText, P.classes (ClassName <$> [ "form-control" ]), P.id_ "billableDesc", P.placeholder "Description of the product or service", P.required true, P.autofocus true, E.onValueInput (Just <<< SetDesc)]]]]eval :: forall slots. Action -> H.HalogenM CState Action slots Output m Uniteval = case _ ofProjectChanged pid ->H.modify_ (_ { projectId = pid })SetName name -> pure unitSetDesc desc -> pure unitSetMessage msg -> pure unitSetRecurrenceType rtype -> pure unitSetRecurrenceDuration dur -> pure unitSetBillingAmount amt -> pure unit - edit in client/src/Aftok/Billing.purs at line 12
import Data.Time.Duration (Hours(..)) - edit in client/src/Aftok/Billing.purs at line 21
import Halogen.HTML.Events as E - edit in client/src/Aftok/Billing.purs at line 23
import Aftok.Billing.Create as Create - edit in client/src/Aftok/Billing.purs at line 51
| BillableCreated (Tuple BillableId Billable) - edit in client/src/Aftok/Billing.purs at line 58
, createBillable :: Create.Slot Unit - edit in client/src/Aftok/Billing.purs at line 62
_createBillable = SProxy :: SProxy "createBillable" - replacement in client/src/Aftok/Billing.purs at line 65
= { createBillable :: ProjectId -> Billable -> m (Either APIError BillableId)= { createBillable :: Create.Capability m - edit in client/src/Aftok/Billing.purs at line 70
- replacement in client/src/Aftok/Billing.purs at line 120
[ billingDetail st ]case st.selectedProject ofJust p ->[ HH.slot_createBillableunit(Create.component system caps.createBillable)(unwrap p).projectId(Just <<< BillableCreated)]Nothing -> [] - edit in client/src/Aftok/Billing.purs at line 135
billingDetail :: BillingState -> H.ComponentHTML BillingAction Slots mbillingDetail st = doHH.div [] [] - edit in client/src/Aftok/Billing.purs at line 152
BillableCreated _ ->pure unit - replacement in client/src/Aftok/Billing.purs at line 157
{ createBillable: createBillable{ createBillable: { createBillable: createBillable } - replacement in client/src/Aftok/Billing.purs at line 164
{ createBillable: \_ _ -> pure $ Left Forbidden{ createBillable: { createBillable: \_ _ -> pure $ Left Forbidden } - edit in client/src/Aftok/Billing.purs at line 168