import { Component } from '@angular/core';
import { AppwriteService } from '../../services/appwrite.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-header',
  standalone: true,
  imports: [],
  templateUrl: './header.component.html',
  styleUrl: './header.component.css',
})
export class HeaderComponentComponent {

  constructor(
    private appwriteService: AppwriteService,
    private routes: Router,
  ) {}

  goToSummery() {
  //  this.routes.navigate(['/list']);
  }

  goToInput() {
  //  this.routes.navigate(['/input']);
  }

  async logout() {
    try {
      const accountService = await this.appwriteService.accountService;
      await this.appwriteService.accountService.deleteSession(
        (await accountService.getSession('current')).$id,
      );
      // Bei erfolgreicher Abmeldung
      //this.toast.success('Logout erfolgreich!', 'Auf Wiedersehen!');
      this.routes.navigate(['/login']);
    } catch (err: any) {
      console.error('Fehler beim Abmelden:', err.message);
    }
  }
}
