Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4061 Rev 4100
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React, { useState } from 'react'
2
import React, { useEffect, useRef, useState } from 'react'
3
import { axios } from '../../../../utils'
3
import { axios } from '../../../../utils'
4
import { useForm } from 'react-hook-form'
4
import { useForm } from 'react-hook-form'
5
import { connect } from 'react-redux'
5
import { connect } from 'react-redux'
6
import { addNotification } from '../../../../redux/notification/notification.actions'
6
import { addNotification } from '../../../../redux/notification/notification.actions'
7
import ConfirmModal from '../../../../shared/confirm-modal/ConfirmModal'
7
import ConfirmModal from '../../../../shared/confirm-modal/ConfirmModal'
Línea 110... Línea 110...
110
        comment,
110
        comment,
111
        unique,
111
        unique,
112
    } = commentData;
112
    } = commentData;
Línea 113... Línea 113...
113
 
113
 
-
 
114
    const [showConfirmModal, setShowConfirmModal] = useState(false);
-
 
115
    const [displayOption, setDisplayOption] = useState(false)
Línea 114... Línea 116...
114
    const [showConfirmModal, setShowConfirmModal] = useState(false);
116
    const deleteButton = useRef();
Línea 115... Línea 117...
115
 
117
 
Línea -... Línea 118...
-
 
118
    const handleShowConfirmModal = () => setShowConfirmModal(!showConfirmModal)
-
 
119
 
-
 
120
    const handleModalAccept = () => onDeleteHandler(unique, link_delete)
-
 
121
 
-
 
122
    useEffect(() => {
-
 
123
        const handleClickOutside = (event) => {
-
 
124
            if (deleteButton.current && !deleteButton.current.contains(event.target)) {
-
 
125
                setDisplayOption(false)
-
 
126
            }
-
 
127
        }
-
 
128
        document.addEventListener("mousedown", handleClickOutside);
-
 
129
 
-
 
130
        return () => {
116
    const handleShowConfirmModal = () => setShowConfirmModal(!showConfirmModal)
131
            document.removeEventListener("mousedown", handleClickOutside);
117
 
132
        };
118
    const handleModalAccept = () => onDeleteHandler(unique, link_delete)
133
    }, [deleteButton]);
119
 
134
 
120
    return (
135
    return (
Línea 129... Línea 144...
129
                    <div className='info'>
144
                    <div className='info'>
130
                        <a href={user_url}>
145
                        <a href={user_url}>
131
                            <h3>{user_name}</h3>
146
                            <h3>{user_name}</h3>
132
                        </a>
147
                        </a>
133
                        <span>
148
                        <span>
134
                            <img
-
 
135
                                src="/images/clock.png"
-
 
136
                                alt="Clock"
-
 
137
                                className='mr-2'
-
 
138
                            />
-
 
139
                            {time_elapsed}
149
                            {time_elapsed}
140
                            {link_delete &&
150
                            {link_delete &&
141
                                <button
151
                                <>
-
 
152
                                    <img
-
 
153
                                        src='/images/icons/options.png'
-
 
154
                                        className='cursor-pointer img-icon options'
-
 
155
                                        onClick={() => setDisplayOption(!displayOption)}
-
 
156
                                    />
-
 
157
                                    <div className={`feed-options ${displayOption ? 'active' : ''}`}>
-
 
158
                                        <ul>
-
 
159
                                            <li>
-
 
160
                                                <button
142
                                    className="btn-comment-trash"
161
                                                    className="option-btn"
143
                                    onClick={handleShowConfirmModal}
162
                                                    onClick={handleShowConfirmModal}
-
 
163
                                                    ref={deleteButton}
144
                                >
164
                                                >
145
                                    <i className="fa fa-trash-o"></i>
165
                                                    <i className="fa fa-trash-o mr-1" />
-
 
166
                                                    Borrar
-
 
167
                                                </button>
-
 
168
                                            </li>
-
 
169
                                        </ul>
-
 
170
                                    </div>
146
                                </button>
171
                                </>
147
                            }
172
                            }
148
                        </span>
173
                        </span>
149
                    </div>
174
                    </div>
150
                    <p>{comment}</p>
175
                    <p>{comment}</p>
151
                </div>
176
                </div>