Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new loan card added for empty basket state in checkout page #4939

Merged
merged 2 commits into from
Aug 17, 2023
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
2 changes: 2 additions & 0 deletions src/components/LoanCards/KvClassicLoanCardContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ export default {
this.basketItems = result.data?.shop?.basket?.items?.values || null;
},
addToBasket(lendAmount) {
// emitting updating tools for empty state in checkout page
this.$emit('updating-totals', true);
this.isAdding = true;
return setLendAmount({
amount: lendAmount,
Expand Down
174 changes: 0 additions & 174 deletions src/components/LoansYouMightLike/MinimalLoanCard.vue

This file was deleted.

67 changes: 50 additions & 17 deletions src/components/RandomLoanSelector/RandomLoanSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
tw-border-t
tw-border-tertiary
"
style="min-height: 23rem;"
>
<div v-if="randomLoans.length" class="section-container tw-mx-auto tw-my-0">
<kv-carousel
Expand All @@ -22,18 +21,19 @@
ref="randomLoansCarousel"
:multiple-slides-visible="true"
slides-to-scroll="visible"
:slide-max-width="carouselCardWidth"
:slide-max-width="singleSlideWidth"
@interact-carousel="onInteractCarousel"
>
<template v-for="(loan, index) in randomLoans" #[`slide${index}`]>
<minimal-loan-card
:key="index"
:class="`minimal-loancard-${index}`"
:loan="loan"
category-set-id="random-loans"
:card-number="index"
@refreshtotals="$emit('refreshtotals')"
<kv-classic-loan-card-container
:key="`loan-card-${index}`"
:loan-id="loan.id"
:use-full-width="true"
:show-tags="true"
:enable-five-dollars-notes="enableFiveDollarsNotes"
@updating-totals="$emit('updating-totals', $event)"
dyersituations marked this conversation as resolved.
Show resolved Hide resolved
dyersituations marked this conversation as resolved.
Show resolved Hide resolved
@add-to-basket="addToBasket(index)"
class="tw-h-full"
/>
</template>
</kv-carousel>
Expand All @@ -43,36 +43,54 @@
</template>

<script>
import MinimalLoanCard from '@/components/LoansYouMightLike/MinimalLoanCard';
import _throttle from 'lodash/throttle';
import KvClassicLoanCardContainer from '@/components/LoanCards/KvClassicLoanCardContainer';
import emptyBasketData from '@/graphql/query/checkout/emptyBasketData.graphql';
import KvCarousel from '~/@kiva/kv-components/vue/KvCarousel';

export default {
name: 'RandomLoanSelector',
components: {
KvCarousel,
MinimalLoanCard,
KvClassicLoanCardContainer
},
props: {
loans: {
type: Array,
default: () => [],
}
},
enableFiveDollarsNotes: {
type: Boolean,
default: false
},
},
data() {
return {
carouselCardWidth: '240px',
randomLoans: [],
loading: false,
scrollPos: 0,
windowWidth: 0,
wrapperWidth: 0,
windowWidth: typeof window !== 'undefined' ? window.innerWidth : 1024,
handleResize: _throttle(this.isWindowWidth, 200)
};
},
inject: ['apollo'],
mounted() {
// we're doing this all client side
this.loadLoans();
computed: {
singleSlideWidth() {
if (this.windowWidth <= 733) {
return '100%';
}
if (this.windowWidth > 733 && this.windowWidth < 1024) {
return '328px';
}
if (this.windowWidth >= 1024) {
if (this.isLargeCard) {
return '512px';
}
return '328px';
}
return '336px';
},
},
methods: {
loadLoans() {
Expand All @@ -87,6 +105,21 @@ export default {
onInteractCarousel(interaction) {
this.$kvTrackEvent('carousel', 'click-carousel-horizontal-scroll', interaction);
},
addToBasket(index) {
this.$kvTrackEvent('basket', 'basket-loan-upsell', 'loan-type', index, index);
this.$emit('refreshtotals');
},
isWindowWidth() {
this.windowWidth = window.innerWidth;
}
},
mounted() {
window.addEventListener('resize', this.handleResize);
// we're doing this all client side
this.loadLoans();
},
beforeDestroy() {
window.removeEventListener('resize', this.handleResize);
}
};
</script>
1 change: 1 addition & 0 deletions src/pages/Checkout/CheckoutPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
style="min-height: 23rem;"
>
<random-loan-selector
:enable-five-dollars-notes="enableFiveDollarsNotes"
@updating-totals="setUpdatingTotals"
@refreshtotals="refreshTotals"
/>
Expand Down
Loading