Skip to content

Instantly share code, notes, and snippets.

@lifedraft
Last active May 6, 2021 15:12
Show Gist options
  • Save lifedraft/170db66083bea16dc77cdb0408aa394f to your computer and use it in GitHub Desktop.
Save lifedraft/170db66083bea16dc77cdb0408aa394f to your computer and use it in GitHub Desktop.
Shipping
Shipping
FetchDeliveryAddressService*
# context:
# addresses: (filtered for tenant)
# isFilterd: if addresses filtered
# deliveryAddress (prefill: cart billingAddress + deliveryDate => scalar Date)
# selection: uuid | new delivery address | useBillingAsShipping
# billingAddressApplicable: true
done -> Guard
Guard
withoutAddresses -> WithoutAddresses
withAddresses -> WithAddresses
WithoutAddresses
Idle*
# selection: sameAsBilling
sameAsBilling -> UpdateDeliveryService
# deliveryAddress = deliveryAddress
# selection: deliveryAddress
submit -> UpdateDeliveryService
UpdateDeliveryService
# => arguments:
# selection: uuid | new delivery address | useBillingAsShipping;
# addressUUID: uuid;
# deliveryAddress: (CartAddress + deliveryDate)
# => formValidation!!!
# * different validators per tenant
# => set delivery address for shipping required deliveries
# * fetch shippingOptions
# * if shippingOptions == 1 => updateShippingOptions
# * if shippingOptions > 1 => return muation with shippingOptions
# => error on unavailable uuid.
# => setPayment with in the mutation
done -> DoneGuard
# Context
# shippingOptions!
fail -> Idle
WithAddresses
IdleWithAddress*
# selection: sameAsBilling
sameAsBilling -> UpdateDeliveryServiceWithAddress
# addressUUID = uuid
# selection: uuid
selectAddress -> UpdateDeliveryServiceWithAddress
# deliveryAddress = deliveryAddress
# selection: deliveryAddress
updateDeliveryAddres -> UpdateDeliveryServiceWithAddress
UpdateDeliveryServiceWithAddress
done -> DoneGuard
# context: -> shippingOptions
fail -> IdleWithAddress
DoneGuard
hasShippingOptions -> ShippingOptions
noShippingOptions -> Success
ShippingOptions
submit -> UpdateShippingOptions
edit -> FetchDeliveryAddressService
UpdateShippingOptions
done -> SetPayment
fail -> ShippingOptions
SetPayment
done -> Success
Success
function render(model){
let current_state_name = model.active_states[0].name;
return $("h1",
{style: {color: "darkBlue"}},
`The current state is: ${current_state_name}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment