Skip to content

Commit

Permalink
Changes in folder Redux
Browse files Browse the repository at this point in the history
  • Loading branch information
WOWmasterJulia committed Oct 29, 2023
1 parent 1bfa264 commit 7de9684
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 117 deletions.
63 changes: 0 additions & 63 deletions src/redux/contactsSlice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const contactSlice = createSlice({
state.isLoading = false;
state.error = action.payload;
})

.addCase(addContact.pending, (state, action) => {
state.isLoading = true;
})
Expand All @@ -37,16 +36,6 @@ const contactSlice = createSlice({
state.isLoading = false;
state.error = action.payload;
})

// .addCase(existContacts.pending, (state, action) => state)
// .addCase(existContacts.fulfilled, (state, action) => {
// const index = state.items.findIndex(
// contact => contact.id === action.payload.id
// );
// state.items.splice(index, 1, action.payload);
// })
// .addCase(existContacts.rejected, (state, action) => state)

.addCase(deleteContact.pending, (state, action) => {
state.isLoading = true;
})
Expand All @@ -64,55 +53,3 @@ const contactSlice = createSlice({
});

export const contactsReducer = contactSlice.reducer;



// import { createSlice } from '@reduxjs/toolkit';
// import { fetchAllContacts, addContact, deleteContact } from './operations';

// const handlePending = state => {
// //console.log('handlePending :', state.isLoading)
// state.isLoading = true;
// };

// const handleRejected = (state, action) => {
// state.isLoading = false;
// state.error = action.payload;
// };


// const contactSlice = createSlice({
// name: 'contacts',
// initialState: {
// items: [],
// isLoading: false,
// error: null,
// },
// extraReducers: {
// [fetchAllContacts.pending]: handlePending,
// [addContact.pending]: handlePending,
// [deleteContact.pending]: handlePending,

// [fetchAllContacts.rejected]: handleRejected,
// [addContact.rejected]: handleRejected,
// [deleteContact.rejected]: handleRejected,

// [fetchAllContacts.fulfilled](state, action) {
// state.isLoading = false;
// state.error = null;
// state.items = action.payload;
// },
// [addContact.fulfilled](state, action) {
// state.isLoading = false;
// state.error = null;
// state.items.push(action.payload);
// },
// [deleteContact.fulfilled](state, action) {
// state.isLoading = false;
// state.error = null;
// state.items = state.items.filter(contact => contact.id !== action.payload.id);
// },
// },
// });

// export const contactsReducer = contactSlice.reducer;
43 changes: 0 additions & 43 deletions src/redux/operations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const fetchAllContacts = createAsyncThunk(
async (_, thunkAPI) => {
try {
const response = await axios.get('/contacts');
// console.log('oper fetch :', response.data);
return response.data;
} catch (e) {
return thunkAPI.rejectWithValue(e.message);
Expand Down Expand Up @@ -42,45 +41,3 @@ export const deleteContact = createAsyncThunk(
}
}
);



// import axios from "axios";
// import { createAsyncThunk } from '@reduxjs/toolkit';

// axios.defaults.baseURL = "https://64b1a2bf062767bc48267982.mockapi.io/api/v1/";

// export const fetchAllContacts = createAsyncThunk(
// 'contacts/fetchAll',
// async (_, thunkAPI) => {
// try {
// const response = await axios.get('/contacts');
// console.log('oper fetch :', response.data);
// return response.data;
// } catch (e) {
// return thunkAPI.rejectWithValue(e.message);
// }
// }
// );
// export const addContact = createAsyncThunk(
// 'contacts/addContact',
// async (dataUser, thunkAPI) => {
// try {
// const response = await axios.post('/contacts', dataUser);
// return response.data;
// } catch (e) {
// return thunkAPI.rejectWithValue(e.message);
// }
// }
// );
// export const deleteContact = createAsyncThunk(
// 'contacts/deleteContact',
// async (id, thunkAPI) => {
// try {
// const response = await axios.delete(`/contacts/${id}`);
// return response.data;
// } catch (e) {
// return thunkAPI.rejectWithValue(e.message);
// }
// }
// );
11 changes: 0 additions & 11 deletions src/redux/store.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export const store = configureStore({
reducer: {
auth: persistReducer(authPersistConfig, authReducer),
contacts: contactsReducer,

// !!!!!!!! Убрала s в filrer
filter: filtersReducer,
},
middleware: getDefaultMiddleware =>
Expand All @@ -40,13 +38,4 @@ export const store = configureStore({
export const persistor = persistStore(store);


// import { configureStore } from "@reduxjs/toolkit";
// import { filtersReducer } from './filterSlice';
// import { contactsReducer } from './contactsSlice';

// export const store = configureStore({
// reducer: {
// filters: filtersReducer,
// contacts: contactsReducer,
// },
// });

0 comments on commit 7de9684

Please sign in to comment.