import { Component } from '@angular/core';
import { NavController, ToastController } from '@ionic/angular';
import * as Parse from "parse";

@Component({
  selector: 'app-tab3',
  templateUrl: './tab3.page.html',
  styleUrls: ['./tab3.page.scss']
})
export class Tab3Page {

  constructor(private navCtrl: NavController, private toastController: ToastController) {}

  async onItemClick(item: string) {
    const toast = await this.toastController.create({
      message: `Clicked on ${item}`,
      duration: 2000,
    });
    toast.present();
  }

  async logout() {
    try {
      await Parse.User.logOut();
      this.navCtrl.navigateRoot('/tabs/calendar'); // 登出后跳转到登录界面
    } catch (error: any) {
      console.error("Logout failed:", error);
      const toast = await this.toastController.create({
        message: `登出失败: ${error.message}`,
        duration: 2000,
      });
      toast.present();
    }
  }
}
