why extrareducers are not working in the following js code:
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import axios from "axios";

const initialState = {
  data: null,
  currentPage: 1,
  total: 0,
  pages: [],
  productsLoading: false,
  productsError: false,
  totalLoading: false,
  totalError: false,
};

export const getProducts = createAsyncThunk(
  "productsSlice/getProducts",
  async () => {
    const currentPage = window.sessionStorage.getItem("currentPage");
    const addPriceWithDiscount = (data) => {
      data.products.map((product) => {
        product.priceWithDiscount = (
          product.price -
          (product.price * product.discountPercentage) / 100
        ).toFixed(2);
      });
      console.log(data.products);
      return data.products;
    };
    if (currentPage === 1) {
      const { data } = await axios.get(
        "https://dummyjson.com/products?limit=12"
      );
      return addPriceWithDiscount(data);
    } else {
      const { data } = await axios.get(
        `https://dummyjson.com/products/?limit=12&skip=${
          (currentPage - 1) * 12
        }`
      );
      return addPriceWithDiscount(data);
    }
  }
);

export const getTotalProducts = createAsyncThunk(
  "productsSlice/getTotalProducts",
  async () => {
    const { data } = await axios.get("https://dummyjson.com/products");
    return data.total;
  }
);

export const productsSlice = createSlice({
  name: "productsSlice",
  initialState,
  reducers: {
    fillPages: (state) => {
      const res = [];
      for (let i = 1; i <= Math.ceil(state.total / 12); i++) {
        res.push(i);
      }
      state.pages = res;
    },
    goCertainPage: (state, action) => {
      window.sessionStorage.setItem("currentPage", action.payload);
    },
    addAvgRatings: (state, action) => {
      const ratingAvgProd = [...action.payload].map((prod) => {
        let total = prod.reviews.reduce(
          (sum, review) => sum + review.rating,
          0
        );
        let average = (total / prod.reviews.length).toFixed(1);
        return {
          ...prod,
          ratingAvg: average,
        };
      });
      state.data = ratingAvgProd;
    },
    sortProductsName: (state, action) => {
      const sortedProd = [...action.payload].sort((a, b) =>
        a.title.toLowerCase() > b.title.toLowerCase() ? 1 : -1
      );
      state.data = sortedProd;
    },
    sortProductsAsc: (state, action) => {
      const sortedProd = [...action.payload].sort((a, b) =>
        a.price > b.price ? 1 : -1
      );
      state.data = sortedProd;
    },
    sortProductsDesc: (state, action) => {
      const sortedProd = [...action.payload].sort((a, b) =>
        b.price > a.price ? 1 : -1
      );
      state.data = sortedProd;
    },
    sortProductsStock: (state, action) => {
      const sortedProd = [...action.payload].sort((a, b) =>
        b.stock > a.stock ? 1 : -1
      );
      state.data = sortedProd;
    },
    sortProductsRating: (state, action) => {
      const sortedProd = [...action.payload].sort(
        (a, b) => b.ratingAvg - a.ratingAvg
      );
      console.log(sortedProd);
      state.data = sortedProd;
    },
  },
  extraReducers: (builder) => {
    builder
      .addCase(getProducts.pending, (state, action) => {
        state.productsLoading = true;
      })
      .addCase(getProducts.fulfilled, (state, action) => {
        state.productsLoading = false;
        state.productsError = false;
        state.data = action.payload;
      })
      .addCase(getProducts.rejected, (state, action) => {
        state.productsLoading = false;
        state.productsError = true;
      });
    builder
      .addCase(getTotalProducts.pending, (state, action) => {
        state.totalLoading = true;
      })
      .addCase(getTotalProducts.fulfilled, (state, action) => {
        state.totalLoading = false;
        state.totalError = false;
        state.total = action.payload;
      })
      .addCase(getTotalProducts.rejected, (state, action) => {
        state.totalLoading = false;
        state.totalError = true;
      });
  },
});

export default productsSlice.reducer;

export const {
  fillPages,
  goCertainPage,
  addAvgRatings,
  sortProductsName,
  sortProductsAsc,
  sortProductsDesc,
  sortProductsStock,
  sortProductsRating,
} = productsSlice.actions;