fix: hide prices in products.index <hen the user isn't logged in - #96

This commit is contained in:
Noah Lancien 2026-02-25 15:45:06 +01:00
parent 06785a3cb8
commit ab9fce56f5
2 changed files with 8 additions and 2 deletions

View file

@ -210,7 +210,8 @@
btnFilterCross: undefined,
btnSearch: undefined,
filters: [],
filtersMenuIsOpen: 0
filtersMenuIsOpen: 0,
shouldDisplayPrices: false,
}
},
mounted() {
@ -231,6 +232,7 @@
this.productsResults = jsonData.productsResults ?? 0;
this.filters = jsonData.filters ?? [];
this.filtersMenuIsOpen = jsonData.filtersMenuIsOpen ?? [];
this.shouldDisplayPrices = jsonData.shouldDisplayPrices ?? false;
this.selectFilters();
this.responsiveFilters();
this.countResults();
@ -410,6 +412,9 @@
if (isNaN(num)) {
return num;
}
if (!this.shouldDisplayPrices) {
return '-.--';
}
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(num);
}
}

View file

@ -18,7 +18,8 @@
'productsCount' => $products->total(),
'search' => $sessionFilter->search ?? '',
'filters' => $sessionFilter,
'filtersMenuIsOpen' => $filtersMenuIsOpen
'filtersMenuIsOpen' => $filtersMenuIsOpen,
'shouldDisplayPrice' => \App\Helpers\BladeDirectivesHelper::shouldShowPrices(),
];
@endphp
<filter-component json-data='@json($dataComponent)'/>