Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 7114 Rev 7116
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react';
1
import React, { useState } from 'react';
2
import { getData } from '../../../helpers/fetchHelpers';
-
 
3
import { Modal, Button } from 'react-bootstrap';
2
import { Modal, Button } from 'react-bootstrap';
4
import axios from 'axios';
3
import axios from 'axios';
Línea 5... Línea 4...
5
 
4
 
6
const SubmitModal = ({
5
const SubmitModal = ({
7
    children,
6
    children,
8
    closeModal = function () { },
7
    closeModal = function () { },
9
    postLink = '',
8
    postLink = '',
10
    submitData = '',
9
    submitData = '',
11
    setValues = function () { }
10
    title = ''
Línea 12... Línea 11...
12
}) => {
11
}) => {
Línea 13... Línea 12...
13
 
12
 
Línea 14... Línea 13...
14
    const [error, setError] = useState('');
13
    const [error, setError] = useState('');
15
 
14
 
16
    const onSubmit = () => {
15
    const onSubmit = () => {
17
 
16
 
18
        axios.post(postLink, submitData)
17
        axios.post(postLink, submitData)
-
 
18
            .then(({ data }) => {
19
            .then(({ data }) => {
19
                if (!data.success) {
20
                if (!data.success) {
-
 
21
                    return setError(Object.values(data.data)[0])
-
 
22
                }
20
                    return console.log(Object.values(data.data)[0])
23
                setValues(Object.values(data.data)[0])
21
                }
24
            })
22
 
25
            .finally(() => {
23
                console.log(data.data)
26
                setError(null)
24
                setError(null)
Línea 27... Línea 25...
27
                closeModal()
25
                closeModal()
28
            })
26
            })
29
            .catch((err) => setError(err))
27
            .catch((err) => setError(err))
30
    };
28
    };
31
 
29
 
32
    return (
30
    return (
-
 
31
        <Modal size="lg" show onHide={closeModal}>
-
 
32
            <Modal.Header closeButton>
33
        <Modal size="lg" show onHide={closeModal}>
33
                <Modal.Title>{title}</Modal.Title>
-
 
34
            </Modal.Header>
-
 
35
            <Modal.Body>
34
            <Modal.Header closeButton>
36
                <div className='form-group'>
35
                <Modal.Title>Cambiar</Modal.Title>
37
                    <label className="form-label">{title}</label>
36
            </Modal.Header>
38
                    {children}
37
            <Modal.Body>
39
                </div>
38
                {children}
40
                {error && <p>{error}</p>}