Línea 1... |
Línea -... |
1 |
/* eslint-disable react/prop-types */
|
- |
|
2 |
/* eslint-disable react/display-name */
|
1 |
/* eslint-disable react/display-name */
|
3 |
import React, { useState } from "react"
|
2 |
import React, { useState } from "react"
|
4 |
import { useDispatch } from "react-redux"
|
3 |
import { useDispatch } from "react-redux"
|
5 |
import { EmailIcon, EmailShareButton, FacebookIcon, FacebookShareButton, RedditIcon, RedditShareButton, TelegramIcon, TelegramShareButton, TwitterIcon, TwitterShareButton, WhatsappIcon, WhatsappShareButton } from "react-share"
|
4 |
import { EmailIcon, EmailShareButton, FacebookIcon, FacebookShareButton, RedditIcon, RedditShareButton, TelegramIcon, TelegramShareButton, TwitterIcon, TwitterShareButton, WhatsappIcon, WhatsappShareButton } from "react-share"
|
6 |
import { addNotification } from "../../../../redux/notification/notification.actions"
|
5 |
import { addNotification } from "../../../../redux/notification/notification.actions"
|
7 |
import { axios } from "../../../../utils"
|
6 |
import { axios } from "../../../../utils"
|
Línea 8... |
Línea 7... |
8 |
|
7 |
|
9 |
export default function withReactionList({Component, url, icon}) {
|
8 |
export default function withReactionList({ Component, url, icon, title, color }) {
|
- |
|
9 |
return function () {
|
- |
|
10 |
const dispatch = useDispatch()
|
- |
|
11 |
const [shareOptions, setShareOptions] = useState(false)
|
- |
|
12 |
const [shareUrl, setShareUrl] = useState('');
|
- |
|
13 |
|
- |
|
14 |
const handleDisplayReactionList = () => setShareOptions(!shareOptions)
|
- |
|
15 |
|
- |
|
16 |
const getShareUrl = new Promise((resolve, reject) => {
|
- |
|
17 |
if (shareOptions) {
|
- |
|
18 |
axios.get(url)
|
- |
|
19 |
.then(({ data }) => {
|
- |
|
20 |
if (!data.success) {
|
- |
|
21 |
dispatch(addNotification({ style: 'danger', msg: data.data }))
|
- |
|
22 |
setShareOptions(false)
|
- |
|
23 |
return reject(data.data)
|
- |
|
24 |
}
|
- |
|
25 |
setShareUrl(data.data)
|
- |
|
26 |
return resolve(data.data)
|
- |
|
27 |
})
|
- |
|
28 |
.catch((err) => reject(err))
|
- |
|
29 |
}
|
- |
|
30 |
});
|
10 |
return function () {
|
31 |
|
11 |
return (
|
32 |
return (
|
12 |
<div className="position-relative">
|
33 |
<div className="position-relative" onClick={handleDisplayReactionList}>
|
- |
|
34 |
<Component Icon={icon} title={title} color={color} />
|
- |
|
35 |
{shareOptions &&
|
- |
|
36 |
<div className="ext_share" >
|
- |
|
37 |
<FacebookShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
- |
|
38 |
<FacebookIcon size={32} round />
|
- |
|
39 |
</FacebookShareButton>
|
- |
|
40 |
<TwitterShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
- |
|
41 |
<TwitterIcon size={32} round />
|
- |
|
42 |
</TwitterShareButton>
|
- |
|
43 |
<TelegramShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
- |
|
44 |
<TelegramIcon size={32} round />
|
- |
|
45 |
</TelegramShareButton>
|
- |
|
46 |
<WhatsappShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
- |
|
47 |
<WhatsappIcon size={32} round />
|
- |
|
48 |
</WhatsappShareButton>
|
- |
|
49 |
<RedditShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
- |
|
50 |
<RedditIcon size={32} round />
|
- |
|
51 |
</RedditShareButton>
|
- |
|
52 |
<EmailShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
- |
|
53 |
<EmailIcon size={32} round />
|
- |
|
54 |
</EmailShareButton>
|
- |
|
55 |
</div>
|
13 |
<Component Icon={icon} />
|
56 |
}
|
14 |
</div>
|
57 |
</div>
|
15 |
)
|
58 |
)
|
16 |
}
|
59 |
}
|
17 |
}
|
60 |
}
|