chore: adding packages for login
This commit is contained in:
		
							
								
								
									
										77
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										77
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -14,9 +14,12 @@ | |||||||
|         "@mui/icons-material": "^7.1.0", |         "@mui/icons-material": "^7.1.0", | ||||||
|         "@mui/material": "^7.1.0", |         "@mui/material": "^7.1.0", | ||||||
|         "@mui/x-data-grid": "^8.5.0", |         "@mui/x-data-grid": "^8.5.0", | ||||||
|  |         "@react-oauth/google": "^0.12.2", | ||||||
|  |         "jwt-decode": "^4.0.0", | ||||||
|         "notistack": "^3.0.2", |         "notistack": "^3.0.2", | ||||||
|         "react": "^19.1.0", |         "react": "^19.1.0", | ||||||
|         "react-dom": "^19.1.0" |         "react-dom": "^19.1.0", | ||||||
|  |         "react-router-dom": "^7.7.1" | ||||||
|       }, |       }, | ||||||
|       "devDependencies": { |       "devDependencies": { | ||||||
|         "@eslint/js": "^9.25.0", |         "@eslint/js": "^9.25.0", | ||||||
| @@ -1500,6 +1503,16 @@ | |||||||
|         "url": "https://opencollective.com/popperjs" |         "url": "https://opencollective.com/popperjs" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/@react-oauth/google": { | ||||||
|  |       "version": "0.12.2", | ||||||
|  |       "resolved": "https://registry.npmjs.org/@react-oauth/google/-/google-0.12.2.tgz", | ||||||
|  |       "integrity": "sha512-d1GVm2uD4E44EJft2RbKtp8Z1fp/gK8Lb6KHgs3pHlM0PxCXGLaq8LLYQYENnN4xPWO1gkL4apBtlPKzpLvZwg==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "peerDependencies": { | ||||||
|  |         "react": ">=16.8.0", | ||||||
|  |         "react-dom": ">=16.8.0" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/@rollup/rollup-android-arm-eabi": { |     "node_modules/@rollup/rollup-android-arm-eabi": { | ||||||
|       "version": "4.40.2", |       "version": "4.40.2", | ||||||
|       "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.2.tgz", |       "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.2.tgz", | ||||||
| @@ -3278,6 +3291,15 @@ | |||||||
|         "node": ">=6" |         "node": ">=6" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/jwt-decode": { | ||||||
|  |       "version": "4.0.0", | ||||||
|  |       "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", | ||||||
|  |       "integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=18" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/keyv": { |     "node_modules/keyv": { | ||||||
|       "version": "4.5.4", |       "version": "4.5.4", | ||||||
|       "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", |       "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", | ||||||
| @@ -3870,6 +3892,53 @@ | |||||||
|         "node": ">=0.10.0" |         "node": ">=0.10.0" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/react-router": { | ||||||
|  |       "version": "7.7.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.7.1.tgz", | ||||||
|  |       "integrity": "sha512-jVKHXoWRIsD/qS6lvGveckwb862EekvapdHJN/cGmzw40KnJH5gg53ujOJ4qX6EKIK9LSBfFed/xiQ5yeXNrUA==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "dependencies": { | ||||||
|  |         "cookie": "^1.0.1", | ||||||
|  |         "set-cookie-parser": "^2.6.0" | ||||||
|  |       }, | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=20.0.0" | ||||||
|  |       }, | ||||||
|  |       "peerDependencies": { | ||||||
|  |         "react": ">=18", | ||||||
|  |         "react-dom": ">=18" | ||||||
|  |       }, | ||||||
|  |       "peerDependenciesMeta": { | ||||||
|  |         "react-dom": { | ||||||
|  |           "optional": true | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "node_modules/react-router-dom": { | ||||||
|  |       "version": "7.7.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.7.1.tgz", | ||||||
|  |       "integrity": "sha512-bavdk2BA5r3MYalGKZ01u8PGuDBloQmzpBZVhDLrOOv1N943Wq6dcM9GhB3x8b7AbqPMEezauv4PeGkAJfy7FQ==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "dependencies": { | ||||||
|  |         "react-router": "7.7.1" | ||||||
|  |       }, | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=20.0.0" | ||||||
|  |       }, | ||||||
|  |       "peerDependencies": { | ||||||
|  |         "react": ">=18", | ||||||
|  |         "react-dom": ">=18" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "node_modules/react-router/node_modules/cookie": { | ||||||
|  |       "version": "1.0.2", | ||||||
|  |       "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", | ||||||
|  |       "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==", | ||||||
|  |       "license": "MIT", | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=18" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/react-transition-group": { |     "node_modules/react-transition-group": { | ||||||
|       "version": "4.4.5", |       "version": "4.4.5", | ||||||
|       "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", |       "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", | ||||||
| @@ -4061,6 +4130,12 @@ | |||||||
|         "node": ">= 18" |         "node": ">= 18" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/set-cookie-parser": { | ||||||
|  |       "version": "2.7.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz", | ||||||
|  |       "integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==", | ||||||
|  |       "license": "MIT" | ||||||
|  |     }, | ||||||
|     "node_modules/setprototypeof": { |     "node_modules/setprototypeof": { | ||||||
|       "version": "1.2.0", |       "version": "1.2.0", | ||||||
|       "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", |       "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", | ||||||
|   | |||||||
| @@ -16,9 +16,12 @@ | |||||||
|     "@mui/icons-material": "^7.1.0", |     "@mui/icons-material": "^7.1.0", | ||||||
|     "@mui/material": "^7.1.0", |     "@mui/material": "^7.1.0", | ||||||
|     "@mui/x-data-grid": "^8.5.0", |     "@mui/x-data-grid": "^8.5.0", | ||||||
|  |     "@react-oauth/google": "^0.12.2", | ||||||
|  |     "jwt-decode": "^4.0.0", | ||||||
|     "notistack": "^3.0.2", |     "notistack": "^3.0.2", | ||||||
|     "react": "^19.1.0", |     "react": "^19.1.0", | ||||||
|     "react-dom": "^19.1.0" |     "react-dom": "^19.1.0", | ||||||
|  |     "react-router-dom": "^7.7.1" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@eslint/js": "^9.25.0", |     "@eslint/js": "^9.25.0", | ||||||
|   | |||||||
							
								
								
									
										32
									
								
								src/context/AuthContext.jsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/context/AuthContext.jsx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | |||||||
|  | import { createContext, useContext, useState, useEffect } from 'react'; | ||||||
|  |  | ||||||
|  | const AuthContext = createContext(); | ||||||
|  |  | ||||||
|  | export function AuthProvider({ children }) { | ||||||
|  |   const [user, setUser] = useState(null); | ||||||
|  |  | ||||||
|  |   useEffect(() => { | ||||||
|  |     const storedUser = localStorage.getItem('user'); | ||||||
|  |     if (storedUser) setUser(JSON.parse(storedUser)); | ||||||
|  |   }, []); | ||||||
|  |  | ||||||
|  |   const login = (userData) => { | ||||||
|  |     setUser(userData); | ||||||
|  |     localStorage.setItem('user', JSON.stringify(userData)); | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   const logout = () => { | ||||||
|  |     setUser(null); | ||||||
|  |     localStorage.removeItem('user'); | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   return ( | ||||||
|  |     <AuthContext.Provider value={{ user, login, logout }}> | ||||||
|  |       {children} | ||||||
|  |     </AuthContext.Provider> | ||||||
|  |   ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | export function useAuth() { | ||||||
|  |   return useContext(AuthContext); | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user
	 Rodolfo Ruiz
					Rodolfo Ruiz