import { api } from './api';
import { API_ENDPOINTS } from '@/utils/constants';
import {
  Ticket,
  ApiResponse,
} from '@/types';

export const employeeService = {
  /**
   * Récupérer la liste des tickets en attente de validation
   * GET /api/employee/pending-tickets
   */
  getPendingTickets: async (): Promise<Ticket[]> => {
    const response = await api.get<ApiResponse<Ticket[]>>(API_ENDPOINTS.EMPLOYEE.PENDING_TICKETS);
    return response.data || [];
  },

  /**
   * Valider un ticket (marquer comme récupéré)
   * POST /api/employee/validate-ticket
   */
  validateTicket: async (ticketId: string, action: 'APPROVE' | 'REJECT', reason?: string): Promise<Ticket> => {
    const response = await api.post<ApiResponse<Ticket>>(
      API_ENDPOINTS.EMPLOYEE.VALIDATE_TICKET,
      { ticketId, action, rejectionReason: reason }
    );
    return response.data!;
  },
};
