feat: add admin management page and types
- Implemented the admin management page with a table displaying admin details. - Created the Administrador type definition for better type safety. - Added SubmitResponse type for handling submission responses. - Included placeholder components for form card previews.
This commit is contained in:
@@ -14,4 +14,46 @@ const axiosInstance = axios.create({
|
||||
},
|
||||
});
|
||||
|
||||
// Request interceptor para agregar el token de autenticación
|
||||
axiosInstance.interceptors.request.use(
|
||||
(config) => {
|
||||
// Obtener el token del sessionStorage
|
||||
const token = sessionStorage.getItem('token');
|
||||
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
// Response interceptor para manejar errores de autenticación
|
||||
axiosInstance.interceptors.response.use(
|
||||
(response) => {
|
||||
return response;
|
||||
},
|
||||
(error) => {
|
||||
// Si el token ha expirado o es inválido (401)
|
||||
if (error.response?.status === 401) {
|
||||
// Limpiar el sessionStorage
|
||||
sessionStorage.removeItem('token');
|
||||
sessionStorage.removeItem('user');
|
||||
|
||||
// Redireccionar al login solo si no estamos ya en la página de login
|
||||
if (
|
||||
typeof window !== 'undefined' &&
|
||||
!window.location.pathname.includes('/login')
|
||||
) {
|
||||
window.location.href = '/login';
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
export default axiosInstance;
|
||||
|
||||
Reference in New Issue
Block a user