Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 26 additions & 36 deletions src/components/WwwFrame/Header/KvAtbModalContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ const props = defineProps({
type: Object,
default: () => ({}),
},
isNextStepsExpEnabled: {
type: Boolean,
default: false
},
goalsV2Enabled: {
type: Boolean,
default: false
},
});

const { addedLoan } = toRefs(props);
Expand Down Expand Up @@ -186,36 +178,34 @@ const newAchievementReached = () => {
const fetchPostCheckoutAchievements = async loanIds => {
const { id: addedLoanId, basketSize } = addedLoan.value;
let showAtbGoalMsg = false;
if (props.isNextStepsExpEnabled) {
await loadGoalData({
loans: loansInBasket.value,
yearlyProgress: props.goalsV2Enabled,
});
// Use yearly progress with current year when Goals V2 is enabled, otherwise use all-time progress
const year = props.goalsV2Enabled ? new Date().getFullYear() : null;
// Increment counter per add-to-basket action
const { totalProgress } = await getPostCheckoutProgressByLoans({
loans: loanIds.map(id => ({ id })),
year,
increment: true,
});
loanGoalProgress.value = totalProgress;
const userTarget = userGoal.value?.target || 0;
const isOneLoanAwayFromGoal = userTarget - totalProgress === 1;
const goalAchieved = loanGoalProgress.value === userTarget;
showAtbGoalMsg = isLoanGoal.value && (basketSize < BASKET_LIMIT_SIZE_FOR_EXP
await loadGoalData({
loans: loansInBasket.value,
yearlyProgress: true,
});
// Use yearly progress with current year
const year = new Date().getFullYear();
// Increment counter per add-to-basket action
const { totalProgress } = await getPostCheckoutProgressByLoans({
loans: loanIds.map(id => ({ id })),
year,
increment: true,
});
loanGoalProgress.value = totalProgress;
const userTarget = userGoal.value?.target || 0;
const isOneLoanAwayFromGoal = userTarget - totalProgress === 1;
const goalAchieved = loanGoalProgress.value === userTarget;
showAtbGoalMsg = isLoanGoal.value && (basketSize < BASKET_LIMIT_SIZE_FOR_EXP
|| isOneLoanAwayFromGoal || goalAchieved);
if (showAtbGoalMsg) {
if (isOneLoanAwayFromGoal) {
const loanUrl = getLoanFindingUrl(userGoal.value?.category, router.currentRoute.value);
oneLoanAwayFilteredUrl.value = !loanUrl ? router.currentRoute.value.path : loanUrl;
oneLoanAwayCategory.value = CATEGORY_TARGETS[userGoal.value?.category];
oneAwayText.value = `${userTarget - 1} of ${userTarget}`;
}
showModalContent.value = true;
modalVisible.value = true;
return;
if (showAtbGoalMsg) {
if (isOneLoanAwayFromGoal) {
const loanUrl = getLoanFindingUrl(userGoal.value?.category, router.currentRoute.value);
oneLoanAwayFilteredUrl.value = !loanUrl ? router.currentRoute.value.path : loanUrl;
oneLoanAwayCategory.value = CATEGORY_TARGETS[userGoal.value?.category];
oneAwayText.value = `${userTarget - 1} of ${userTarget}`;
}
showModalContent.value = true;
modalVisible.value = true;
return;
}

// If added loan is not related to user goal, proceed with achievements logic.
Expand Down
2 changes: 0 additions & 2 deletions src/pages/MyKiva/MyKivaPageContent.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<template>
<KvAtbModalContainer
:added-loan="addedLoan"
:is-next-steps-exp-enabled="isNextStepsExpEnabled"
:goals-v2-enabled="goalsV2Enabled"
/>
<MyKivaNavigation
:visible="showNavigation"
Expand Down
Loading