Better typing on expiration status view

This commit is contained in:
Joseph Schorr 2017-07-17 17:28:11 +03:00
parent 9679ec91ec
commit 05194664a9

View file

@ -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'};
}
}
}