Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1906 Rev 1908
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React, { 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 -... Línea 5...
-
 
5
 
-
 
6
import { isPromise } from '@app/utils'
5
 
7
 
6
import Button from '../buttons/Buttons'
8
import Button from '../buttons/Buttons'
Línea 7... Línea 9...
7
import Spinner from '../Spinner'
9
import Spinner from '../Spinner'
8
 
-
 
Línea 9... Línea 10...
9
import styles from './Modal.module.scss'
10
 
10
import { isPromise } from '@app/utils'
11
import styles from './Modal.module.scss'
11
 
12
 
12
const Modal = ({
13
const Modal = ({
Línea 28... Línea 29...
28
  const [loading, setLoading] = useState(false)
29
  const [loading, setLoading] = useState(false)
29
  const labels = useSelector(({ intl }) => intl.labels)
30
  const labels = useSelector(({ intl }) => intl.labels)
Línea 30... Línea 31...
30
 
31
 
31
  const handleAccept = () => {
32
  const handleAccept = () => {
32
    const enableLoading = isPromise(onAccept)
-
 
Línea 33... Línea 33...
33
    console.log(enableLoading)
33
    const enableLoading = isPromise(onAccept)
34
 
34
 
35
    if (!enableLoading) {
35
    if (!enableLoading) {
36
      onAccept()
36
      onAccept()
Línea 37... Línea 37...
37
      return
37
      return
-
 
38
    }
38
    }
39
 
39
 
40
    setLoading(true)
Línea 40... Línea 41...
40
    setLoading(true)
41
    console.log(loading)
41
    onAccept().finally(() => setLoading(false))
42
    onAccept().finally(() => setLoading(false))
Línea 55... Línea 56...
55
        <BootstrapModal.Title>{title}</BootstrapModal.Title>
56
        <BootstrapModal.Title>{title}</BootstrapModal.Title>
56
      </BootstrapModal.Header>
57
      </BootstrapModal.Header>
Línea 57... Línea 58...
57
 
58
 
58
      <BootstrapModal.Body className={styles['modal-content']}>
59
      <BootstrapModal.Body className={styles['modal-content']}>
59
        {children}
60
        {children}
60
        {loading && (
61
        {loading ? (
61
          <Box
62
          <Box
62
            sx={{
63
            sx={{
63
              position: 'absolute',
64
              position: 'absolute',
64
              zIndex: 50,
65
              zIndex: 1250,
65
              width: '100%',
66
              width: '100%',
66
              height: '100%',
67
              height: '100%',
67
              top: 0,
68
              top: 0,
68
              left: 0,
69
              left: 0,
69
              display: 'grid',
70
              display: 'grid',
70
              placeItems: 'center'
71
              placeItems: 'center'
71
            }}
72
            }}
72
          >
73
          >
73
            <Spinner />
74
            <Spinner />
74
          </Box>
75
          </Box>
75
        )}
76
        ) : null}
Línea 76... Línea 77...
76
      </BootstrapModal.Body>
77
      </BootstrapModal.Body>
77
 
78
 
78
      {showFooter ? (
79
      {showFooter ? (
79
        <BootstrapModal.Footer className={styles['modal-footer']}>
80
        <BootstrapModal.Footer className={styles['modal-footer']}>
80
          <Button variant='primary' onClick={handleAccept}>
81
          <Button variant='primary' onClick={handleAccept} disabled={loading}>
81
            {labelAccept || labels.accept}
82
            {labelAccept || labels.accept}
82
          </Button>
83
          </Button>
83
          <Button variant='secondary' onClick={onReject || onClose}>
84
          <Button variant='secondary' onClick={onReject || onClose}>