2020-12-19 04:22:38 +02:00
|
|
|
import React, { useReducer, useMemo } from "react";
|
|
|
|
import Main from "./layout/Main";
|
2020-12-19 03:38:04 +02:00
|
|
|
import { initialState } from "../state/initialState";
|
2020-12-19 04:22:38 +02:00
|
|
|
import {
|
|
|
|
reducer,
|
|
|
|
dispatchActions as reducerDispatchActions
|
|
|
|
} from "../state/reducer";
|
|
|
|
import {
|
|
|
|
ApplicationStateContext,
|
|
|
|
ApplicationDispatchContext
|
|
|
|
} from "../state/ApplicationContexts";
|
2020-12-24 04:42:32 +02:00
|
|
|
import { ToastContainer, Slide } from "react-toastify";
|
|
|
|
import "react-toastify/dist/ReactToastify.css";
|
2020-12-16 03:09:24 +02:00
|
|
|
|
2020-12-19 03:38:04 +02:00
|
|
|
const App = () => {
|
2020-12-19 04:22:38 +02:00
|
|
|
//il fac pt test dar e gresit. daca va fi un singur state se va redesena toata aplicatia de fiecare data.
|
|
|
|
//testeaza ca se redeseneaza de fiecare data
|
2020-12-19 03:38:04 +02:00
|
|
|
const [state, dispatch] = useReducer(reducer, initialState);
|
2020-12-19 04:22:38 +02:00
|
|
|
const dispatchActions = useMemo(() => reducerDispatchActions(dispatch), [
|
|
|
|
dispatch
|
|
|
|
]);
|
2020-12-19 02:08:36 +02:00
|
|
|
|
2020-12-16 03:09:24 +02:00
|
|
|
return (
|
2020-12-24 04:42:32 +02:00
|
|
|
<>
|
|
|
|
<ApplicationStateContext.Provider value={state}>
|
|
|
|
<ApplicationDispatchContext.Provider value={dispatchActions}>
|
|
|
|
<Main />
|
|
|
|
</ApplicationDispatchContext.Provider>
|
|
|
|
</ApplicationStateContext.Provider>
|
|
|
|
<ToastContainer
|
2020-12-24 13:16:53 +02:00
|
|
|
position="bottom-right"
|
2020-12-24 04:42:32 +02:00
|
|
|
transition={Slide}
|
|
|
|
autoClose={3000}
|
|
|
|
hideProgressBar={false}
|
|
|
|
newestOnTop={false}
|
|
|
|
closeOnClick
|
|
|
|
rtl={false}
|
|
|
|
pauseOnFocusLoss
|
|
|
|
draggable
|
|
|
|
pauseOnHover
|
|
|
|
limit={5}
|
|
|
|
/>
|
|
|
|
</>
|
2020-12-16 03:09:24 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-12-19 03:38:04 +02:00
|
|
|
export default App;
|