import { BaseApiService } from '@/services/api/base';
import { BaseApiResponse } from '@/types/api/api-general';
import { CustomerPaymentReport } from '@/types/api/report/customer-payment';

export class FinanceApiService extends BaseApiService<
  CustomerPaymentReport,
  unknown,
  unknown
> {
  constructor(basePath: string) {
    super(basePath);
  }

  async getCustomerPaymentReport(
    customer_ids?: string,
    // TODO: Uncomment when BE is ready
    // sales_id?: string,
    filter_by?: 'trans_date' | 'realization_date',
    start_date?: string,
    end_date?: string,
    page?: number,
    limit?: number
  ): Promise<BaseApiResponse<CustomerPaymentReport> | undefined> {
    return await this.customRequest<BaseApiResponse<CustomerPaymentReport>>(
      `customer-payment`,
      {
        method: 'GET',
        params: {
          customer_ids: customer_ids,
          // TODO: Uncomment when BE is ready
          // sales_id: sales_id,
          filter_by: filter_by,
          start_date: start_date,
          end_date: end_date,
          page: page,
          limit: limit,
        },
      }
    );
  }
}

export const FinanceApi = new FinanceApiService('reports');

// export const FinanceApi = new FinanceApiService(
//   'http://localhost:4010/api/reports/finance'
// );
