import create from 'zustand';

export const [productListDataStore] = create(set => ({
    searchResultCount: null,
    setSearchResultCount: searchResultCount => set(() => ({ searchResultCount })),

    sortBy: null,
    setSortBy: sortBy => set(() => ({ sortBy })),

    filtersQuery: null,
    nAppliedFilters: null,
    setFiltersQuery: filtersQuery => set(() => (
        {
            filtersQuery, nAppliedFilters: filtersQuery && filtersQuery.length
        }
    )),

    filtersDetails: null,
    setFiltersDetails: filtersDetails => set(() => (
        {
            filtersDetails
        }
    )),

    listingPage: null,
    setListingPage: listingPage => set(() => ({ listingPage })),

    listingLastPage: null,
    setListingLastPage: listingLastPage => set(() => ({ listingLastPage })),

    listingCategories: null,
    setListingCategories: listingCategories => set(() => ({ listingCategories }))
}));
