Skip to content

Commit

Permalink
Merge pull request #5108 from kiva/redirect-not-fundraising-borrower-…
Browse files Browse the repository at this point in the history
…profiles-to-lend-classic-MARS-358

feat: redirect lender that has lent to the borrower to its legacy pag…
  • Loading branch information
christian14b authored Dec 20, 2023
2 parents 7e40826 + ca91daf commit 40cacde
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/pages/BorrowerProfile/BorrowerProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ const preFetchQuery = gql`
id
name
}
userProperties {
lentTo
}
}
}
community @include(if: $getInviter) {
Expand Down Expand Up @@ -458,7 +461,19 @@ export default {
// Check for loan and loan status
const loan = data?.lend?.loan;
const loanStatusAllowed = ALLOWED_LOAN_STATUSES.indexOf(loan?.status) !== -1;
if (loan === null || loan === 'undefined' || !loanStatusAllowed) {
let redirectToLendClasic = loan === null || loan === 'undefined' || !loanStatusAllowed;
// Evaluate if lender should be redirected to lend classic MARS-358
const lentTo = loan?.userProperties?.lentTo ?? false;
if (lentTo && !redirectToLendClasic) {
const loanAmount = loan?.loanAmount ?? '0';
const fundedAmount = loan?.loanFundraisingInfo?.fundedAmount ?? '0';
const amountLeft = Number(loanAmount) - Number(fundedAmount);
const loanStatus = loan?.status !== 'fundraising';
redirectToLendClasic = !amountLeft && loanStatus;
}
if (redirectToLendClasic) {
// redirect to legacy borrower profile
const { query = {} } = route;
query.minimal = false;
Expand Down

0 comments on commit 40cacde

Please sign in to comment.