From: charleswrayjr Date: Sat, 13 Sep 2025 22:59:41 +0000 (-0500) Subject: Cleaning up code warnings and errors. X-Git-Url: https://git.phasecustomsoft.com/static/git-logo.png?a=commitdiff_plain;h=b65ddfe724db58abe15dcc53dc0a4ee95222d876;p=phs-admin.git Cleaning up code warnings and errors. --- diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml new file mode 100644 index 0000000..bbf6451 --- /dev/null +++ b/.idea/dictionaries/project.xml @@ -0,0 +1,7 @@ + + + + ovpn + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 03d9549..3044da6 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,6 +1,17 @@ \ No newline at end of file diff --git a/README.md b/README.md index 58beeac..76e91cf 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc.) right into your project so you have full control over them. All the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. -You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. +You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you could not customize it when you are ready for it. ## Learn More diff --git a/src/app/components/AuthContext.js b/src/app/components/AuthContext.js index 290b9a9..91035fc 100644 --- a/src/app/components/AuthContext.js +++ b/src/app/components/AuthContext.js @@ -2,58 +2,58 @@ * @file Authentication context for user and role data */ -import React, { createContext, useState, useEffect } from 'react'; +import React, { createContext, useEffect, useMemo, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useSnackbar } from 'notistack'; import { AuthService } from '../services/auth'; -export const AuthContext = createContext(); +export const AuthContext = createContext( undefined ); -export const AuthProvider = ({ children }) => { - const [user, setUser] = useState(null); +export const AuthProvider = ( { children } ) => { + const [user, setUser] = useState( null ); const navigate = useNavigate(); const { enqueueSnackbar } = useSnackbar(); - useEffect(() => { - const fetchUser = async () => { - try { - const token = localStorage.getItem('token'); - if (token) { - const response = await AuthService.getCurrentUser(); - setUser(response.user); - } - } catch (error) { - enqueueSnackbar(`Error fetching user: ${error.message}`, { variant: 'error' }); + const fetchUser = useMemo( () => async () => { + try { + const token = localStorage.getItem( 'token' ); + if (token) { + const response = await AuthService.getCurrentUser(); + setUser( response.user ); } - }; - fetchUser(); - }, [enqueueSnackbar]); + } catch (error) { + enqueueSnackbar( `Error fetching user: ${ error.message }`, { variant:'error' } ); + } + }, [enqueueSnackbar] ); + useEffect( () => { + fetchUser().catch(); + }, [enqueueSnackbar, fetchUser] ); - const login = async (email, password) => { + const login = async ( email, password ) => { try { - const response = await AuthService.login(email, password); + const response = await AuthService.login( email, password ); if (response.success) { - localStorage.setItem('token', response.token); - setUser(response.user); - navigate('/'); + localStorage.setItem( 'token', response.token ); + setUser( response.user ); + navigate( '/' ); return true; } return false; } catch (error) { - enqueueSnackbar(`Login error: ${error.message}`, { variant: 'error' }); + enqueueSnackbar( `Login error: ${ error.message }`, { variant:'error' } ); return false; } }; const logout = () => { - localStorage.removeItem('token'); - setUser(null); - navigate('/login'); + localStorage.removeItem( 'token' ); + setUser( null ); + navigate( '/login' ); }; return ( - - {children} + + { children } ); }; \ No newline at end of file diff --git a/tailwind.config.js b/tailwind.config.js index f2b75db..c0f998f 100755 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,5 +1,7 @@ /** @type {import('tailwindcss').Config} */ /* eslint-disable import/no-extraneous-dependencies */ +// noinspection SpellCheckingInspection + const path = require('path'); module.exports = {