Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1917 Rev 1918
Línea 1... Línea 1...
1
import React, { useCallback, useState } from 'react'
1
import React, { useCallback, useState } from 'react'
2
import { useSelector } from 'react-redux'
2
import { useSelector } from 'react-redux'
3
import { Box } from '@mui/material'
3
import { Box } from '@mui/material'
4
import BootstrapModal from 'react-bootstrap/Modal'
4
import BootstrapModal from 'react-bootstrap/Modal'
Línea 5... Línea -...
5
 
-
 
6
import { isPromise } from '@app/utils'
-
 
7
 
5
 
8
import Button from '../buttons/Buttons'
6
import Button from '../buttons/Buttons'
Línea 9... Línea 7...
9
import Spinner from '../Spinner'
7
import Spinner from '../Spinner'
Línea 28... Línea 26...
28
}) => {
26
}) => {
29
  const [loading, setLoading] = useState(false)
27
  const [loading, setLoading] = useState(false)
30
  const labels = useSelector(({ intl }) => intl.labels)
28
  const labels = useSelector(({ intl }) => intl.labels)
Línea 31... Línea 29...
31
 
29
 
32
  const handleAccept = useCallback(() => {
30
  const handleAccept = useCallback(() => {
Línea 33... Línea -...
33
    const enableLoading = isPromise(onAccept)
-
 
34
 
-
 
35
    if (enableLoading) {
31
    if (!onAccept) return
36
      setLoading(true)
-
 
37
      onAccept().finally(() =>
-
 
38
        setLoading((val) => {
-
 
39
          console.log(val)
-
 
40
          return false
-
 
41
        })
-
 
42
      )
32
 
-
 
33
    if (!onAccept().finally) {
43
    } else {
34
      onAccept()
-
 
35
      return
-
 
36
    }
44
      onAccept()
37
 
-
 
38
    setLoading(true)
Línea 45... Línea 39...
45
    }
39
    onAccept().finally(() => setLoading(false))
46
  }, [onAccept, setLoading, loading])
40
  }, [onAccept])
47
 
41
 
48
  return (
42
  return (