sort and filter added to tenders web
This commit is contained in:
@@ -15,11 +15,19 @@ class TendersRepository {
|
||||
required int limit,
|
||||
required int offset,
|
||||
String? query,
|
||||
String? sortBy,
|
||||
String? sortOrder,
|
||||
String? publicationDateFrom,
|
||||
String? publicationDateTo,
|
||||
}) async {
|
||||
return _tendersService.getTenders(
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
query: query,
|
||||
sortBy: sortBy,
|
||||
sortOrder: sortOrder,
|
||||
publicationDateFrom: publicationDateFrom,
|
||||
publicationDateTo: publicationDateTo,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,33 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,22 @@ class TendersService {
|
||||
required int limit,
|
||||
required int offset,
|
||||
String? query,
|
||||
String? sortBy,
|
||||
String? sortOrder,
|
||||
String? publicationDateFrom,
|
||||
String? publicationDateTo,
|
||||
}) async {
|
||||
final result = await _networkManager.makeRequest(
|
||||
TendersApi.getTenders(limit: limit, offset: offset, query: query),
|
||||
TendersApi.getTenders(
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
query: query,
|
||||
sortBy: sortBy,
|
||||
sortOrder: sortOrder,
|
||||
publicationDateFrom: publicationDateFrom,
|
||||
publicationDateTo: publicationDateTo,
|
||||
),
|
||||
|
||||
method: 'GET',
|
||||
(json) => TendersResponse.fromJson(json),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user