Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 6024 | Rev 7775 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
7774 stevensc 1
import React, { useState } from 'react'
2
import LocationModal from './LocationModal'
6002 stevensc 3
 
7774 stevensc 4
const Location = ({ locations = [], googleApiKey, locationsAddUrl }) => {
6002 stevensc 5
 
7774 stevensc 6
    const [actionUrl, setActionUrl] = useState(locationsAddUrl)
7
    const [showModal, setShowModal] = useState(false)
6002 stevensc 8
 
7774 stevensc 9
    const editLocation = (url) => {
10
        setShowModal(true)
11
        setActionUrl(url)
12
    }
13
 
14
    const closeModal = () => setShowModal(false)
15
 
6002 stevensc 16
    const deleteLocation = (url) => { }
17
 
18
    return (
7774 stevensc 19
        <>
20
            <div className="user-profile-extended-ov st2">
21
                <h3>
22
                    Ubicaciones
23
                    <button className="btn btn-location-add">
24
                        <i className="fa fa-plus-square" />
25
                    </button>
26
                </h3>
27
                <span id="locations-records">
28
                    {
29
                        locations.map((location, index) => (
30
                            <>
31
                                <p key={index}>
32
                                    {location.formatted_address}
33
                                    {location.is_main === 'y' ? " (Principal)" : ""}
34
                                    <button
35
                                        onClick={() => editLocation(location.link_edit)}
36
                                        className="btn btn-location-edit"
37
                                        style={{ padding: '.3rem' }}
38
                                    >
39
                                        <i className="fa fa-pencil" />
40
                                    </button>
41
                                    <button
42
                                        onClick={() => deleteLocation(location.link_delete)}
43
                                        className="btn btn-location-delete"
44
                                        style={{ padding: '.3rem' }}
45
                                    >
46
                                        <i className="fa fa-trash" />
47
                                    </button>
48
                                </p>
49
                                {
50
                                    locations[index + 1] && <hr />
51
                                }
52
                            </>
53
                        ))
54
                    }
55
                </span>
56
            </div >
57
            {
58
                showModal
59
                &&
60
                <LocationModal
61
                    closeModal={closeModal}
62
                    dataLink={actionUrl}
63
                    googleApiKey={googleApiKey}
64
 
65
                />
66
            }
67
        </>
6002 stevensc 68
    )
69
}
70
 
71
export default Location