2024-07-12 12:58:34 +02:00
|
|
|
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 PayNowHandler from './PayNowHandler';
|
|
|
|
import PreviewHandler from './PreviewHandler';
|
2023-08-28 17:19:07 +01:00
|
|
|
|
|
|
|
class ContextHandlerFactory {
|
2024-07-12 12:58:34 +02:00
|
|
|
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':
|
|
|
|
return new CheckoutHandler(
|
|
|
|
buttonConfig,
|
|
|
|
ppcpConfig,
|
|
|
|
externalActionHandler
|
|
|
|
);
|
|
|
|
case 'pay-now':
|
|
|
|
return new PayNowHandler(
|
|
|
|
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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-08-28 17:19:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ContextHandlerFactory;
|