From 95c7cd77b4a2cde86ff4cba27a520e39be46fabb Mon Sep 17 00:00:00 2001 From: Christian Bedon Date: Wed, 20 Dec 2023 15:21:11 -0500 Subject: [PATCH 1/2] feat: redirect lender that has lent to the borrower to its legacy page when it is no longer in fundraising state --- src/pages/BorrowerProfile/BorrowerProfile.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pages/BorrowerProfile/BorrowerProfile.vue b/src/pages/BorrowerProfile/BorrowerProfile.vue index abe31d6058..8c42b05f87 100644 --- a/src/pages/BorrowerProfile/BorrowerProfile.vue +++ b/src/pages/BorrowerProfile/BorrowerProfile.vue @@ -233,6 +233,9 @@ const preFetchQuery = gql` id name } + userProperties { + lentTo + } } } community @include(if: $getInviter) { @@ -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 = data?.lend?.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; From ca91dafe1266580bfedeb791f47b8e8b6cc1d94c Mon Sep 17 00:00:00 2001 From: Christian Bedon Date: Wed, 20 Dec 2023 15:38:20 -0500 Subject: [PATCH 2/2] refactor: use loan declaration for lentTo variable --- src/pages/BorrowerProfile/BorrowerProfile.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/BorrowerProfile/BorrowerProfile.vue b/src/pages/BorrowerProfile/BorrowerProfile.vue index 8c42b05f87..aba9c978ea 100644 --- a/src/pages/BorrowerProfile/BorrowerProfile.vue +++ b/src/pages/BorrowerProfile/BorrowerProfile.vue @@ -463,7 +463,7 @@ export default { const loanStatusAllowed = ALLOWED_LOAN_STATUSES.indexOf(loan?.status) !== -1; let redirectToLendClasic = loan === null || loan === 'undefined' || !loanStatusAllowed; // Evaluate if lender should be redirected to lend classic MARS-358 - const lentTo = data?.lend?.loan?.userProperties?.lentTo ?? false; + const lentTo = loan?.userProperties?.lentTo ?? false; if (lentTo && !redirectToLendClasic) { const loanAmount = loan?.loanAmount ?? '0'; const fundedAmount = loan?.loanFundraisingInfo?.fundedAmount ?? '0';