Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3416 Rev 3432
Línea 1... Línea 1...
1
import { useMemo } from "react";
1
import { useEffect, useMemo } from 'react'
Línea 2... Línea 2...
2
 
2
 
Línea 3... Línea 3...
3
import { useFetch } from "@hooks";
3
import { useFetch } from '@hooks'
4
 
4
 
-
 
5
export function useNavbar() {
-
 
6
  const { data: menuData } = useFetch('/helpers/menu')
-
 
7
  const {
-
 
8
    data: session,
5
export function useNavbar() {
9
    refetch,
Línea 6... Línea 10...
6
  const { data: menuData } = useFetch("/helpers/menu");
10
    isLoading
7
  const { data: session } = useFetch(menuData?.routeCheckSession);
11
  } = useFetch(menuData?.routeCheckSession)
Línea 8... Línea 12...
8
 
12
 
9
  const memoMenu = useMemo(() => {
13
  const memoMenu = useMemo(() => {
10
    if (!menuData.menu) return [];
14
    if (!menuData.menu) return []
11
 
15
 
12
    const menu = structuredClone(menuData?.menu);
16
    const menu = structuredClone(menuData?.menu)
Línea 13... Línea 17...
13
    const comunicationIndex = menu.findIndex(
17
    const comunicationIndex = menu.findIndex(
14
      (item) => item.label === "Comunicación"
18
      (item) => item.label === 'Comunicación'
15
    );
19
    )
16
    const comunication = menu[comunicationIndex];
20
    const comunication = menu[comunicationIndex]
Línea 17... Línea 21...
17
 
21
 
18
    const newComunicationChilds = comunication.childs.map((child) => {
22
    const newComunicationChilds = comunication.childs.map((child) => {
19
      if (child.label === "Notificaciones") {
23
      if (child.label === 'Notificaciones') {
Línea 20... Línea 24...
20
        return { ...child, count: session?.total_notifications };
24
        return { ...child, count: session?.total_notifications }
21
      }
25
      }
Línea 22... Línea 26...
22
 
26
 
23
      if (child.label === "Inmail") {
27
      if (child.label === 'Inmail') {
Línea 24... Línea 28...
24
        return { ...child, count: session?.total_messages };
28
        return { ...child, count: session?.total_messages }
25
      }
29
      }
-
 
30
 
-
 
31
      return child
-
 
32
    })
-
 
33
 
-
 
34
    comunication.childs = newComunicationChilds
-
 
35
    menu[comunicationIndex] = comunication
-
 
36
 
-
 
37
    return menu
-
 
38
  }, [menuData, session])
-
 
39
 
Línea 26... Línea 40...
26
 
40
  useEffect(() => {
27
      return child;
41
    const sessionInterval = setTimeout(() => {
28
    });
42
      !isLoading && refetch()
29
 
43
    }, 3000)
30
    comunication.childs = newComunicationChilds;
44
 
31
    menu[comunicationIndex] = comunication;
45
    return () => {