Skip to content

Commit 25cec19

Browse files
authored
Merge pull request #6109 from kiva/add-more-loan-status-to-recent-borrowers-carousel-MP-MP-1651
2 parents c0589f9 + a11d106 commit 25cec19

File tree

4 files changed

+85
-11
lines changed

4 files changed

+85
-11
lines changed

.storybook/stories/BorrowerStatusCard.stories.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ import BorrowerStatusCard from '#src/components/MyKiva/BorrowerStatusCard.vue';
22
import { mockLoansArray } from '../utils';
33
import apolloStoryMixin from "../mixins/apollo-story-mixin";
44
import cookieStoreStoryMixin from '../mixins/cookie-store-story-mixin';
5+
import {
6+
PAYING_BACK,
7+
FUNDED,
8+
FUNDRAISING,
9+
RAISED,
10+
EXPIRED,
11+
REFUNDED,
12+
ENDED,
13+
} from '#src/api/fixtures/LoanStatusEnum';
514

615
export default {
716
title: 'MyKiva/BorrowerStatusCard',
@@ -38,4 +47,11 @@ const story = (args = {}) => {
3847
};
3948

4049
export const Default = story({ loan: mockLoans[0] });
41-
export const Repaying = story({ loan: { ...mockLoans[0], status: 'payingBack' } });
50+
export const Repaying = story({ loan: { ...mockLoans[0], status: PAYING_BACK } });
51+
export const Fundraising = story({ loan: { ...mockLoans[0], status: FUNDRAISING } });
52+
export const Funded = story({ loan: { ...mockLoans[0], status: FUNDED } });
53+
export const Raised = story({ loan: { ...mockLoans[0], status: RAISED } });
54+
export const PayingBackDelinquent = story({ loan: { ...mockLoans[0], status: PAYING_BACK, delinquent: true } });
55+
export const Expired = story({ loan: { ...mockLoans[0], status: EXPIRED } });
56+
export const Refunded = story({ loan: { ...mockLoans[0], status: REFUNDED } });
57+
export const Ended = story({ loan: { ...mockLoans[0], status: ENDED } });

src/components/MyKiva/BorrowerCarousel.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ import {
132132
PAYING_BACK,
133133
FUNDED,
134134
FUNDRAISING,
135-
RAISED
135+
RAISED,
136+
EXPIRED,
137+
REFUNDED,
138+
ENDED,
136139
} from '#src/api/fixtures/LoanStatusEnum';
137140
import LoanCommentModal from '#src/pages/Portfolio/ImpactDashboard/LoanCommentModal';
138141
import ShareButton from '#src/components/BorrowerProfile/ShareButton';
@@ -191,8 +194,18 @@ const commentLoanData = ref({
191194
const shareLoan = ref(false);
192195
const previousLastIndex = ref(0);
193196
197+
const VALID_LOAN_STATUS = [
198+
FUNDED,
199+
FUNDRAISING,
200+
PAYING_BACK,
201+
RAISED,
202+
EXPIRED,
203+
REFUNDED,
204+
ENDED,
205+
];
206+
194207
const activeLoans = computed(() => {
195-
return loans.value.filter(l => [FUNDED, FUNDRAISING, PAYING_BACK, RAISED].includes(l?.status));
208+
return loans.value.filter(l => VALID_LOAN_STATUS.includes(l?.status));
196209
});
197210
198211
const hasActiveLoans = computed(() => activeLoans.value.length > 0);
@@ -205,7 +218,7 @@ const title = computed(() => {
205218
});
206219
207220
const filteredLoans = computed(() => {
208-
return loans.value.filter(loan => [FUNDED, FUNDRAISING, PAYING_BACK, RAISED]
221+
return loans.value.filter(loan => VALID_LOAN_STATUS
209222
.includes(loan?.status)).slice(0, props.cardsNumber);
210223
});
211224

src/components/MyKiva/BorrowerStatusCard.vue

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,22 @@
8888
<p
8989
class="tw-text-action tw-font-medium md:tw-text-black
9090
md:tw-w-full md:tw-text-left md:tw-mt-5 md:tw-mb-1"
91+
:class="{
92+
'!tw-text-action': !showWhatIsNextColumn,
93+
}"
9194
>
92-
What's next
95+
{{ stepsCopy }}
9396
</p>
9497
<KvMaterialIcon
98+
v-if="showWhatIsNextColumn"
9599
class="tw-w-3 tw-h-3 tw-text-action md:tw-hidden"
96100
:icon="open ? mdiChevronUp : mdiChevronDown"
97101
/>
98102
</button>
99103
<kv-expandable easing="ease-in-out" class="tw-block md:tw-hidden">
100104
<div v-show="open">
101105
<LoanNextSteps
106+
v-if="showWhatIsNextColumn"
102107
id="loan-next-steps"
103108
:weeks-to-repay="weeksToRepay"
104109
:current-step="currentStep"
@@ -108,6 +113,7 @@
108113
</div>
109114
</kv-expandable>
110115
<LoanNextSteps
116+
v-if="showWhatIsNextColumn"
111117
id="loan-next-steps"
112118
class="tw-hidden md:tw-block"
113119
:weeks-to-repay="weeksToRepay"
@@ -144,6 +150,11 @@ import {
144150
} from 'vue';
145151
import {
146152
FUNDRAISING,
153+
REFUNDED,
154+
EXPIRED,
155+
PAYING_BACK,
156+
ENDED,
157+
FUNDED,
147158
} from '#src/api/fixtures/LoanStatusEnum';
148159
149160
const COMMENT_ID = 'comment';
@@ -203,15 +214,45 @@ const loanUse = computed(() => loan.value?.use ?? '');
203214
204215
const isFundraising = computed(() => loan.value?.status === FUNDRAISING);
205216
217+
const showWhatIsNextColumn = computed(() => {
218+
return !([REFUNDED, EXPIRED, ENDED].includes(loan.value?.status));
219+
});
220+
221+
const stepsCopy = computed(() => {
222+
if (!showWhatIsNextColumn.value) {
223+
return 'Learn what this means';
224+
}
225+
return 'What’s next?';
226+
});
227+
206228
const loanStatus = computed(() => {
207-
if (isFundraising.value) {
208-
return 'Fundraising';
229+
switch (loan.value?.status) {
230+
case FUNDRAISING:
231+
return 'Fundraising';
232+
case FUNDED:
233+
return 'Funded';
234+
case PAYING_BACK:
235+
return 'Repaying';
236+
case REFUNDED:
237+
return 'Refunded';
238+
case EXPIRED:
239+
return 'Expired';
240+
case ENDED:
241+
return 'Ended in default';
242+
default:
243+
return 'Repaid';
209244
}
210-
return 'Repaying';
211245
});
246+
212247
const description = computed(() => {
248+
let loanUsageDescription = isFundraising.value ? 'will use ' : 'used ';
249+
250+
if (showWhatIsNextColumn.value) {
251+
loanUsageDescription = 'asked for a loan to ';
252+
}
253+
213254
return `${borrowerName.value}
214-
${isFundraising.value ? 'will use' : 'used'}
255+
${loanUsageDescription}
215256
${pronoun.value} loan ${loanUse.value}`;
216257
});
217258
const currentStep = computed(() => {
@@ -247,6 +288,10 @@ const toggleWhatIsNext = () => {
247288
if (!open.value) {
248289
$kvTrackEvent('portfolio', 'click', 'What’s next?', borrowerName.value, loan.value.id);
249290
}
291+
if (!showWhatIsNextColumn.value) {
292+
// eslint-disable-next-line max-len
293+
window.location = 'https://help.kiva.org/s/article/What-happens-if-a-loan-doesn-t-fully-fund-on-Kiva-1611075923145';
294+
}
250295
emit('toggle-what-is-next', !open.value);
251296
};
252297

src/components/Thanks/LoanNextSteps.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ export default {
5959
steps: [
6060
{ text: 'Your contribution is received ' },
6161
{ text: 'Their loan is funded' },
62-
{ text: 'They use the money to improve their life' },
62+
{ text: 'They used the money to improve their life' },
6363
// eslint-disable-next-line max-len
64-
{ text: `${this.repaymentsStarted ? 'Their next repayment is coming in' : 'They start repaying you in'} <span class="tw-text-action"> ${this.weeksToRepay} </span>` }
64+
{ text: `${this.repaymentsStarted ? `Their next repayment is coming in <span class="tw-text-action"> ${this.weeksToRepay} </span>` : 'They completed their repayments'}` }
6565
]
6666
};
6767
},

0 commit comments

Comments
 (0)