diff --git a/src/components/Nav.jsx b/src/components/Nav.jsx
index 283b0e0..58f63cb 100644
--- a/src/components/Nav.jsx
+++ b/src/components/Nav.jsx
@@ -1,13 +1,44 @@
import React from "react";
import {Link} from "react-router-dom";
import './Nav.scss';
+import {useStateValue} from '../services/State'
-export const Nav = () => (
-
-)
+export const Nav = () => {
+ const [context, dispatch] = useStateValue();
+
+ const handleLogin = () => dispatch({type: 'login', user: {auth: true}})
+ const handleLogout = () => dispatch({type: 'logout', user: {auth: false}})
+
+ const showLogin = () => {
+ return context.user.auth === false;
+ }
+
+ const buttons = () => {
+ if (showLogin()) {
+ return
+ -
+
+
+ -
+ Registrate
+
+
+ }else {
+ return
+ -
+ Bienvenido
+
+ -
+
+
+
+ }
+ }
+
+ return (
+
+ )
+}
diff --git a/src/index.jsx b/src/index.jsx
index f8297f3..2d8d1ef 100644
--- a/src/index.jsx
+++ b/src/index.jsx
@@ -62,16 +62,8 @@ const App = () => (
);
const AppWithState = () => {
- const initialState = {theme: {primary: 'green'}};
-
- const reducer = (state, action) => {
- switch (action.type) {
- default: return state;
- }
- };
-
return (
-
+
);
diff --git a/src/services/State.jsx b/src/services/State.jsx
index 76febae..7a6b60b 100644
--- a/src/services/State.jsx
+++ b/src/services/State.jsx
@@ -1,11 +1,34 @@
import React, {createContext, useContext, useReducer} from 'react';
+const initialState = {user: {auth: false}};
+
+const reducer = (state, action) => {
+ console.log(state, action);
+
+ switch (action.type) {
+ case 'login':
+ return {
+ ...state,
+ user: action.user
+ }
+ case 'logout':
+ return {
+ ...state,
+ user: action.user
+ }
+ default: return state;
+ }
+};
+
export const StateContext = createContext(null);
-export const StateProvider = ({reducer, initialState, children}) => (
-
- {children}
-
-);
+export const StateProvider = ({children}) => {
+
+ return (
+
+ {children}
+
+ );
+}
export const useStateValue = () => useContext(StateContext);