Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 8472 Rev 8473
Línea 9... Línea 9...
9
    closeModal,
9
    closeModal,
10
    editUrl,
10
    editUrl,
11
    action
11
    action
12
}) => {
12
}) => {
Línea 13... Línea 13...
13
 
13
 
14
    const { handleSubmit, register } = useForm()
14
    const { handleSubmit, register, setValue } = useForm()
15
    const [error, setError] = useState(null);
15
    const [error, setError] = useState(null);
-
 
16
    const [industries, setIndustries] = useState([]);
Línea 16... Línea 17...
16
    const [industries, setIndustries] = useState([]);
17
    const [currentIndustry, setCurrentIndustry] = useState("");
17
 
18
 
18
    const onSubmit = ({ industry }) => {
19
    const onSubmit = ({ industry }) => {
Línea 33... Línea 34...
33
            .catch((err) => console.log(err))
34
            .catch((err) => console.log(err))
34
    }
35
    }
Línea 35... Línea 36...
35
 
36
 
36
    useEffect(() => {
37
    useEffect(() => {
37
        getData(editUrl)
38
        getData(editUrl)
38
            .then(({ industries }) => {
39
            .then(({ industries, industry_id }) => {
39
                Object.entries(industries).map(([key, value]) => {
40
                Object.entries(industries).map(([key, value]) => {
40
                    setIndustries(prev => [...prev, { value: key, name: value }])
41
                    setIndustries(prev => [...prev, { value: key, name: value }])
-
 
42
                })
-
 
43
 
41
                })
44
                setCurrentIndustry(industry_id)
42
            })
45
            })
Línea -... Línea 46...
-
 
46
    }, [isOpen]);
-
 
47
 
-
 
48
    useEffect(() => {
-
 
49
        setValue("industry", industries.find(el => el.value === currentIndustry))
43
    }, [isOpen]);
50
    }, [industries]);
44
 
51
 
45
    return (
52
    return (
46
        <Modal
53
        <Modal
47
            size="md"
54
            size="md"
Línea 53... Línea 60...
53
                <Modal.Title>Cambiar</Modal.Title>
60
                <Modal.Title>Cambiar</Modal.Title>
54
            </Modal.Header>
61
            </Modal.Header>
55
            <form onSubmit={handleSubmit(onSubmit)}>
62
            <form onSubmit={handleSubmit(onSubmit)}>
56
                <Modal.Body>
63
                <Modal.Body>
57
                    <div className="mb-3">
64
                    <div className="mb-3">
58
                        <label className="form-label">Página web</label>
65
                        <label className="form-label">Industria</label>
59
                        <select
66
                        <select
60
                            className='form-control'
67
                            className='form-control'
61
                            name="industry"
68
                            name="industry"
62
                            ref={register}
69
                            ref={register}
63
                        >
70
                        >