Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2303 | Rev 2306 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2303 Rev 2304
Línea 5... Línea 5...
5
function useNavbar() {
5
function useNavbar() {
6
  const { data: menuData } = useFetch('/helpers/menu')
6
  const { data: menuData } = useFetch('/helpers/menu')
7
  const { data: session, refetch } = useFetch(menuData?.routeCheckSession)
7
  const { data: session, refetch } = useFetch(menuData?.routeCheckSession)
Línea 8... Línea 8...
8
 
8
 
9
  const memoMenu = useMemo(() => {
9
  const memoMenu = useMemo(() => {
10
    const menu = menuData?.menu
-
 
11
    const newMenu = menu?.map((item) => {
-
 
12
      if (menu.label !== 'Comunicación') return item
-
 
13
 
-
 
14
      const newItem = item.childs.map((child) => {
-
 
15
        if (child.label === 'Notificaciones') {
-
 
16
          return { ...child, count: session?.total_notifications }
-
 
17
        }
-
 
18
 
-
 
19
        if (child.label === 'Inmail') {
-
 
20
          return { ...child, count: session?.total_messages }
-
 
Línea -... Línea 10...
-
 
10
    if (!menuData.menu) return []
-
 
11
 
-
 
12
    const menu = structuredClone(menuData?.menu)
-
 
13
    const comunicationIndex = menu.findIndex(
-
 
14
      (item) => item.label === 'Comunicación'
-
 
15
    )
-
 
16
    const comunication = menu[comunicationIndex]
-
 
17
 
-
 
18
    const newComunicationChilds = comunication.childs.map((child) => {
21
        }
19
      if (child.label === 'Notificaciones') {
-
 
20
        return { ...child, count: session?.total_notifications }
-
 
21
      }
-
 
22
 
22
 
23
      if (child.label === 'Inmail') {
Línea 23... Línea 24...
23
        return item
24
        return { ...child, count: session?.total_messages }
24
      })
25
      }
Línea -... Línea 26...
-
 
26
 
25
 
27
      return child
Línea -... Línea 28...
-
 
28
    })
-
 
29
 
26
      return newItem
30
    comunication.childs = newComunicationChilds
27
    })
31
    menu[comunicationIndex] = comunication
Línea 28... Línea 32...
28
 
32
 
29
    console.log(newMenu)
33
    console.log(menu)