mirror of https://github.com/ghostfolio/ghostfolio
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							41 lines
						
					
					
						
							1.0 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							41 lines
						
					
					
						
							1.0 KiB
						
					
					
				
								import {
							 | 
						|
								  ChangeDetectionStrategy,
							 | 
						|
								  Component,
							 | 
						|
								  Input,
							 | 
						|
								  OnChanges,
							 | 
						|
								  OnInit
							 | 
						|
								} from '@angular/core';
							 | 
						|
								import { PortfolioSummary } from '@ghostfolio/common/interfaces';
							 | 
						|
								import { Currency } from '@prisma/client';
							 | 
						|
								import { formatDistanceToNow } from 'date-fns';
							 | 
						|
								
							 | 
						|
								@Component({
							 | 
						|
								  selector: 'gf-portfolio-summary',
							 | 
						|
								  changeDetection: ChangeDetectionStrategy.OnPush,
							 | 
						|
								  templateUrl: './portfolio-summary.component.html',
							 | 
						|
								  styleUrls: ['./portfolio-summary.component.scss']
							 | 
						|
								})
							 | 
						|
								export class PortfolioSummaryComponent implements OnChanges, OnInit {
							 | 
						|
								  @Input() baseCurrency: Currency;
							 | 
						|
								  @Input() isLoading: boolean;
							 | 
						|
								  @Input() locale: string;
							 | 
						|
								  @Input() summary: PortfolioSummary;
							 | 
						|
								
							 | 
						|
								  public timeInMarket: string;
							 | 
						|
								
							 | 
						|
								  public constructor() {}
							 | 
						|
								
							 | 
						|
								  public ngOnInit() {}
							 | 
						|
								
							 | 
						|
								  public ngOnChanges() {
							 | 
						|
								    if (this.summary) {
							 | 
						|
								      if (this.summary.firstOrderDate) {
							 | 
						|
								        this.timeInMarket = formatDistanceToNow(this.summary.firstOrderDate);
							 | 
						|
								      } else {
							 | 
						|
								        this.timeInMarket = '-';
							 | 
						|
								      }
							 | 
						|
								    } else {
							 | 
						|
								      this.timeInMarket = undefined;
							 | 
						|
								    }
							 | 
						|
								  }
							 | 
						|
								}
							 | 
						|
								
							 |