Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanTymoshchuk committed Jun 26, 2023
1 parent 8c451c5 commit 5097830
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/components/ContactList/ContactList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import { deleteContacts } from 'redux/contactsSlice';
const ContactList = () => {
const contacts = useSelector(getVisibleContacts);
const dispatch = useDispatch();
const handleDelete = () => dispatch(deleteContacts());

return (
<ListWrap>
{contacts.map(({ id, name, number }) => (
<List key={id}>
{name + ' : ' + number}

<Button type="button" onClick={handleDelete}>
<Button type="button" onClick={() => dispatch(deleteContacts(id))}>
<UserDeleteOutlined />
</Button>
</List>
Expand Down
2 changes: 1 addition & 1 deletion src/redux/contactsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const contactsSlice = createSlice({
reducers: {
addContact: {
reducer(state, action) {
state.list.push(action.payload); // Додавання нового контакта
state.list = [...state.list, action.payload]; // Додавання нового контакта
},
},
prepare: (name, number) => {
Expand Down
4 changes: 2 additions & 2 deletions src/redux/filterSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const filterSlice = createSlice({
name: 'filter',
initialState: initialFilterState,
reducers: {
changeFilter(action) {
return action.payload; // Оновлення значення з попереднього
changeFilter(state, action) {
return (state = action.payload); // Оновлення значення з попереднього
},
},
});
Expand Down

0 comments on commit 5097830

Please sign in to comment.