import { Component, OnInit } from '@angular/core';
import { ToastController } from '@ionic/angular';
import { ServiceUserService } from '../../../service/service-user.service';
import * as Parse from "parse";
import { ActivatedRoute, Router } from '@angular/router';

@Component({
  selector: 'app-mine',
  templateUrl: './mine.component.html',
  styleUrls: ['./mine.component.scss']
})
export class MineComponent {
  path = ""

  goTab(path: string) {
    this.path = path;
    this.router.navigate([path])
  }
  private values: string[] = ['first', 'second', 'third'];
  accordionGroupChange = (ev: any) => {
    const collapsedItems = this.values.filter((value) => value !== ev.detail.value);
    const selectedValue = ev.detail.value;
    console.log(
      `Expanded: ${selectedValue === undefined ? 'None' : ev.detail.value} | Collapsed: ${collapsedItems.join(', ')}`
    );
  }

  currentUser: Parse.User | undefined;
  constructor(
    private toastCtrl: ToastController,
    public userServ: ServiceUserService,
    private route: ActivatedRoute, private router: Router
  ) {
    this.currentUser = Parse.User.current()
    this.route.queryParams.subscribe(params => {
      this.path = location.pathname;
    })
  }
  async logout() {
    Parse.User.logOut().then(async () => {
      let toast = await this.toastCtrl.create({
        message: "登出成功",
        position: "top",
        duration: 500
      })
      toast.present();
    })
  }
}
