Better typing on expiration status view
This commit is contained in:
parent
9679ec91ec
commit
05194664a9
1 changed files with 9 additions and 4 deletions
|
@ -2,6 +2,11 @@ import { Input, Component, Inject } from 'ng-metadata/core';
|
|||
import * as moment from "moment";
|
||||
import './expiration-status-view.component.css';
|
||||
|
||||
type expirationInfo = {
|
||||
className: string;
|
||||
icon: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A component that displays expiration status.
|
||||
*/
|
||||
|
@ -12,12 +17,12 @@ import './expiration-status-view.component.css';
|
|||
export class ExpirationStatusViewComponent {
|
||||
@Input('<') public expirationDate: Date;
|
||||
|
||||
private getExpirationInfo(expirationDate): any {
|
||||
private getExpirationInfo(expirationDate): expirationInfo|null {
|
||||
if (!expirationDate) {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
var expiration = moment(expirationDate);
|
||||
const expiration = moment(expirationDate);
|
||||
if (moment().isAfter(expiration)) {
|
||||
return {'className': 'expired', 'icon': 'fa-warning'};
|
||||
}
|
||||
|
@ -32,4 +37,4 @@ export class ExpirationStatusViewComponent {
|
|||
|
||||
return {'className': 'info', 'icon': 'fa-clock-o'};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue