Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 356 Rev 357
Línea 2... Línea 2...
2
import { Modal } from "react-bootstrap";
2
import { Modal } from "react-bootstrap";
3
import { useDispatch } from "react-redux";
3
import { useDispatch } from "react-redux";
4
import { addNotification } from "../../../../redux/notification/notification.actions";
4
import { addNotification } from "../../../../redux/notification/notification.actions";
5
import parse from "html-react-parser";
5
import parse from "html-react-parser";
Línea 6... Línea -...
6
 
-
 
7
import Input from "../../../UI/Input";
6
 
Línea 8... Línea 7...
8
import FormErrorFeedback from "../../../UI/FormErrorFeedback";
7
import FormErrorFeedback from "../../../UI/FormErrorFeedback";
9
 
8
 
10
const SharePopup = ({ shareData, onClose, onError, show }) => {
9
const SharePopup = ({ shareData, onClose, onError, show }) => {
11
  const [shareUrl, setShareUrl] = useState("");
10
  const [shareUrl, setShareUrl] = useState("");
Línea 12... Línea 11...
12
  const [state, setState] = useState("pending");
11
  const [state, setState] = useState("pending");
13
  const dispatch = useDispatch();
12
  const dispatch = useDispatch();
14
 
13
 
15
  const getShareUrl = async (url = "") => {
14
  const getShareUrl = (url = "") => {
16
    await axios
15
    axios
17
      .get(url)
16
      .get(url)
18
      .then(({ data }) => {
17
      .then(({ data }) => {
19
        if (!data.success) {
18
        if (!data.success) {
Línea 20... Línea 19...
20
          dispatch(addNotification({ style: "danger", msg: data.data }));
19
          dispatch(addNotification({ style: "danger", msg: data.data }));
21
          throw new Error(err);
20
          return;
22
        }
21
        }
Línea 48... Línea 47...
48
        return "Copiar URL";
47
        return "Copiar URL";
49
    }
48
    }
50
  };
49
  };
Línea 51... Línea 50...
51
 
50
 
-
 
51
  useEffect(() => {
52
  useEffect(() => {
52
    if (show) {
-
 
53
      getShareUrl(shareData?.url);
53
    getShareUrl(shareData.url);
54
    }
Línea 54... Línea 55...
54
  }, [shareData]);
55
  }, [shareData, show]);
55
 
56
 
56
  return (
57
  return (
57
    <Modal show={show} onHide={onClose} centered>
58
    <Modal show={show} onHide={onClose} centered>
Línea 62... Línea 63...
62
          <FormErrorFeedback>
63
          <FormErrorFeedback>
63
            No se pudo copiar al portapapeles, por favor copia la url
64
            No se pudo copiar al portapapeles, por favor copia la url
64
            manualmente para compartir.
65
            manualmente para compartir.
65
          </FormErrorFeedback>
66
          </FormErrorFeedback>
66
        ) : null}
67
        ) : null}
67
        <Input value={shareUrl} readOnly />
68
        <input className="form-control" type="text" value={shareUrl} readOnly />
68
        <button className="btn btn-primary" onClick={copyClicked}>
69
        <button className="btn btn-primary" onClick={copyClicked}>
69
          {getButtonText(state)}
70
          {getButtonText(state)}
70
        </button>
71
        </button>
71
      </Modal.Body>
72
      </Modal.Body>
72
    </Modal>
73
    </Modal>