diff --git a/front/src/features/catalog/catalogSlice.ts b/front/src/features/catalog/catalogSlice.ts index bfa06a0..06dbda4 100644 --- a/front/src/features/catalog/catalogSlice.ts +++ b/front/src/features/catalog/catalogSlice.ts @@ -67,15 +67,27 @@ const catalogSlice = createSlice({ state.loading = false; state.products = action.payload; state.filtered = action.payload; + state.error = null; + }) + .addCase(fetchProductsByCategory.rejected, (state, action) => { + state.loading = false; + state.error = action.error.message || "Ошибка загрузки товаров"; + state.products = []; + state.filtered = []; + }) + .addCase(fetchCategoryParameters.pending, (state) => { + state.loading = true; + state.error = null; }) .addCase(fetchCategoryParameters.fulfilled, (state, action) => { state.loading = false; state.filters = action.payload }) - /*.addCase(getCategoryProducts.rejected, (state, action) => { + .addCase(fetchCategoryParameters.rejected, (state, action) => { state.loading = false; - state.error = action.error.message || "Ошибка загрузки данных"; - });*/ + state.error = action.error.message || "Ошибка загрузки параметров категории"; + state.filters = {}; + }); }, });