Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2162 Rev 2242
Línea 41... Línea 41...
41
 
41
 
42
    const toggleShareOptions = () => {
42
    const toggleShareOptions = () => {
43
      setShareOptions(!shareOptions)
43
      setShareOptions(!shareOptions)
Línea 44... Línea 44...
44
    }
44
    }
45
 
45
 
46
    const getShareUrl = async () => {
46
    const getShorterUrl = new Promise(() => {
47
      await axios
47
      axios
48
        .get(url)
48
        .get(url)
49
        .then(({ data }) => {
-
 
50
          if (!data.success) {
49
        .then(({ data }) => {
51
            dispatch(addNotification({ style: 'danger', msg: data.data }))
50
          if (!data.success) {
52
            setShareOptions(false)
51
            setShareOptions(false)
Línea 53... Línea 52...
53
            return
52
            throw new Error(data.data)
54
          }
53
          }
55
 
54
 
-
 
55
          setShareUrl(data.data)
-
 
56
        })
56
          setShareUrl(data.data)
57
        .catch((err) =>
Línea 57... Línea 58...
57
        })
58
          dispatch(addNotification({ style: 'danger', msg: err.message }))
58
        .catch((err) => console.log(err))
59
        )
59
    }
60
    })
60
 
61
 
Línea 71... Línea 72...
71
          setValue(data.data)
72
          setValue(data.data)
72
        })
73
        })
73
        .catch((err) => console.log(err))
74
        .catch((err) => console.log(err))
74
    }
75
    }
Línea 75... Línea -...
75
 
-
 
76
    useEffect(() => {
-
 
77
      if (shareOptions && !shareUrl) getShareUrl()
-
 
78
    }, [shareOptions])
-
 
79
 
76
 
80
    return (
77
    return (
81
      <Component onClick={toggleShareOptions}>
78
      <Component onClick={toggleShareOptions}>
Línea 82... Línea 79...
82
        {children}
79
        {children}
83
 
80
 
84
        {shareOptions && (
81
        {shareOptions && (
85
          <StyledShareContainer>
82
          <StyledShareContainer>
86
            <FacebookShareButton
83
            <FacebookShareButton
-
 
84
              url={shareUrl}
87
              url={shareUrl}
85
              onShareWindowClose={() => incrementCount()}
88
              onShareWindowClose={() => incrementCount()}
86
              beforeOnClick={getShorterUrl}
89
            >
87
            >
90
              <FacebookIcon size={32} round />
88
              <FacebookIcon size={32} round />
91
            </FacebookShareButton>
89
            </FacebookShareButton>