import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class TrackingService {

  constructor() { }

  generateTrackingNumber(): string {
    let now = new Date();
    let year = now.getFullYear();
    let month = now.getMonth() + 1;
    let day = now.getDate();
    
    let trackingNumber = this.generateRandomNumber(1000, 9999).toString();
    trackingNumber = year.toString() + month.toString() + day.toString() + trackingNumber;
    return trackingNumber;
  }

  private generateRandomNumber(min: number, max: number): number {
    return Math.floor(Math.random() * (max - min + 1)) + min;
  }
}