From c9d1b56c2a32fff6c93ae323f7d19dea6f5340b4 Mon Sep 17 00:00:00 2001 From: Corentin Huet Date: Mon, 11 May 2026 11:03:07 +0200 Subject: [PATCH] fix: :bug: the promotions filter was selected by default --- app/Http/Controllers/ProductsController.php | 3 +-- .../front/sable/js/components/FilterComponent.vue | 10 +++++----- resources/views/front/sable/ranges.blade.php | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/ProductsController.php b/app/Http/Controllers/ProductsController.php index db9a27c4..ef4505dd 100644 --- a/app/Http/Controllers/ProductsController.php +++ b/app/Http/Controllers/ProductsController.php @@ -100,8 +100,7 @@ class ProductsController extends Controller } else { $ranges = Range::all(); $tags = Tag::where('status', true)->get(); - $hasPromotion = Promotion::where('date_start', '<=', now())->where('date_end', '>=', now())->get(); - return view('ranges', compact('products', 'ranges', 'tags', 'sessionFilter', 'filtersMenuIsOpen', 'brands', 'hasPromotion')); + return view('ranges', compact('products', 'ranges', 'tags', 'sessionFilter', 'filtersMenuIsOpen', 'brands')); } } diff --git a/resources/views/front/sable/js/components/FilterComponent.vue b/resources/views/front/sable/js/components/FilterComponent.vue index d20ee3dd..a578c4ea 100644 --- a/resources/views/front/sable/js/components/FilterComponent.vue +++ b/resources/views/front/sable/js/components/FilterComponent.vue @@ -86,7 +86,7 @@
- + @@ -184,7 +184,7 @@ import BasketButtons from './BasketButtons.vue'; return { loading: false, countFilter: 0, - hasPromotion: false, + filterPromotion: false, ranges: [], brands: [], tags: [], @@ -204,7 +204,7 @@ import BasketButtons from './BasketButtons.vue'; }, mounted() { const jsonData = JSON.parse(this.jsonData); - this.hasPromotion = jsonData.hasPromotion ? true : false; + this.filterPromotion = jsonData.filterPromotion ?? false; this.ranges = jsonData.ranges ?? []; this.brands = jsonData.brands ?? []; this.tags = jsonData.tags ?? []; @@ -312,7 +312,7 @@ import BasketButtons from './BasketButtons.vue'; */ getFilters() { return { - promotion: this.hasPromotion, + promotion: this.filterPromotion, ranges: this.ranges.filter((range) => range.selected) .map((range) => range.id), brands: this.brands.filter((brand) => { @@ -375,7 +375,7 @@ import BasketButtons from './BasketButtons.vue'; .map((brand) => brand.selected = false); this.tags.filter((tag) => tag.selected) .map((tag) => tag.selected = false); - this.hasPromotion = false; + this.filterPromotion = false; this.search = ""; this.updatedFilter(); }, diff --git a/resources/views/front/sable/ranges.blade.php b/resources/views/front/sable/ranges.blade.php index 058df585..d315b69e 100644 --- a/resources/views/front/sable/ranges.blade.php +++ b/resources/views/front/sable/ranges.blade.php @@ -9,7 +9,6 @@
@php $dataComponent = [ - 'hasPromotion' => $hasPromotion ? true : false, 'ranges' => $ranges, 'brands' => $brands, 'tags' => $tags,