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 hasNewPromo = !!newPromo;
|
||||||
const addableVaps = getAddableVapsFromAvailableLineItems(pricedLineItems);
|
const addableVaps = getAddableVapsFromAvailableLineItems(pricedLineItems);
|
||||||
|
|
||||||
let validatePromoResult = null;
|
let validatePromoResponse = null;
|
||||||
let revalidatePromoResult = null;
|
let revalidatePromoResponse = null;
|
||||||
|
|
||||||
if (hasActivePromos || hasHasInactivePromos) {
|
if (hasActivePromos || hasHasInactivePromos) {
|
||||||
revalidatePromoResult = await baseMixin.methods.dispatchStoreActionWithLogging(
|
revalidatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.REVALIDATE_ORDER_PROMOS_AND_UPDATE_STORE,
|
storeActions.REVALIDATE_ORDER_PROMOS_AND_UPDATE_STORE,
|
||||||
null,
|
null,
|
||||||
pageNameToLog,
|
pageNameToLog,
|
||||||
|
|
@ -57,7 +57,7 @@ export async function revalidatePromosAndValidateNewPromo(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (hasNewPromo) {
|
if (hasNewPromo) {
|
||||||
validatePromoResult = await baseMixin.methods.dispatchStoreActionWithLogging(
|
validatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
||||||
{
|
{
|
||||||
promoCode: newPromo,
|
promoCode: newPromo,
|
||||||
|
|
@ -68,7 +68,7 @@ export async function revalidatePromosAndValidateNewPromo(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { validatePromoResult, revalidatePromoResult };
|
return { validatePromoResponse, revalidatePromoResponse };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPromosThatMatchLineItemsOnOrder(promos, lineItemsOnOrder) {
|
export function getPromosThatMatchLineItemsOnOrder(promos, lineItemsOnOrder) {
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ import { applicationConfig } from "@/constants/application-config";
|
||||||
import { payWithInsuranceStates } from "@/constants/pay-with-insurance-states";
|
import { payWithInsuranceStates } from "@/constants/pay-with-insurance-states";
|
||||||
import { revalidatePromosAndValidateNewPromo } from "@/helpers/promotions-helper";
|
import { revalidatePromosAndValidateNewPromo } from "@/helpers/promotions-helper";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
|
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
||||||
import { setTransitionHooks } from "vue";
|
import { setTransitionHooks } from "vue";
|
||||||
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||||
|
|
||||||
|
|
@ -150,13 +151,7 @@ export default {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Promo logic
|
// Promo logic
|
||||||
const queryString = window.location.search;
|
const promoCodeFromQueryString = getQuerystringParameter(queryStrings.PROMO);
|
||||||
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 { validatePromoResponse, revalidatePromoResponse } =
|
const { validatePromoResponse, revalidatePromoResponse } =
|
||||||
await revalidatePromosAndValidateNewPromo(
|
await revalidatePromosAndValidateNewPromo(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue