Skip to content

Commit

Permalink
update function name; update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
vpchung committed Oct 12, 2023
1 parent dffe710 commit bb24df3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<main *ngIf="challenge">
<div id="bio">
<h3 class="top-section-title">Overview</h3>
<p>{{ use_default(challenge.description) }}</p>
<p>{{ useNaIfEmpty(challenge.description) }}</p>
<div *ngIf="challenge.description.endsWith('...')">
<a class="read-more" href="{{ challenge.websiteUrl }}"
>Continue reading <mat-icon aria-hidden="true" inline="true">open_in_new</mat-icon></a
Expand All @@ -15,13 +15,13 @@ <h3 class="section-title">Challenge Details</h3>
<tr>
<td class="text-right">Start Date</td>
<td [ngClass]="{ 'text-grey': challenge.startDate === null }">
{{ use_default(challenge.startDate) }}
{{ useNaIfEmpty(challenge.startDate) }}
</td>
</tr>
<tr>
<td class="text-right">End Date</td>
<td [ngClass]="{ 'text-grey': challenge.endDate === null }">
{{ use_default(challenge.endDate) }}
{{ useNaIfEmpty(challenge.endDate) }}
</td>
</tr>
<tr>
Expand All @@ -31,7 +31,7 @@ <h3 class="section-title">Challenge Details</h3>
<tr>
<td class="text-right">Platform</td>
<td [ngClass]="{ 'text-grey': challenge.platform.name === '' }">
{{ use_default(challenge.platform.name) }}
{{ useNaIfEmpty(challenge.platform.name) }}
</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class ChallengeOverviewComponent {
organizationCards: OrganizationCard[] = MOCK_ORGANIZATION_CARDS;
// mockTopics = ['breast', 'cancer'];

use_default(str: string | null | undefined) {
return str === '' || str == null ? 'Not available' : str;
useNaIfEmpty(str: string | null | undefined) {
return str ?? 'Not available';
}

prettify(camel: string | undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="bio" class="row">
<div class="col">
<h3>Overview</h3>
<p>{{ use_default(org.description) }}</p>
<p>{{ useNaIfEmpty(org.description) }}</p>
<div *ngIf="org.description.endsWith('...')">
<a class="read-more" href="{{ org.websiteUrl }}"
>Continue reading <mat-icon aria-hidden="true" inline="true">open_in_new</mat-icon></a>
Expand All @@ -15,11 +15,11 @@ <h3 class="section-title">Organization Details</h3>
<tbody>
<tr>
<td class="text-right">Acronym</td>
<td [ngClass]="{ 'text-grey': org.acronym === '' }">{{ use_default(org.acronym) }}</td>
<td [ngClass]="{ 'text-grey': org.acronym === '' }">{{ useNaIfEmpty(org.acronym) }}</td>
</tr>
<tr>
<td class="text-right">Contact Email</td>
<td [ngClass]="{ 'text-grey': org.email === '' }">{{ use_default(org.email) }}</td>
<td [ngClass]="{ 'text-grey': org.email === '' }">{{ useNaIfEmpty(org.email) }}</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class OrgProfileOverviewComponent {
@Input({ required: true }) organization!: Organization;
organizationCards: OrganizationCard[] = MOCK_ORGANIZATION_CARDS;

use_default(str: string | undefined) {
return str === '' ? 'Not available' : str;
useNaIfEmpty(str: string | undefined) {
return str || 'Not available';
}
}

0 comments on commit bb24df3

Please sign in to comment.