-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Bedon
committed
Jan 8, 2024
1 parent
a6ad481
commit 48c919b
Showing
6 changed files
with
91 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { parseISO, differenceInDays } from 'date-fns'; | ||
|
||
export default { | ||
props: { | ||
goal: { | ||
type: Object, | ||
required: true, | ||
default: () => ({}), | ||
}, | ||
}, | ||
computed: { | ||
challengeEndDate() { | ||
return this.goal?.endDate ?? null; | ||
}, | ||
loansFunded() { | ||
const loans = this.goal?.targets?.values ?? []; | ||
// filter out loans where status is not complete | ||
const completedLoans = loans.filter( | ||
loan => loan.status === 'COMPLETE' | ||
); | ||
return completedLoans.length ?? 0; | ||
}, | ||
totalLoans() { | ||
return this.goal?.targets?.totalCount ?? 0; | ||
}, | ||
percentageFunded() { | ||
return Math.round((this.loansFunded / this.totalLoans) * 100); | ||
}, | ||
// calculate days remaining between now and the challengeEndDate using the the datefns library | ||
daysRemaining() { | ||
// Get planned expiration time as Date | ||
const plannedExpirationDate = parseISO(this.challengeEndDate); | ||
const diffInDays = differenceInDays( | ||
plannedExpirationDate, | ||
new Date() | ||
); | ||
return diffInDays; | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters