refactor(routes): use react-context to clarify and centralize the management of API routes #12
parent
220ccacdfe
commit
c7909388d1
@ -0,0 +1,19 @@
|
||||
import React, { createContext } from "react";
|
||||
|
||||
export const AppContext = createContext();
|
||||
|
||||
const AppContextProvider = ({ children }) => {
|
||||
const defaultState = {
|
||||
urlServer: process.env.REACT_APP_SERVER_URL,
|
||||
routesServer: {
|
||||
setElection: "election/",
|
||||
getElection: "election/get/:slug",
|
||||
getResultsElection: "election/results/:slug",
|
||||
voteElection: "election/vote/:slug"
|
||||
}
|
||||
};
|
||||
return (
|
||||
<AppContext.Provider value={defaultState}>{children}</AppContext.Provider>
|
||||
);
|
||||
};
|
||||
export default AppContextProvider;
|
Loading…
Reference in new issue