Skip to content

Commit

Permalink
feat: 5 dollars pre select added to loan card components
Browse files Browse the repository at this point in the history
  • Loading branch information
roger-in-kiva committed Jul 26, 2023
1 parent d54d59b commit ffd6a08
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions @kiva/kv-components/utils/loanUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function getLendCtaSelectedOption(
campaign,
unreservedAmount,
userBalance,
fiveDollarsSelected,
) {
// Don't enable the campaign changes when the user balance is undefined (user not logged in)
if (enableFiveDollarsNotes && typeof userBalance !== 'undefined') {
Expand Down Expand Up @@ -78,6 +79,10 @@ export function getLendCtaSelectedOption(
}
}

if (enableFiveDollarsNotes && fiveDollarsSelected) {
return '5';
}

// Handle when $5 notes isn't enabled
if (isBetween25And50(unreservedAmount) || isLessThan25(unreservedAmount)) {
return Number(unreservedAmount).toFixed();
Expand Down
5 changes: 5 additions & 0 deletions @kiva/kv-components/vue/KvClassicLoanCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
:is-loading="isLoading"
:is-adding="isAdding"
:enable-five-dollars-notes="enableFiveDollarsNotes"
:five-dollars-selected="fiveDollarsSelected"
:kv-track-function="kvTrackFunction"
:show-view-loan="showViewLoan"
:custom-loan-details="customLoanDetails"
Expand Down Expand Up @@ -324,6 +325,10 @@ export default {
type: Function,
default: undefined,
},
fiveDollarsSelected: {
type: Boolean,
default: false,
},
},
data() {
return {
Expand Down
6 changes: 6 additions & 0 deletions @kiva/kv-components/vue/KvLendCta.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ export default {
type: Function,
default: undefined,
},
fiveDollarsSelected: {
type: Boolean,
default: false,
},
},
data() {
return {
Expand All @@ -206,6 +210,7 @@ export default {
this.route?.query?.utm_campaign,
this.loan?.unreservedAmount,
this.userBalance,
this.fiveDollarsSelected,
),
};
},
Expand Down Expand Up @@ -344,6 +349,7 @@ export default {
this.route?.query?.utm_campaign,
newValue,
this.userBalance,
this.fiveDollarsSelected,
);
}
},
Expand Down
10 changes: 10 additions & 0 deletions @kiva/kv-components/vue/stories/KvClassicLoanCard.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const story = (args) => {
:show-tags="showTags"
:category-page-name="categoryPageName"
:enable-five-dollars-notes="enableFiveDollarsNotes"
:five-dollars-selected="fiveDollarsSelected"
:large-card="largeCard"
:is-adding="isAdding"
:is-visitor="isVisitor"
Expand Down Expand Up @@ -206,6 +207,15 @@ export const FiveDollarNotes = story({
photoPath,
});

export const FiveDollarsSelected = story({
loanId: loan.id,
loan,
enableFiveDollarsNotes: true,
fiveDollarsSelected: true,
kvTrackFunction,
photoPath,
});

export const ViewLoan = story({
loanId: loan.id,
loan,
Expand Down
12 changes: 12 additions & 0 deletions @kiva/kv-components/vue/stories/KvLendCta.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const story = (args) => {
:is-loading="isLoading"
:is-adding="isAdding"
:enable-five-dollars-notes="enableFiveDollarsNotes"
:five-dollars-selected="fiveDollarsSelected"
:kv-track-function="kvTrackFunction"
:show-view-loan="showViewLoan"
:custom-loan-details="customLoanDetails"
Expand Down Expand Up @@ -77,6 +78,17 @@ export const FiveDollar = story({
kvTrackFunction,
});

export const FiveDollarsSelected = story({
isLoading: false,
loan: {
id: 1,
unreservedAmount: '150.00',
},
enableFiveDollarsNotes: true,
fiveDollarsSelected: true,
kvTrackFunction,
});

export const LessThan25 = story({
isLoading: false,
loan: {
Expand Down

0 comments on commit ffd6a08

Please sign in to comment.