import { Component, OnInit } from '@angular/core';
import { NavComponent } from '../../../app/components/nav/nav.component';
import { ionicStandaloneModules } from '../../ionic-standalone.modules';
import * as Parse from 'parse';
import { CommonModule, DatePipe } from '@angular/common';
import { Router } from '@angular/router';
@Component({
  selector: 'app-order',
  templateUrl: './order.component.html',
  styleUrls: ['./order.component.scss'],
  standalone: true,
  imports: [...ionicStandaloneModules, NavComponent,CommonModule],
  providers: [DatePipe],
})
export class OrderComponent implements OnInit {
  list: Array<any> = []
  constructor(
    private router: Router,
  ) { }

  ngOnInit() {
    this.getOrder()
  }
  async getOrder(){
    let query = new Parse.Query('Order');
    query.notEqualTo('isDeleted', true);
    query.equalTo('user',Parse.User.current()?.id);
    query.limit(20)
    query.skip(this.list.length)
    query.select('price','status','targetObject.name')
    query.descending('createdAt')
    this.list = await query.find();
  }
  toUrl(id:string){
    this.router.navigate(['account/order/detail/'+id]);
  }
}
