import store from "@/store";
import { storeActions } from "@/constants/store-actions";
import { paymentMethods } from "@/constants/payment-method-constants";
import { debugLog } from "@/helpers/debug-log-helper";

export async function paymentBeforeEnter(to, from) {
    const piaType = store.getters.order?.payment?.piaType;
    debugLog(`Entering payment with type =`, piaType);

    if (piaType === paymentMethods.PAYPAL) {
        debugLog(`Changing to payment type =`, paymentMethods.CREDIT_CARD);
        await store.dispatch(storeActions.SAVE_PAYMENT_METHOD_CHOICE, paymentMethods.CREDIT_CARD);
    }
}
