import { Component, OnInit } from '@angular/core';
import { IonLabel,ModalController } from '@ionic/angular/standalone';
import { IonCard, IonCardContent, IonCardHeader,  IonCardTitle,  IonItem } from '@ionic/angular/standalone';
import { CloudUser } from 'src/lib/ncloud';

@Component({
  selector: 'app-info-modal',
  templateUrl: './info-modal.component.html',
  styleUrls: ['./info-modal.component.scss'],
  standalone: true,
  imports: [IonCard,IonCardContent,IonCardHeader,IonCardTitle,
    IonItem,IonLabel
  ],
})
export class InfoModalComponent  implements OnInit {

  
  currentUser:CloudUser|undefined
  userData:any = {}
  userDataChange(key:string,ev:any){
    let value = ev?.detail?.value
    if(value){
      this.userData[key] = value
    }
  }
  constructor(private modalCtrl: ModalController) {
    this.currentUser = new CloudUser();
    this.userData = this.currentUser.data;
  }
  ngOnInit() {}

}
export async function openInfoModal(modalCtrl:ModalController):Promise<CloudUser|null>{
  const modal = await modalCtrl.create({
    component: InfoModalComponent,
    breakpoints:[0.7,1.0],
    initialBreakpoint:0.7
  });
  modal.present();

  const { data, role } = await modal.onWillDismiss();

  if (role === 'confirm') {
    return data;
  }
  return null
}
