mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
32 lines
1.4 KiB
JavaScript
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;
|