Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 7106 Rev 7107
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react';
1
import React, { useEffect, useState } from 'react';
2
import { getData } from '../../../helpers/fetchHelpers';
-
 
3
import { Modal, Button } from 'react-bootstrap';
2
import SubmitModal from './SubmitModal';
-
 
3
 
Línea 4... Línea 4...
4
 
4
 
5
const StatusModal = ({
-
 
6
    children,
5
const StatusModal = ({
7
    data = '',
-
 
8
    setData = function () { },
6
    modalData = '',
9
    getLink = '',
-
 
10
    postLink = '',
7
    dataLink = '',
11
    closeModal = function () { }
8
    closeModal = function () { }
Línea 12... Línea 9...
12
}) => {
9
}) => {
-
 
10
 
-
 
11
    const [error, setError] = useState('');
Línea 13... Línea 12...
13
 
12
    const [data, setData] = useState(modalData);
14
    const [error, setError] = useState('');
-
 
15
 
-
 
Línea 16... Línea 13...
16
    const onSubmit = (data) => {
13
    const [values, setValues] = useState('');
17
        console.log('Submit');
14
 
18
    };
15
    const defaultValues = [{ label: "Activo", value: "a" }, { label: "Inactivo", value: "i" }]
19
 
16
 
20
    useEffect(() => {
17
    useEffect(() => {
Línea 21... Línea 18...
21
        getData(getLink)
18
        if(values.status && values.status === "i"){
22
            .then(results => console.log(results))
-
 
23
            .catch(err => setError(err))
-
 
24
    }, []);
-
 
25
 
-
 
26
    return (
19
            defaultValues.reverse()
27
        <Modal size="lg" show onHide={closeModal}>
-
 
28
            <Modal.Header closeButton>
20
        }
29
                <Modal.Title>Cambiar</Modal.Title>
-
 
30
            </Modal.Header>
-
 
31
            <Modal.Body>
-
 
32
                <form onSubmit={onSubmit}>
-
 
33
                    {children}
-
 
34
                    {/* {
21
    }, [values]);
35
                            status.map((item, index) => (
-
 
36
                                <option
-
 
37
                                    key={index}
22
 
38
                                    value={item}
23
    return (
39
                                >
24
        <SubmitModal
40
                                    {item}
-
 
41
                                </option>
25
            submitData={data}
42
                            ))
26
            setValues={setValues}
43
                        } */}
27
            dataLink={dataLink}
44
                </form>
28
            closeModal={closeModal}
45
            </Modal.Body>
29
        >
46
            <Modal.Footer>
30
            <select
47
                <Button
31
                name="status"
48
                    variant="primary"
32
                onChange={(e) => setData(e.target.value)}
49
                    type="submit"
33
                defaultValue={modalData}
50
                >
34
            >
51
                    Enviar
35
                {
52
                </Button>
36
                    defaultValues.map(({ value, label }) => (
53
                <Button variant="danger" onClick={closeModal}>
37
                        <option value={value}>{label}</option>
54
                    Cancelar
38
                    ))
Línea 55... Línea 39...
55
                </Button>
39
                }
56
            </Modal.Footer>
40
            </select>