Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 8052 Rev 8060
Línea 7... Línea 7...
7
    const [actionUrl, setActionUrl] = useState(locationsAddUrl)
7
    const [actionUrl, setActionUrl] = useState(locationsAddUrl)
8
    const [defaultData, setDefaultData] = useState('')
8
    const [defaultData, setDefaultData] = useState('')
9
    const [showModal, setShowModal] = useState(false)
9
    const [showModal, setShowModal] = useState(false)
10
    const [showDeleteModal, setShowDeleteModal] = useState(false)
10
    const [showDeleteModal, setShowDeleteModal] = useState(false)
11
    const [deleteLink, setDeleteLink] = useState('')
11
    const [deleteLink, setDeleteLink] = useState('')
-
 
12
    const [removeElement, setRemoveElement] = useState('')
-
 
13
    const [locationState, setLocationState] = useState(locations)
Línea 12... Línea 14...
12
 
14
 
13
    const addLocation = (url) => {
15
    const addLocation = (url) => {
14
        setShowModal(true)
16
        setShowModal(true)
15
        setActionUrl(url)
17
        setActionUrl(url)
Línea 22... Línea 24...
22
    }
24
    }
Línea 23... Línea 25...
23
 
25
 
24
    const closeModal = () => setShowModal(false)
26
    const closeModal = () => setShowModal(false)
Línea 25... Línea 27...
25
    const closeDeleteModal = () => setShowDeleteModal(false)
27
    const closeDeleteModal = () => setShowDeleteModal(false)
26
 
28
 
27
    const deleteLocation = (url) => {
29
    const deleteLocation = ({ url, address }) => {
-
 
30
        setShowDeleteModal(true)
28
        setShowDeleteModal(true)
31
        setDeleteLink(url)
Línea 29... Línea 32...
29
        setDeleteLink(url)
32
        setRemoveElement(address)
30
    }
33
    }
31
 
34
 
Línea 41... Línea 44...
41
                        <i className="fa fa-plus-square" />
44
                        <i className="fa fa-plus-square" />
42
                    </button>
45
                    </button>
43
                </h3>
46
                </h3>
44
                <span id="locations-records">
47
                <span id="locations-records">
45
                    {
48
                    {
46
                        locations.map((location, index) => (
49
                        locationState.map((location, index) => (
47
                            <>
50
                            <>
48
                                <p key={index}>
51
                                <p key={index}>
49
                                    {location.formatted_address}
52
                                    {location.formatted_address}
50
                                    {location.is_main === 'y' ? " (Principal)" : ""}
53
                                    {location.is_main === 'y' ? " (Principal)" : ""}
51
                                    <button
54
                                    <button
Línea 54... Línea 57...
54
                                        style={{ padding: '.3rem' }}
57
                                        style={{ padding: '.3rem' }}
55
                                    >
58
                                    >
56
                                        <i className="fa fa-pencil" />
59
                                        <i className="fa fa-pencil" />
57
                                    </button>
60
                                    </button>
58
                                    <button
61
                                    <button
59
                                        onClick={() => deleteLocation(location.link_delete)}
62
                                        onClick={() => deleteLocation({ url: location.link_delete, address: location.formatted_address })}
60
                                        className="btn btn-location-delete"
63
                                        className="btn btn-location-delete"
61
                                        style={{ padding: '.3rem' }}
64
                                        style={{ padding: '.3rem' }}
62
                                    >
65
                                    >
63
                                        <i className="fa fa-trash" />
66
                                        <i className="fa fa-trash" />
64
                                    </button>
67
                                    </button>
Línea 87... Línea 90...
87
                <DeleteModal
90
                <DeleteModal
88
                    url={deleteLink}
91
                    url={deleteLink}
89
                    isOpen={showDeleteModal}
92
                    isOpen={showDeleteModal}
90
                    closeModal={closeDeleteModal}
93
                    closeModal={closeDeleteModal}
91
                    title={`Esta seguro de eliminar esta ubicación?`}
94
                    title={`Esta seguro de eliminar esta ubicación?`}
92
                    onComplete={() => deleteLocation(locationToDelete)}
95
                    onComplete={() => setLocationState(locationState.filter(val => val.formatted_address !== removeElement))}
93
                    message={`Ubicación eliminada`}
96
                    message={`Ubicación eliminada`}
94
                />
97
                />
95
            }
98
            }
96
        </>
99
        </>
97
    )
100
    )