import { CustomerQueueManager } from './customer-queue.manager';

export class CustomerQueueItemManager extends CustomerQueueManager {
  get data() {
    return this.tickets.map((ticket) => {
      const queueItems = this.mergeQueueItems(ticket);
      const item = ticket.items[0];

      return {
        id: ticket.id,
        code: ticket.code,
        customer: ticket.customer,
        phone: ticket.phone,
        date: ticket.date,
        image_url: item.item.image_url,
        summary: this.summaryTicket(ticket),
        queue: queueItems[0].queues
          .sort((a, b) => b.time - a.time)
          .map((q) => {
            return {
              code: q.code,
              qty: q.qty,
              time: this.toTime(q.time),
              status: q.status,
            };
          }),
      };
    });
  }
}
