import { Component, OnInit } from '@angular/core';
import { CommonModule, DatePipe } from '@angular/common';
import { ionicStandaloneModules } from '../../../ionic-standalone.modules';
import { NavComponent } from '../../../../app/components/nav/nav.component';
import * as Parse from 'parse';
import { ActivatedRoute } from '@angular/router';
import { AiChatService } from '../../../../services/aichart.service';
import { SharedModule } from "../../../shared.module";
@Component({
  selector: 'app-detail',
  templateUrl: './detail.component.html',
  styleUrls: ['./detail.component.scss'],
  standalone: true,
  imports: [...ionicStandaloneModules, NavComponent, CommonModule, SharedModule],
  providers: [DatePipe],
})
export class DetailComponent implements OnInit {
  liveLog?: Parse.Object;
  timeLength:number = 0
  constructor(private activateRoute: ActivatedRoute,private aiServ:AiChatService) {}

  ngOnInit() {
    this.activateRoute.paramMap.subscribe(async (params) => {
      let id: any = params.get('id');
      let query = new Parse.Query('LiveLog');
      // query.select('price','isPay', 'orderNum','status', 'targetObject.name','targetObject.validity');
      query.include('profile', 'user','room');
      query.get(id).then((res) => {
        this.liveLog = res;
      });
      this.timeLength = await this.aiServ.getLiveActiveLog(id)
    });
  }
}
