woocommerce-paypal-payments/modules/ppcp-googlepay/resources/js/Context/ContextHandlerFactory.js
2023-09-21 11:58:51 +01:00

32 lines
1.4 KiB
JavaScript

import SingleProductHandler from "./SingleProductHandler";
import CartHandler from "./CartHandler";
import CheckoutHandler from "./CheckoutHandler";
import CartBlockHandler from "./CartBlockHandler";
import CheckoutBlockHandler from "./CheckoutBlockHandler";
import MiniCartHandler from "./MiniCartHandler";
import PreviewHandler from "./PreviewHandler";
class ContextHandlerFactory {
static create(context, buttonConfig, ppcpConfig, externalActionHandler) {
switch (context) {
case 'product':
return new SingleProductHandler(buttonConfig, ppcpConfig, externalActionHandler);
case 'cart':
return new CartHandler(buttonConfig, ppcpConfig, externalActionHandler);
case 'checkout':
case 'pay-now': // same as checkout
return new CheckoutHandler(buttonConfig, ppcpConfig, externalActionHandler);
case 'mini-cart':
return new MiniCartHandler(buttonConfig, ppcpConfig, externalActionHandler);
case 'cart-block':
return new CartBlockHandler(buttonConfig, ppcpConfig, externalActionHandler);
case 'checkout-block':
return new CheckoutBlockHandler(buttonConfig, ppcpConfig, externalActionHandler);
case 'preview':
return new PreviewHandler(buttonConfig, ppcpConfig, externalActionHandler);
}
}
}
export default ContextHandlerFactory;