Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(openchallenges): challenge card fixes #2315

Merged
merged 5 commits into from
Nov 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add try-catch
vpchung committed Nov 3, 2023
commit 918c04af7ac7f736142e834dd66b0c7a538553d0
Original file line number Diff line number Diff line change
@@ -57,17 +57,23 @@ export class ChallengeCardComponent implements OnInit {
: this.imageService.getImage({
objectKey: 'banner-default.svg',
});
if (this.challenge.endDate && this.status === 'completed') {
const timeSince = this.calcTimeDiff(this.challenge.endDate, true);
if (timeSince) {
this.time_info = `Ended ${timeSince} ago`;
try {
if (this.challenge.endDate && this.status === 'completed') {
const timeSince = this.calcTimeDiff(this.challenge.endDate, true);
if (timeSince) {
this.time_info = `Ended ${timeSince} ago`;
}
} else if (this.challenge.endDate && this.status === 'active') {
this.time_info = `Ends in ${this.calcTimeDiff(
this.challenge.endDate
)}`;
} else if (this.challenge.startDate && this.status === 'upcoming') {
this.time_info = `Starts in ${this.calcTimeDiff(
this.challenge.startDate
)}`;
}
} else if (this.challenge.endDate && this.status === 'active') {
this.time_info = `Ends in ${this.calcTimeDiff(this.challenge.endDate)}`;
} else if (this.challenge.startDate && this.status === 'upcoming') {
this.time_info = `Starts in ${this.calcTimeDiff(
this.challenge.startDate
)}`;
} catch (e: unknown) {
console.log(e);
}
}
}