|
|
|
|
@ -310,12 +310,11 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String catParam = (targetCategoryId == "all" || targetCategoryId == "0") ? "" : targetCategoryId;
|
|
|
|
|
String? offerTypeParam = OffersAndDiscountsApiClient.mapOfferTypeFilter(selectedTypeFilter);
|
|
|
|
|
String catParam = (isFavoriteOnly || targetCategoryId == "all" || targetCategoryId == "0") ? "" : targetCategoryId;
|
|
|
|
|
String? offerTypeParam = isFavoriteOnly ? null : OffersAndDiscountsApiClient.mapOfferTypeFilter(selectedTypeFilter);
|
|
|
|
|
String? queryParam = searchQuery.trim().isNotEmpty ? searchQuery.trim() : null;
|
|
|
|
|
int? radiusParam = _radiusFromFilterDistance(_filterDistance);
|
|
|
|
|
int? minDiscountParam = _filterMinDiscount == 'any' ? null : int.tryParse(_filterMinDiscount);
|
|
|
|
|
print("Fetching WalaPlus retailers: category='$catParam', offerType='$offerTypeParam', query='$queryParam', sortBy='$_filterSortBy', radius=$radiusParam, minDiscount=$minDiscountParam, page=1, per_page=$pageSize");
|
|
|
|
|
int? radiusParam = isFavoriteOnly ? null : _radiusFromFilterDistance(_filterDistance);
|
|
|
|
|
int? minDiscountParam = (isFavoriteOnly || _filterMinDiscount == 'any') ? null : int.tryParse(_filterMinDiscount);
|
|
|
|
|
String? userRef = isFavoriteOnly ? _getUserReferenceForFavorites() : null;
|
|
|
|
|
print("Fetching WalaPlus retailers: category='$catParam', offerType='$offerTypeParam', query='$queryParam', userReference='$userRef', page=1, per_page=$pageSize");
|
|
|
|
|
WalaPlusRetailersResponse? response = await OffersAndDiscountsApiClient().getWalaPlusRetailers(
|
|
|
|
|
@ -324,10 +323,10 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
|
|
|
|
|
perPage: pageSize,
|
|
|
|
|
offerType: offerTypeParam,
|
|
|
|
|
query: queryParam,
|
|
|
|
|
sortBy: _filterSortBy,
|
|
|
|
|
sortBy: isFavoriteOnly ? null : _filterSortBy,
|
|
|
|
|
radius: radiusParam,
|
|
|
|
|
minDiscount: minDiscountParam,
|
|
|
|
|
context: wantsNearest ? context : null,
|
|
|
|
|
context: (!isFavoriteOnly && wantsNearest) ? context : null,
|
|
|
|
|
userReference: userRef,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@ -369,14 +368,14 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
int nextPage = currentPage + 1;
|
|
|
|
|
String catParam = (currentCategoryId == "all" || currentCategoryId == "0") ? "" : currentCategoryId;
|
|
|
|
|
String? offerTypeParam = OffersAndDiscountsApiClient.mapOfferTypeFilter(selectedTypeFilter);
|
|
|
|
|
String catParam = (isFavoriteOnly || currentCategoryId == "all" || currentCategoryId == "0") ? "" : currentCategoryId;
|
|
|
|
|
String? offerTypeParam = isFavoriteOnly ? null : OffersAndDiscountsApiClient.mapOfferTypeFilter(selectedTypeFilter);
|
|
|
|
|
String? queryParam = searchQuery.trim().isNotEmpty ? searchQuery.trim() : null;
|
|
|
|
|
String? userRef = isFavoriteOnly ? _getUserReferenceForFavorites() : null;
|
|
|
|
|
int? radiusParam = _radiusFromFilterDistance(_filterDistance);
|
|
|
|
|
int? minDiscountParam = _filterMinDiscount == 'any' ? null : int.tryParse(_filterMinDiscount);
|
|
|
|
|
int? radiusParam = isFavoriteOnly ? null : _radiusFromFilterDistance(_filterDistance);
|
|
|
|
|
int? minDiscountParam = (isFavoriteOnly || _filterMinDiscount == 'any') ? null : int.tryParse(_filterMinDiscount);
|
|
|
|
|
|
|
|
|
|
print("Fetching WalaPlus retailers next page: $nextPage of $totalPages, category: '$catParam', offerType: '$offerTypeParam', query: '$queryParam'");
|
|
|
|
|
print("Fetching WalaPlus retailers next page: $nextPage of $totalPages, category: '$catParam', offerType: '$offerTypeParam', query: '$queryParam', userReference='$userRef'");
|
|
|
|
|
|
|
|
|
|
WalaPlusRetailersResponse? response = await OffersAndDiscountsApiClient().getWalaPlusRetailers(
|
|
|
|
|
categoryId: catParam,
|
|
|
|
|
@ -384,10 +383,10 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
|
|
|
|
|
perPage: pageSize,
|
|
|
|
|
offerType: offerTypeParam,
|
|
|
|
|
query: queryParam,
|
|
|
|
|
sortBy: _filterSortBy,
|
|
|
|
|
sortBy: isFavoriteOnly ? null : _filterSortBy,
|
|
|
|
|
radius: radiusParam,
|
|
|
|
|
minDiscount: minDiscountParam,
|
|
|
|
|
context: wantsNearest ? context : null,
|
|
|
|
|
context: (!isFavoriteOnly && wantsNearest) ? context : null,
|
|
|
|
|
userReference: userRef,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@ -689,7 +688,7 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
|
|
|
|
|
setState(() {
|
|
|
|
|
isFavoriteOnly = !isFavoriteOnly;
|
|
|
|
|
});
|
|
|
|
|
fetchOffers(categoryId: currentCategoryId.isEmpty ? "all" : currentCategoryId);
|
|
|
|
|
fetchOffers(categoryId: isFavoriteOnly ? "" : (currentCategoryId.isEmpty ? "all" : currentCategoryId));
|
|
|
|
|
},
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(3),
|
|
|
|
|
@ -740,16 +739,23 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
|
|
|
|
|
// Search Input Card
|
|
|
|
|
_buildSearchBar(isAr),
|
|
|
|
|
|
|
|
|
|
// "Browse Categories" Header
|
|
|
|
|
_buildBrowseCategoriesHeader(isAr),
|
|
|
|
|
if (isFavoriteOnly) ...[
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 22, bottom: 14),
|
|
|
|
|
child: LocaleKeys.favoriteMerchant.tr().toText18(weight: FontWeight.w600, color: const Color(0xFF1E293B)),
|
|
|
|
|
),
|
|
|
|
|
] else ...[
|
|
|
|
|
// "Browse Categories" Header
|
|
|
|
|
_buildBrowseCategoriesHeader(isAr),
|
|
|
|
|
|
|
|
|
|
// Categories Section
|
|
|
|
|
if (categoriesList.isNotEmpty) _buildCategoriesList(isAr) else _buildCategoriesShimmer(),
|
|
|
|
|
// Categories Section
|
|
|
|
|
if (categoriesList.isNotEmpty) _buildCategoriesList(isAr) else _buildCategoriesShimmer(),
|
|
|
|
|
|
|
|
|
|
// Type Filter Chips (All, In Store, Online)
|
|
|
|
|
_buildFiltersRow(isAr),
|
|
|
|
|
// Type Filter Chips (All, In Store, Online)
|
|
|
|
|
_buildFiltersRow(isAr),
|
|
|
|
|
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
// Offers Grid
|
|
|
|
|
if (isLoading)
|
|
|
|
|
@ -1326,7 +1332,6 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
|
|
|
|
|
// type can be a comma-separated combo (e.g. "online,instore") - normalizedTypes already
|
|
|
|
|
// splits that into its distinct parts, so a retailer offering both ways gets a chip each.
|
|
|
|
|
List<String> offerTypes = item.normalizedTypes;
|
|
|
|
|
String validityText = item.getDisplayValidity();
|
|
|
|
|
String usageText = "";
|
|
|
|
|
if (item.displayUsage.isNotEmpty) {
|
|
|
|
|
usageText = item.displayUsage.replaceAll('usage:', LocaleKeys.usageLabel.tr()).replaceAll('Usage :', LocaleKeys.usageLabel.tr());
|
|
|
|
|
|