= (props) => {
DSAuth.Validate()
.then((response) => {
dispatch(populateUserProfile(''))
- window.location.href = 'http://localhost:3000/login'
+ window.location.href = 'http://localhost:3000'
})
.catch((e: Error) => {
console.log('Debe de salir al login')
- window.location.href = 'http://localhost:3000/login'
+ window.location.href = 'http://localhost:3000'
})
}
}
diff --git a/src/Components/Navbar/Navbar.tsx b/src/Components/Navbar/Navbar.tsx
index 975e611..1bccf0e 100644
--- a/src/Components/Navbar/Navbar.tsx
+++ b/src/Components/Navbar/Navbar.tsx
@@ -1,17 +1,73 @@
-import { Container, Navbar } from 'react-bootstrap'
+import { useEffect, useState } from 'react'
+import { Container, Nav, Navbar, NavDropdown } from 'react-bootstrap'
import { useSelector } from 'react-redux'
import { Link } from 'react-router-dom'
+import IMenu from '../../Interfaces/Auth/IMenu'
import { RootState } from '../../store/store'
+interface Isubmenu {
+ menu: IMenu[]
+ descripcion: string
+}
+
+function Submenu({ descripcion, menu }: Isubmenu) {
+ return (
+
+
+ {menu.map((item, index) => {
+ return (
+
+ {item.descripcion}
+
+ )
+ })}
+
+
+ )
+}
+
function AOLNavbar() {
+ //const MenuItems = useSelector((state: RootState) => state.MenuItems.MenuItems)
+ let _menu: IMenu[] = []
+ let mn: string = ''
+ const [menu, setMenu] = useState(localStorage.getItem('menu') ? localStorage.getItem('menu') : '')
+ const [mainMenu, setMainMenu] = useState(_menu)
const UserLogued = useSelector((state: RootState) => state.UserProfile.UserProfile.logueado)
const User = useSelector((state: RootState) => state.UserProfile.UserProfile.User)
+ useEffect(() => {
+ if (menu) {
+ setMainMenu(JSON.parse(menu))
+ }
+ }, [menu])
+
return (
AOL
+
+
+
+
{UserLogued ? (
diff --git a/src/store/features/Auth/MenuItemsSlice.ts b/src/store/features/Auth/MenuItemsSlice.ts
index 056895d..1055588 100644
--- a/src/store/features/Auth/MenuItemsSlice.ts
+++ b/src/store/features/Auth/MenuItemsSlice.ts
@@ -8,8 +8,12 @@ export const MenuItemsSlice = createSlice({
initialState: initialState,
reducers: {
populateMenuItems : (state, action: PayloadAction) => {
- state.MenuItems = [{ id:0, descripcion:'', padreId:0, posicion:0, url:''}]
- state.MenuItems.push(... action.payload)
+ //alert('populate IMenu '+JSON.stringify(action.payload))
+ // state.MenuItems = [{ id:0, descripcion:'', padreId:0, posicion:0, url:''}]
+ // state.MenuItems.push(... action.payload)
+ action.payload.forEach(element => state.MenuItems.push(element));
+ /* if (action.payload.length>0)
+ state.MenuItems.push(... action.payload) */
},
},
})