import { getQuerystringParameter } from "@/helpers/querystring-helper";
import { queryStrings } from "@/constants/query-strings";
import store from "@/store";
import { storeMutations } from "@/constants/store-mutations";
import { updateOrCreateFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";

export async function consumeReferralQuerystrings() {
    const referralNumber = getQuerystringParameter(queryStrings.REFERRAL_NUMBER);
    const parentAccount = getQuerystringParameter(queryStrings.PARENT_ACCOUNT);
    const correlationId = getQuerystringParameter(queryStrings.CORRELATION_ID);
    if (referralNumber) {
        store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
        store.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, parentAccount);
        store.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, correlationId);
        // log(" --update cookie");
        updateOrCreateFunnelCookie();
    }
}
