import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { IonHeader, IonToolbar, IonTitle, IonContent, IonList,IonItem,IonIcon,IonLabel,IonButton,
  IonCard,IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle} from '@ionic/angular/standalone';
import { CloudUser } from 'src/lib/ncloud';
import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-login.component';
import { ModalController } from '@ionic/angular/standalone';
import { openUserEditModal } from 'src/lib/user/modal-user-edit/modal-user-edit.component';
import { openInfoModal } from '../info-modal/info-modal.component';
import { openIdentityVerificationModal } from 'src/lib/user/modal-identity-verification/modal-identity-verification.component';
import { Router } from '@angular/router';

@Component({
  selector: 'app-tab3',
  templateUrl: 'tab3.page.html',
  styleUrls: ['tab3.page.scss'],
  standalone: true,
  imports: [IonHeader,IonToolbar,IonTitle,IonContent,IonList,IonItem,IonIcon,IonLabel,IonButton,
    IonCard,IonCardContent,IonCardHeader,IonCardTitle,IonCardSubtitle
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
  })
export class Tab3Page {

  currentUser:CloudUser|undefined
  constructor(private modalCtrl:ModalController,private router: Router) {
    this.currentUser = new CloudUser();
  }
  async login(){
    //弹出登录窗口
    let user = await openUserLoginModal(this.modalCtrl);
    if(user?.id){
      this.currentUser = user
    }
  }
  async signup(){
    //弹出注册窗口
    let user = await openUserLoginModal(this.modalCtrl,"signup");
    if(user?.id){
      this.currentUser = user
    }
  }
  logout(){
    this.currentUser?.logout();
  }
  editUser(){
    openUserEditModal(this.modalCtrl)
  }
  presentInfoModal(){
    openInfoModal(this.modalCtrl)
  }
  identityVerificationModal(){
    openIdentityVerificationModal(this.modalCtrl)
  }
  openReportModal() {
    this.router.navigate(['tabs/report-modal'])
  }
}