@futureordering/fo-web-plugin-types
v3.0.0
Published
Types related to Plugins and Statistics shared between FO.Web and FO.Web.Plugins
Downloads
155
Keywords
Readme
Future Ordering frontend plugin types
TypeScript typings for frontend extensibility plugins for the Future Ordering frontend.
Installation
npm i @futureordering/fo-web-plugin-types
Examples
See https://github.com/Future-Ordering/frontend-plugin-boilerplate for usage example
Version 3
Version 3 changes:
- Adds basic order support for working with orders, menus and products. Some of the new addons include:
- Create order (
ctx.order.createOrder
) - Add item to basket (
orderContext.addItem
, orderContext can for example be retrieved usingctx.order.getCurrentOrder
andctx.order.createOrder
) - Get order items (
(await orderContext.getOrderData()).orderItems
) - Remove item from order (
orderContext.removeItem
) - Set order class (
orderContext.setOrderClass
) - Get menu (
ctx.menu.getMenu
) - Get product (
menuContext.getProduct
, menuContext can for example be retrieved usingctx.menu.getMenu
or(await ctx.order.getCurrentOrder()).menu
) - Iterate products (
menuContext.products
) - Selecting config item (
menuContext.setItem
)
- Create order (
- Starting order from plugin by navigating to select store and order type, and then back to plugin (
ctx.location.navigateToStartOrderAndBack
) - Navigate to page (
ctx.location.navigateToPage
, currently only supported to navigate to productConfig page) - Removes
ctx.location.navigateToPageComponent
overload - Changes
ctx.location.navigate
argument menuType to orderClass
Migrating from version 2 to 3
ctx.location.navigateToPageComponent
Change
ctx.location.navigateToPageComponent('myPlugin', {}, { addReturnUrl: true });
To
ctx.location.navigateToPageComponent({
pageName: 'myPlugin',
queryParams: {},
addReturnUrl: truer
})
ctx.location.navigate
Change
ctx.location.navigate({
menuType: 'takeaway',
...
})
To
ctx.location.navigate({
orderClass: 'takeaway',
...
})
ctx.page.setButton
Available in page components. Removed because overriding the back button behavior goes against user expectations and the way the app works in general.