CSR-1520 | Refactor
Use existing method from querystring-helper Rename response objects
This commit is contained in:
parent
8601f61442
commit
6358818bdc
2 changed files with 7 additions and 12 deletions
|
|
@ -45,11 +45,11 @@ export async function revalidatePromosAndValidateNewPromo(
|
|||
const hasNewPromo = !!newPromo;
|
||||
const addableVaps = getAddableVapsFromAvailableLineItems(pricedLineItems);
|
||||
|
||||
let validatePromoResult = null;
|
||||
let revalidatePromoResult = null;
|
||||
let validatePromoResponse = null;
|
||||
let revalidatePromoResponse = null;
|
||||
|
||||
if (hasActivePromos || hasHasInactivePromos) {
|
||||
revalidatePromoResult = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
revalidatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.REVALIDATE_ORDER_PROMOS_AND_UPDATE_STORE,
|
||||
null,
|
||||
pageNameToLog,
|
||||
|
|
@ -57,7 +57,7 @@ export async function revalidatePromosAndValidateNewPromo(
|
|||
);
|
||||
}
|
||||
if (hasNewPromo) {
|
||||
validatePromoResult = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
validatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
promoCode: newPromo,
|
||||
|
|
@ -68,7 +68,7 @@ export async function revalidatePromosAndValidateNewPromo(
|
|||
);
|
||||
}
|
||||
|
||||
return { validatePromoResult, revalidatePromoResult };
|
||||
return { validatePromoResponse, revalidatePromoResponse };
|
||||
}
|
||||
|
||||
export function getPromosThatMatchLineItemsOnOrder(promos, lineItemsOnOrder) {
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ import { applicationConfig } from "@/constants/application-config";
|
|||
import { payWithInsuranceStates } from "@/constants/pay-with-insurance-states";
|
||||
import { revalidatePromosAndValidateNewPromo } from "@/helpers/promotions-helper";
|
||||
import { queryStrings } from "@/constants/query-strings";
|
||||
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
||||
import { setTransitionHooks } from "vue";
|
||||
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||
|
||||
|
|
@ -150,13 +151,7 @@ export default {
|
|||
);
|
||||
|
||||
// Promo logic
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
const lowerCaseParams = new URLSearchParams();
|
||||
for (const [name, value] of urlParams) {
|
||||
lowerCaseParams.append(name.toLowerCase(), value);
|
||||
}
|
||||
const promoCodeFromQueryString = lowerCaseParams.get(queryStrings.PROMO);
|
||||
const promoCodeFromQueryString = getQuerystringParameter(queryStrings.PROMO);
|
||||
|
||||
const { validatePromoResponse, revalidatePromoResponse } =
|
||||
await revalidatePromosAndValidateNewPromo(
|
||||
|
|
|
|||
Loading…
Reference in a new issue