import { Component, OnInit } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import * as Parse from 'parse';
import { NavComponent } from '../../../app/components/nav/nav.component';
import { AiChatService } from '../../../services/aichart.service';

@Component({
  selector: 'app-ranking',
  templateUrl: './ranking.component.html',
  styleUrls: ['./ranking.component.scss'],
  standalone: true,
  imports: [IonicModule,NavComponent],
})
export class RankingComponent implements OnInit {
  user?: Parse.Object = Parse.User.current();
  orderList: Array<any> = [];

  active: string = 'anchor';
  disbable:boolean = true
  constructor(
    private aiServ: AiChatService
  ) {}

  async ngOnInit() {
    this.orderList = await this.aiServ.getOrderAnchor(null,null,'day')
    // console.log(this.orderList);
  }
  async segmentChanged(e: any) {
    let { value } = e.detail;
    this.active = value;
    console.log(this.active);
    // console.log(this.active);
    // this.orderList = []
    this.orderList = await this.aiServ.getOrderAnchor(this.active,null,'day')
  }
  async changeTop(e:any, type?:string){
    e.cancelBubble = true;
    this.orderList = await this.aiServ.getOrderAnchor(this.active,null,type);
  }
}
