Skip to content

Commit

Permalink
change state error value to bollean
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantin-it-lysenko committed Dec 28, 2023
1 parent 62065cd commit eb94c34
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/redux/contacts/contactsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { addContact, getContacts, deleteContact } from "../../redux/contacts/con
const initialState = {
items: [],
isLoading: false,
error: null
error: false
}

const handlePending = (state) => {
state.error = null
state.error = false
state.isLoading = true
}

Expand All @@ -17,8 +17,8 @@ const handleFulfilled = (state, { payload }) => {
state.isLoading = false
}

const handleRejected = (state, { payload }) => {
state.error = payload
const handleRejected = (state) => {
state.error = true
state.isLoading = false
}

Expand All @@ -34,7 +34,7 @@ const contactsSlice = createSlice({
.addCase(addContact.fulfilled, (state, { payload }) => {
state.items.push(payload)
state.isLoading = false
state.error = null
state.error = false
})
.addCase(addContact.rejected, handleRejected)
.addCase(deleteContact.pending, handlePending)
Expand All @@ -45,7 +45,7 @@ const contactsSlice = createSlice({

state.items.splice(index, 1)
state.isLoading = false
state.error = null
state.error = false
})
.addCase(deleteContact.rejected, handleRejected)
}
Expand Down

0 comments on commit eb94c34

Please sign in to comment.