Last active
September 29, 2021 16:49
-
-
Save dorelljames/123b62fbfdfd3048b4d399b0b557ca0d to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const allProducts = ["Auction! Desktop", "Auction! Cloud", "Auction! Online", "Auction! Mobile", "Auction! Reservations"]; | |
const orderMachine = Machine({ | |
id: 'order', | |
initial: 'idle', | |
context: { | |
cart: [], | |
loggedInuser: { | |
organizations: null, | |
profile: null | |
} | |
}, | |
states: { | |
idle: { | |
on: { | |
LOGIN: 'loggedIn' | |
} | |
}, | |
loggedIn: { | |
on: { | |
IDENTIFY_ORDER_INTENT: 'identifying_intent' | |
} | |
}, | |
identifying_intent: { | |
on: { | |
REQUEST_DEMO_KEY: {}, | |
UPGRADE_AUCTION_DESKTOP_FROM_SINGLE_TO_NETWORK: { | |
}, | |
RENEW_AUCTION_DESKTOP_NO_PRODUCT_SUPPORT: {}, | |
RENEW_PRODUCT_SUPPORT_PREMIUM_SERVICES_AND_PRODUCT_SUPPORT: {}, | |
PURCHASE_NEW_PRODUCT: 'purchasing_products' | |
} | |
}, | |
purchasing_products: { | |
initial: 'selectingProductsToAdd', | |
states: { | |
selectingProductsToAdd: { | |
on: { | |
ADD_AUCTION_DESKTOP_PRODUCT: { | |
actions: assign({ | |
cart: (ctx, event) => [...ctx.cart, "Auction! Desktop"] | |
}), | |
target: "Auction!DesktopProductAdded" | |
}, | |
ADD_AUCTION_CLOUD_PRODUCT: { | |
actions: assign({ | |
cart: (ctx, event) => [...ctx.cart, "Auction! Cloud"] | |
}), | |
target: "Auction!CloudProductAdded" | |
}, | |
ADD_AUCTION_ONLINE_PRODUCT: { | |
actions: assign({ | |
cart: (ctx, event) => [...ctx.cart, "Auction! Online"] | |
}) | |
}, | |
ADD_AUCTION_MOBILE_PRODUCT: { | |
actions: assign({ | |
cart: (ctx, event) => [...ctx.cart, "Auction! Mobile"] | |
}) | |
}, | |
ADD_AUCTION_RESERVATIONS_PRODUCT: { | |
actions: assign({ | |
cart: (ctx, event) => [...ctx.cart, "Auction! Reservations"] | |
}) | |
}, | |
DONE_SELECTING_PRODUCTS_TO_ADD: "#order.entering_orgDetails" }, | |
}, | |
"Auction!DesktopProductAdded": { | |
initial: 'settingOptions', | |
states: { | |
settingOptions: { | |
on: { | |
SELECT_SINGLE_USER: "#order.purchasing_products.selectingProductsToAdd", | |
SELECT_NETWORK: "#order.purchasing_products.selectingProductsToAdd", | |
} | |
}, | |
} | |
}, | |
"Auction!CloudProductAdded": { | |
initial: 'settingOptions', | |
states: { | |
settingOptions: { | |
on: { | |
SELECT_DESKTOP: "settingDuration", | |
SELECT_WITHOUT_DESKTOP: "settingDuration" | |
} | |
}, | |
settingDuration: { | |
on: { | |
SET_6_PERSON_MONTHS: { | |
target: "#order.purchasing_products.selectingProductsToAdd" | |
}, | |
SET_12_PERSON_MONTHS: { | |
target: "#order.purchasing_products.selectingProductsToAdd" | |
}, | |
SET_18_PERSON_MONTHS: { | |
target: "#order.purchasing_products.selectingProductsToAdd" | |
}, | |
} | |
}, | |
}, | |
}, | |
}, | |
}, | |
entering_orgDetails: { | |
on: { | |
UPDATE: "entering_orgDetails", | |
DONE: "entering_purchaserDetails" | |
} | |
}, | |
entering_purchaserDetails: { | |
on: { | |
UPDATE: "entering_purchaserDetails", | |
DONE: "entering_paymentDetails" | |
} | |
}, | |
entering_paymentDetails: { | |
on: { | |
UPDATE: "entering_paymentDetails", | |
DONE: "readyForSubmitting" | |
} | |
}, | |
"readyForSubmitting": { | |
on: { | |
SUBMIT: "creatingOrder" | |
} | |
}, | |
creatingOrder: { | |
on: { | |
SUCCESS: "done", | |
ERROR: "error" | |
} | |
}, | |
done: { | |
type: "final" | |
}, | |
error: { | |
on: { | |
RETRY: "creatingOrder" | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment