diff --git a/website/context/types.js b/website/context/types.js new file mode 100644 index 00000000..4379f0b5 --- /dev/null +++ b/website/context/types.js @@ -0,0 +1 @@ +export const SET_PROGRESS = "SET_PROGRESS"; diff --git a/website/context/user/UserState.js b/website/context/user/UserState.js new file mode 100644 index 00000000..ff1789ac --- /dev/null +++ b/website/context/user/UserState.js @@ -0,0 +1,36 @@ +import React, { useReducer } from "react"; +import UserContext from "./userContext"; +import UserReducer from "./userReducer"; +import { SET_PROGRESS } from "./types"; + +const UserState = props => { + const initialState = { + user: {}, + test: [ + { + case: ["b=5", "b=5;"], + hint: "b should have value of 5", + isCorrect: false + }, + {} + ] + }; + + const [state, dispatch] = useReducer(UserReducer, initialState); + + //set user progress - complete function + + return ( + + {props.children} + + ); +}; + +export default UserState; diff --git a/website/context/user/userContext.js b/website/context/user/userContext.js new file mode 100644 index 00000000..3c81dafd --- /dev/null +++ b/website/context/user/userContext.js @@ -0,0 +1,5 @@ +import { createContext } from "react"; + +const userContext = createContext(); + +export default userContext; diff --git a/website/context/user/userReducer.js b/website/context/user/userReducer.js new file mode 100644 index 00000000..c207642b --- /dev/null +++ b/website/context/user/userReducer.js @@ -0,0 +1,13 @@ +import { SET_PROGRESS } from "..types/"; + +export default function ur(state, action) { + switch (action.type) { + case SET_PROGRESS: + return { + ...state, + user: action.payload + }; + default: + return state; + } +} diff --git a/website/pages/_app.js b/website/pages/_app.js index 1e1cec92..e1af41fc 100644 --- a/website/pages/_app.js +++ b/website/pages/_app.js @@ -1,7 +1,12 @@ -import '../styles/globals.css' +import { UserContext } from "../context/user/userContext"; +import "../styles/globals.css"; function MyApp({ Component, pageProps }) { - return + return ( + + + + ); } -export default MyApp +export default MyApp;