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 * as moment from "moment";
import './expiration-status-view.component.css'; import './expiration-status-view.component.css';
type expirationInfo = {
className: string;
icon: string;
};
/** /**
* A component that displays expiration status. * A component that displays expiration status.
*/ */
@ -12,12 +17,12 @@ import './expiration-status-view.component.css';
export class ExpirationStatusViewComponent { export class ExpirationStatusViewComponent {
@Input('<') public expirationDate: Date; @Input('<') public expirationDate: Date;
private getExpirationInfo(expirationDate): any { private getExpirationInfo(expirationDate): expirationInfo|null {
if (!expirationDate) { if (!expirationDate) {
return ''; return null;
} }
var expiration = moment(expirationDate); const expiration = moment(expirationDate);
if (moment().isAfter(expiration)) { if (moment().isAfter(expiration)) {
return {'className': 'expired', 'icon': 'fa-warning'}; return {'className': 'expired', 'icon': 'fa-warning'};
} }