Skip to content

Commit

Permalink
feat: relending test code removed (#5042)
Browse files Browse the repository at this point in the history
* feat: relending test code removed

* fix: banner cookie check reverted
  • Loading branch information
roger-in-kiva authored Oct 20, 2023
1 parent 9b441ce commit 0627c07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 190 deletions.
68 changes: 0 additions & 68 deletions src/components/LoanCards/Buttons/MultipleAtcButton.vue

This file was deleted.

77 changes: 0 additions & 77 deletions src/components/LoanFinding/LendingCategorySection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,10 @@
<p
v-if="subtitle"
class="tw-text-subhead tw-text-primary"
:class="{ 'tw-hidden lg:tw-block' : enableRelendingExp }"
>
{{ subtitle }}
</p>
</div>
<multiple-atc-button
v-if="enableRelendingExp"
:amount="multipleAmount"
:loans-number="totalLoans"
:is-adding="isAddingMultiple"
:show-checkout="hasMultipleBeenAdded"
@add-multiple="addMultipleLoans"
@checkout="checkout"
/>
</div>
<kv-carousel
class="tw-w-full tw-overflow-hidden tw-mt-1 tw-pb-2 tw-px-1 tw-pt-1"
Expand All @@ -37,7 +27,6 @@
<template v-for="(loan, index) in loans" #[`slide${index}`]>
<kv-classic-loan-card-container
:key="loanCardKey(index)"
:ref="loanCardKey(index)"
:loan-id="loan.id"
:use-full-width="true"
:show-tags="true"
Expand All @@ -62,7 +51,6 @@
<script>
import _throttle from 'lodash/throttle';
import KvClassicLoanCardContainer from '@/components/LoanCards/KvClassicLoanCardContainer';
import MultipleAtcButton from '@/components/LoanCards/Buttons/MultipleAtcButton';
import KvCarousel from '~/@kiva/kv-components/vue/KvCarousel';
import ViewMoreCard from './ViewMoreCard';
Expand All @@ -71,7 +59,6 @@ export default {
components: {
KvCarousel,
KvClassicLoanCardContainer,
MultipleAtcButton,
ViewMoreCard,
},
props: {
Expand Down Expand Up @@ -130,8 +117,6 @@ export default {
},
data() {
return {
isAddingMultiple: false,
hasMultipleBeenAdded: false,
windowWidth: typeof window !== 'undefined' ? window.innerWidth : 1024,
handleResize: _throttle(this.isWindowWidth, 200)
};
Expand All @@ -155,24 +140,6 @@ export default {
}
return '336px';
},
multipleAmount() {
let amount = 0;
for (let index = 0; index < this.totalLoans; index += 1) {
const loan = this.loans[index];
const { unreservedAmount } = loan;
if (this.enableFiveDollarsNotes) {
if (this.userBalance > 20) {
amount += unreservedAmount > 25 ? 25 : Number(unreservedAmount);
} else {
amount += unreservedAmount > 5 ? 5 : Number(unreservedAmount);
}
} else {
amount += unreservedAmount > 25 ? 25 : Number(unreservedAmount);
}
}
return amount;
},
totalLoans() {
return this.loans.length;
},
Expand All @@ -184,50 +151,6 @@ export default {
addToBasket(payload) {
this.$emit('add-to-basket', payload);
},
async addMultipleLoans() {
this.isAddingMultiple = true;
const { multipleAmount } = this;
for (let index = 0; index < this.totalLoans; index += 1) {
const { unreservedAmount } = this.loans[index];
const key = this.loanCardKey(index);
let amount = '';
if (this.enableFiveDollarsNotes && this.userBalance <= 20) {
amount = Number(unreservedAmount) > 5 ? '5' : unreservedAmount;
} else {
amount = Number(unreservedAmount) > 25 ? '25' : unreservedAmount;
}
// We occasionally get fully funded loans from dev FLSS
if (Number(amount) > 0) {
try {
// Ensure the reservations happen synchronously to prevent race conditions with the basket
// eslint-disable-next-line no-await-in-loop
await this.$refs[key][0].addToBasket(amount);
} catch {
// no-op
}
}
}
this.$kvTrackEvent(
'loan-card',
'add-all-to-basket',
'relending-lending-home-add-all',
this.userBalance,
multipleAmount
);
this.isAddingMultiple = false;
this.hasMultipleBeenAdded = true;
},
checkout() {
this.$kvTrackEvent('loan-card', 'checkout', 'relending-lending-home-add-all');
this.$router.push({ path: '/checkout' });
},
loanCardKey(index) {
return `loan-card-${index}`;
},
Expand Down
54 changes: 9 additions & 45 deletions src/pages/LoanFinding/LoanFinding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
:subtitle="firstRowSubtitle"
:loans="firstRowLoans"
:enable-five-dollars-notes="enableFiveDollarsNotes"
:enable-relending-exp="enableRelendingExp"
:user-balance="userBalance"
:per-step="perStepRecommendedRow"
@add-to-basket="trackCategory($event, 'recommended')"
:class="{
'tw-pt-3 tw-pb-4 tw-bg-secondary' : enableRelendingExp,
'tw-pt-3' : !isLoggedIn,
}"
:class="{ 'tw-pt-3' : !isLoggedIn }"
/>

<!-- Almost Funded loans row -->
Expand All @@ -35,7 +31,6 @@
:subtitle="almostFundedRowSubtitle"
:loans="almostFundedLoans"
:enable-five-dollars-notes="enableFiveDollarsNotes"
:enable-relending-exp="enableRelendingExp"
:user-balance="userBalance"
@add-to-basket="trackCategory($event, 'almost-funded')"
class="tw-pt-3 tw-mb-2"
Expand All @@ -49,7 +44,6 @@
:subtitle="fiveDollarsRowSubtitle"
:loans="fiveDollarsRowLoans"
:enable-five-dollars-notes="enableFiveDollarsNotes"
:enable-relending-exp="enableRelendingExp"
:user-balance="userBalance"
:five-dollars-selected="true"
:title-icon="HandOrangeIcon"
Expand All @@ -60,7 +54,6 @@
<div class="tw-flex tw-flex-col">
<quick-filters-section
class="tw-mt-3"
:class="{ 'tw-order-last' : enableRelendingExp }"
:enable-five-dollars-notes="enableFiveDollarsNotes"
:enable-qf-mobile="enableQFMobileVersion"
:enable-almost-funded-row="enableAlmostFundedRow"
Expand All @@ -78,7 +71,6 @@
:subtitle="secondCategorySubtitle"
:loans="secondCategoryLoans"
class="tw-py-3"
:class="{ 'tw-order-first' : enableRelendingExp }"
:enable-five-dollars-notes="enableFiveDollarsNotes"
:user-balance="userBalance"
@add-to-basket="trackCategory($event, 'matched-lending')"
Expand Down Expand Up @@ -157,7 +149,6 @@ export default {
spotlightLoans: [],
spotlightIndex: 0,
spotlightViewportObserver: null,
enableRelendingExp: false,
userBalance: undefined,
showFiveDollarsBanner: false,
enableThreeLoansRecommended: false,
Expand Down Expand Up @@ -198,7 +189,6 @@ export default {
return balance;
},
secondCategoryTitle() {
if (this.enableRelendingExp) return '<span class="tw-text-action">Recycle your balance</span> and get these borrowers funded '; // eslint-disable-line max-len
if (this.matchedLoansTotal > 0) {
if (this.matchedLoansTotal < 3) return 'Help these borrowers cross the finish line';
return 'Matched lending';
Expand All @@ -216,13 +206,11 @@ export default {
return spotlightData[this.spotlightIndex] ?? {};
},
firstRowTitle() {
if (this.enableRelendingExp) return `${this.firstName}, let's put your <span class="tw-text-action">$${this.userBalanceString}</span> to good use`; // eslint-disable-line max-len
return this.isLoggedIn
? 'Recommended for you'
: 'Make a difference <span class="tw-text-action">today</span>';
},
firstRowSubtitle() {
if (this.enableRelendingExp) return 'Loans we think you\'ll love based on your lending history';
return this.isLoggedIn
? 'Loans handpicked for you based on your lending history'
: 'Support a featured borrower with a microloan.';
Expand All @@ -234,7 +222,7 @@ export default {
return 'Lend as little as $5 to fund a new dream.';
},
showWelcomeMsg() {
return this.isLoggedIn && !this.enableRelendingExp && !this.showFiveDollarsBanner;
return this.isLoggedIn && !this.showFiveDollarsBanner;
},
perStepRecommendedRow() {
return !this.enableThreeLoansRecommended ? 2 : 3;
Expand Down Expand Up @@ -380,15 +368,12 @@ export default {
this.trackDisplayedLoans('recommended', 1, this.firstRowLoans);
},
trackQuickFiltersDisplayedLoans({ data, pageOffset }) {
this.trackDisplayedLoans('quick-filters', this.enableRelendingExp ? 3 : 2, data, pageOffset);
this.trackDisplayedLoans('quick-filters', 2, data, pageOffset);
},
trackSecondCarouselDisplayedLoans() {
this.trackDisplayedLoans(
// eslint-disable-next-line no-nested-ternary
this.enableRelendingExp
? 'recycle'
: (this.matchedLoansTotal < 3 ? 'ending-soon-almost-funded' : 'matched'),
this.enableRelendingExp ? 2 : 3,
this.matchedLoansTotal < 3 ? 'ending-soon-almost-funded' : 'matched',
3,
this.secondCategoryLoans,
);
},
Expand Down Expand Up @@ -458,40 +443,19 @@ export default {
);
this.enableAlmostFundedRow = almostFundedRowTestData.version === 'b';
const recommendedArray = [
this.firstRowLoans = [
...cachedRecommendedLoans,
{ id: 0 }, { id: 0 },
{ id: 0 }, { id: 0 },
{ id: 0 }, { id: 0 },
{ id: 0 }, { id: 0 },
];
let relendingArray = [
...cachedRecommendedLoans,
];
/* eslint-disable max-len */
if (this.enableFiveDollarsNotes) {
if ((this.userBalance > 0 && this.userBalance < 10) || (this.userBalance > 20 && this.userBalance < 50)) relendingArray = relendingArray.slice(0, 2);
if ((this.userBalance > 10 && this.userBalance < 15) || (this.userBalance > 50 && this.userBalance < 75)) relendingArray = relendingArray.slice(0, 3);
// check for $5 notes banner cookie
this.check5DollarsBannerCookie();
} else {
if (this.userBalance > 0 && this.userBalance < 50) relendingArray = relendingArray.slice(0, 2);
if (this.userBalance > 50 && this.userBalance < 75) relendingArray = relendingArray.slice(0, 3);
}
/* eslint-enable max-len */
this.firstRowLoans = this.enableRelendingExp ? relendingArray : recommendedArray;
// check for $5 notes banner cookie
if (this.enableFiveDollarsNotes) this.check5DollarsBannerCookie();
},
mounted() {
if (!this.enableRelendingExp) {
this.getRecommendedLoans();
} else {
this.trackFirstRowDisplayedLoans();
}
this.getRecommendedLoans();
this.getSecondCategoryData();
this.verifySpotlightIndex();
Expand Down

0 comments on commit 0627c07

Please sign in to comment.