import 'package:tm_app/core/utils/logger.dart';

class TendersApi {
  static const String tenders = '/api/v1/tenders';
  static String getTenders({
    required int limit,
    required int offset,
    String? query,
    String? sortBy,
    String? sortOrder,
    String? publicationDateFrom,
    String? publicationDateTo,
  }) {
    String url = '$tenders?limit=$limit&offset=$offset';
    if (query != null && query.isNotEmpty) {
      url += '&q=${Uri.encodeComponent(query)}';
    }
    if (sortBy != null && sortBy.isNotEmpty) {
      url += '&sort_by=$sortBy';
    }
    if (sortOrder != null && sortOrder.isNotEmpty) {
      url += '&sort_order=$sortOrder';
    }
    if (publicationDateFrom != null && publicationDateFrom.isNotEmpty) {
      url += '&publication_date_from=$publicationDateFrom';
    }
    if (publicationDateTo != null && publicationDateTo.isNotEmpty) {
      url += '&publication_date_to=$publicationDateTo';
    }
    AppLogger().logWarning('🔍 Tenders API: $url');
    return url;
  }

  static const String feedbackTender = '/api/v1/feedback/tender';
  static String getFeedbackForTender({required String tenderId}) {
    return '$feedbackTender/$tenderId';
  }

  static const String feedback = '/api/v1/feedback';

  static const String tenderApprovals = '/api/v1/tender-approvals';

  static const String tenderApprovalsTender = '/api/v1/tender-approvals/tender';
  static String getTenderApprovalById({required String tenderId}) {
    return '$tenderApprovalsTender/$tenderId';
  }
}
