export function updateCartActionBase(params) {
    const {
        response,
        repaintData,
        context,
        charity,
        initial,
        updateOrderSummaryFn,
        getEqualMapFn,
        repaintOrderItemsFn,
        addCharityEntryNumberFn,
        updatePromotionFn,
        addPotentialPromoFn,
        cartEntries,
        getCartEntriesFn,
        checkProductArraysFn,
        removeOrderItemFn,
        elOrderItem,
        updateKlarnaPlacementsFn,
        updateClearpayPlacementsFn,
        updateClearpayVisibilityFn,
        addClassToSummaryAsideFn,
        updateBasketSessionFn,
        drawEnergyLabelsFn,
        triggerCartUpdate = true,
        extraActions = () => {},
        extraActionsMiniBasket = () => {},
    } = params;
    if (initial) {
        getCartEntriesFn(response);
    } else {
        updateOrderSummaryFn && updateOrderSummaryFn(response, getEqualMapFn(response));
        if (repaintData) {
            if (repaintData.isChangeDelivery) {
                repaintData.cartEntry = cartEntries.filter(
                    (entry) => entry.entryNumber === repaintData.cartEntryNumber
                )[0];
                $(document).trigger('EEUpdateDeliveryMode', repaintData);
            }
            checkProductArraysFn(response)
                ? repaintOrderItemsFn(response, repaintData)
                : (() => {
                      $(elOrderItem).remove();
                      removeOrderItemFn && removeOrderItemFn(repaintData);
                  })();
        }
        charity && addCharityEntryNumberFn && addCharityEntryNumberFn(response);
        context && context.length && updatePromotionFn && updatePromotionFn(response, context);
        addPotentialPromoFn && addPotentialPromoFn(response);
        updateKlarnaPlacementsFn &&
            updateKlarnaPlacementsFn(
                response.totalPrice.formattedPriceWithoutCurrencySymbol,
                response.paymentInfos.klarnaPaymentInfo.customPaymentMethodIds
            );
        updateClearpayPlacementsFn && updateClearpayPlacementsFn(response.totalPrice.value);
        updateClearpayVisibilityFn && updateClearpayVisibilityFn(response.totalPrice.value);
        addClassToSummaryAsideFn && addClassToSummaryAsideFn(response);
        getCartEntriesFn && getCartEntriesFn(response);
        updateBasketSessionFn && updateBasketSessionFn();
        drawEnergyLabelsFn && drawEnergyLabelsFn();
        triggerCartUpdate && $(document).trigger('cartUpdate');
        extraActions && extraActions(response, repaintData, context, charity, initial);
        extraActionsMiniBasket && extraActionsMiniBasket();
    }
}
