Skip to content

Commit

Permalink
feat: toggle what is next for all cards and fix number of loans in ca…
Browse files Browse the repository at this point in the history
…rousel to match tabs
  • Loading branch information
Christian Bedon committed Nov 18, 2024
1 parent bec5f1a commit 89e7ab0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/components/MyKiva/BorrowerCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@
:embla-options="{ loop: false, align: 'center'}"
@change="onInteractCarousel"
>
<template v-for="(loan, index) in loans" #[`slide${index+1}`] :key="loan.id || index">
<BorrowerStatusCard :loan="loan" class="tw-h-full" />
<template v-for="(loan, index) in filteredLoans" #[`slide${index+1}`] :key="loan.id || index">
<BorrowerStatusCard
:loan="loan" class="tw-h-full"
@toggle-what-is-next="openWhatIsNext = $event"
:open-what-is-next="openWhatIsNext"
/>
</template>
</KvCarousel>
</div>
Expand Down Expand Up @@ -156,6 +160,7 @@ const { loans, totalLoans } = toRefs(props);
const carousel = ref(null);
const tabs = ref(null);
const windowWidth = ref(0);
const openWhatIsNext = ref(false);
const hasActiveLoans = computed(() => {
return loans.value.some(loan => [FUNDED, FUNDRAISING, PAYING_BACK, RAISED].includes(loan?.status));
Expand Down
16 changes: 13 additions & 3 deletions src/components/MyKiva/BorrowerStatusCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import {
toRefs,
defineProps,
inject,
watch,
} from 'vue';
import {
FUNDRAISING,
Expand All @@ -111,10 +112,15 @@ const props = defineProps({
type: Object,
required: true,
},
openWhatIsNext: {
type: Boolean,
required: false,
}
});
const { loan } = toRefs(props);
const open = ref(false);
const { loan, openWhatIsNext } = toRefs(props);
const open = ref(openWhatIsNext.value);
const emit = defineEmits(['toggle-what-is-next']);
const borrowerName = computed(() => loan.value?.name ?? '');
const borrowerCountry = computed(() => loan.value?.geocode?.country?.name ?? '');
Expand Down Expand Up @@ -221,8 +227,12 @@ const toggleWhatIsNext = () => {
if (!open.value) {
$kvTrackEvent('portfolio', 'click', 'what-is-next', borrowerName.value, loan.value.id);
}
open.value = !open.value;
emit('toggle-what-is-next', !open.value);
};
watch(() => openWhatIsNext.value, () => {
open.value = openWhatIsNext.value;
});
</script>
<style lang="postcss" scoped>
Expand Down

0 comments on commit 89e7ab0

Please sign in to comment.