Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 348 Rev 349
Línea 1... Línea 1...
1
import React, { useState } from "react";
1
import React, { useState } from "react";
Línea -... Línea 2...
-
 
2
 
-
 
3
import styles from "./MobileSharePopUp.module.scss";
2
 
4
 
3
const SharePopup = ({ shareData, onClose, onError }) => {
5
const SharePopup = ({ shareData, onClose, onError }) => {
Línea -... Línea 6...
-
 
6
  const [state, setState] = useState("pending");
-
 
7
 
-
 
8
  const getShareUrl = async (url = "") => {
-
 
9
    await axios
-
 
10
      .get(url)
-
 
11
      .then(({ data }) => {
-
 
12
        if (!data.success) {
-
 
13
          dispatch(addNotification({ style: "danger", msg: data.data }));
-
 
14
          return;
-
 
15
        }
-
 
16
 
-
 
17
        return data.data;
-
 
18
      })
-
 
19
      .catch((err) => {
-
 
20
        onError(err);
-
 
21
        throw new Error(err);
-
 
22
      });
4
  const [state, setState] = useState("pending");
23
  };
5
 
24
 
-
 
25
  const copyClicked = async () => {
6
  const copyClicked = async () => {
26
    try {
7
    try {
27
      const shareUrl = await getShareUrl(shareData.url);
8
      await navigator.clipboard.writeText(shareData?.url || "");
28
      await navigator.clipboard.writeText(shareUrl || "");
9
      setState("success");
29
      setState("success");
10
    } catch (err) {
30
    } catch (err) {
11
      onError && onError(err);
31
      onError && onError(err);
Línea 22... Línea 42...
22
        return "Copy link";
42
        return "Copy link";
23
    }
43
    }
24
  };
44
  };
Línea 25... Línea 45...
25
 
45
 
-
 
46
  return (
26
  return (
47
    <div className={styles.share__popup}>
-
 
48
      <div>
-
 
49
        <h3>{shareData.title}</h3>
-
 
50
        <button onClick={onClose}>
-
 
51
          <span>Close Share</span>
-
 
52
          <div aria-hidden="true">
-
 
53
            <svg
-
 
54
              xmlns="http://www.w3.org/2000/svg"
-
 
55
              width="24"
-
 
56
              height="24"
-
 
57
              viewBox="0 0 24 24"
-
 
58
            >
-
 
59
              <g id="close">
-
 
60
                <path
-
 
61
                  id="x"
-
 
62
                  d="M18.717 6.697l-1.414-1.414-5.303 5.303-5.303-5.303-1.414 1.414 5.303 5.303-5.303 5.303 1.414 1.414 5.303-5.303 5.303 5.303 1.414-1.414-5.303-5.303z"
-
 
63
                />
-
 
64
              </g>
-
 
65
            </svg>
-
 
66
          </div>
-
 
67
        </button>
27
    <div>
68
      </div>
28
      <div>
69
      <div>
29
        <div>
70
        {state === "error" ? (
30
          <div>
71
          <div>
31
            <div>
-
 
32
              <div>
-
 
33
                <h3>{shareData.title}</h3>
-
 
34
                <button onClick={onClose}>
-
 
35
                  <span>Close Share</span>
-
 
36
                  <div aria-hidden="true">
-
 
37
                    <svg
-
 
38
                      xmlns="http://www.w3.org/2000/svg"
-
 
39
                      width="24"
-
 
40
                      height="24"
-
 
41
                      viewBox="0 0 24 24"
-
 
42
                    >
-
 
43
                      <g id="close">
-
 
44
                        <path
-
 
45
                          id="x"
-
 
46
                          d="M18.717 6.697l-1.414-1.414-5.303 5.303-5.303-5.303-1.414 1.414 5.303 5.303-5.303 5.303 1.414 1.414 5.303-5.303 5.303 5.303 1.414-1.414-5.303-5.303z"
-
 
47
                        />
-
 
48
                      </g>
-
 
49
                    </svg>
-
 
50
                  </div>
-
 
51
                </button>
-
 
52
              </div>
-
 
53
              <div>
-
 
54
                {state === "error" ? (
-
 
55
                  <div>
-
 
56
                    <p>
72
            <p>
57
                      Unable to copy to clipboard, please manually copy the url
-
 
58
                      to share.
-
 
59
                    </p>
-
 
60
                  </div>
-
 
61
                ) : null}
-
 
62
                <input value={shareData.url} readOnly />
-
 
63
                <button onClick={copyClicked}>{getButtonText(state)}</button>
73
              Unable to copy to clipboard, please manually copy the url to
64
              </div>
74
              share.
65
            </div>
75
            </p>
66
          </div>
76
          </div>
-
 
77
        ) : null}
-
 
78
        <input value={shareData.url} readOnly />
67
        </div>
79
        <button onClick={copyClicked}>{getButtonText(state)}</button>
68
      </div>
80
      </div>
69
    </div>
81
    </div>
70
  );
82
  );