Proyectos de Subversion LeadersLinked - SPA

Rev

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

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