Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/redux/actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import users from "../../bd.json"
import users from "../bd.json"

export const getUsers = ()=>{
return{
Expand Down
39 changes: 24 additions & 15 deletions src/redux/reducer.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import {
GET_USER_BY_NAME,
GET_USER_BY_ID,
GET_POST_BY_NAME,
GET_POST_BY_ID,
GET_ALL_TAGS,
} from "./actions";

const initialState = {
favorites: [],
posts: [],
users: []
}
favorites: [],
posts: [],
users: [],
};

const reducer = (state = initialState, {type, payload}) => {
switch (type) {
case "GET_USERS":
return{
...state,
users: payload
}
const reducer = (state = initialState, { type, payload }) => {
switch (type) {
case "GET_USERS":
return {
...state,
users: payload,
};

default: return {...state};
}
}
default:
return { ...state };
}
};

export default reducer
export default reducer;
5 changes: 5 additions & 0 deletions src/redux/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const GET_USER_BY_NAME = 'GET_USER_BY_NAME';
export const GET_USER_BY_ID = 'GET_USER_BY_ID';
export const GET_POST_BY_NAME = 'GET_POST_BY_NAME';
export const GET_POST_BY_ID = 'GET_POST_BY_ID';
export const GET_ALL_TAGS = 'GET_ALL_TAGS';