diff --git a/src/components/item-details/hide-item-button.tsx b/src/components/item-details/hide-item-button.tsx index f6c098e..81b9e66 100644 --- a/src/components/item-details/hide-item-button.tsx +++ b/src/components/item-details/hide-item-button.tsx @@ -11,8 +11,8 @@ export const HideItemButton = () => { const dispatch = useAppDispatch(); const [isModalOpen, setIsModalOpen] = useState(false); const { - selectedItem: { itemId, status, isHidden }, - isLoading, + selectedItem: { itemId, isHidden }, + isHiding, } = useAppSelector((state) => state.marketplace); const handleModal = () => { @@ -55,7 +55,7 @@ export const HideItemButton = () => {
{ let initialState: MarketplaceState; beforeEach(() => { - initialState = { - isUploadingImage: false, - items: [], - itemsCount: 0, - likedItems: [], - collections: [], - collectionsCount: 0, - collectionsWithoutItems: [], - selectedItem: {} as Item, - newestItems: [], - filters: { - likesDirection: '', - search: '', - priceRange: { - from: '', - to: '', - }, - cheapest: '', - mostExpensive: '', - page: 1, - limit: 3, - }, - history: [] as History[], - historyCount: 0, - newestCollections: [] as ICollection[], - selectedCollection: {} as ICollection, - isLoadingCollections: false, - collectionsFilters: { - search: '', - popularityOrder: '', - creationOrder: '', - mintType: '', - page: 1, - limit: 3, - }, - isLoading: false, - isDelisting: false, - isListing: false, - isPagingLoading: false, - isLoadingHistory: false, - isLoadingNewest: false, - isLoadingCollection: false, - isModalOpen: false, - isCompleted: false, - isOpenPreviewProductModal: false, - }; + initialState = initialMarketplaceState; }); describe('When newestItems function is called', () => { diff --git a/src/features/marketplace/store/marketplace.slice.ts b/src/features/marketplace/store/marketplace.slice.ts index 18c98e6..c8967c9 100644 --- a/src/features/marketplace/store/marketplace.slice.ts +++ b/src/features/marketplace/store/marketplace.slice.ts @@ -67,6 +67,8 @@ export type MarketplaceState = { isListing: boolean; isModalOpen: boolean; isCompleted: boolean; + isHiding: boolean; + isBuying: boolean; isOpenPreviewProductModal: boolean; }; @@ -79,7 +81,7 @@ export const initialFormState = { properties: [], }; -const initialState: MarketplaceState = { +export const initialMarketplaceState: MarketplaceState = { items: [], itemsCount: 0, likedItems: [], @@ -124,19 +126,21 @@ const initialState: MarketplaceState = { isModalOpen: false, isCompleted: false, isOpenPreviewProductModal: false, + isHiding: false, + isBuying: false, }; const marketplaceSlice = createSlice({ name: 'marketplace', - initialState, + initialState: initialMarketplaceState, reducers: { setFilters: (state, { payload }) => { state.filters = payload; }, resetFilters: (state) => { - state.filters = initialState.filters; - state.items = initialState.items; - state.history = initialState.history; + state.filters = initialMarketplaceState.filters; + state.items = initialMarketplaceState.items; + state.history = initialMarketplaceState.history; }, setSelectedItem: (state, { payload }) => { state.selectedItem = payload; @@ -335,6 +339,7 @@ const marketplaceSlice = createSlice({ builder.addCase(hideItem.fulfilled, (state, { payload }) => { const index = state.items.findIndex((i) => i.itemId === payload.itemId); state.items[index] = payload; + state.isHiding = false; if (state.selectedItem.itemId === payload.itemId) state.selectedItem = payload; });