import { Component, OnInit } from '@angular/core';
import { IActiveTosResponseModel } from '@fleio-api/core/model/active-tos-response.model';
import { ActivatedRoute } from '@angular/router';
import { TosApiService } from '@fleio-api/core/tos-api.service';

@Component({
  selector: 'app-terms-of-service-preview',
  templateUrl: './terms-of-service-preview.component.html',
  styleUrls: ['./terms-of-service-preview.component.scss']
})
export class TermsOfServicePreviewComponent implements OnInit {
  tos: IActiveTosResponseModel;
  tosId: number;
  translatedContent: string;

  constructor(
    private tosApi: TosApiService,
    private activatedRoute: ActivatedRoute,
  ) {
    this.tosId = this.activatedRoute.snapshot.params.id;
  }

  ngOnInit(): void {
    this.tosApi.getTos(this.tosId).subscribe(value => {
      this.tos = value;
      this.translatedContent = $localize`${this.tos.tos_data.content}`;
    });
  }

}
