Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 3764 Rev 3810
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, { useState, useRef } from 'react'
-
 
3
import axios from '../../utils/axios'
3
import parse from "html-react-parser";
4
import parse from "html-react-parser";
4
import moment from 'moment'
5
import moment from 'moment'
5
import { BiShareAlt } from 'react-icons/bi'
6
import { BiShareAlt } from 'react-icons/bi'
6
import { EmailIcon, EmailShareButton, FacebookIcon, FacebookShareButton, RedditIcon, RedditShareButton, TelegramIcon, TelegramShareButton, TwitterIcon, TwitterShareButton, WhatsappIcon, WhatsappShareButton } from 'react-share';
7
import { EmailIcon, EmailShareButton, FacebookIcon, FacebookShareButton, RedditIcon, RedditShareButton, TelegramIcon, TelegramShareButton, TwitterIcon, TwitterShareButton, WhatsappIcon, WhatsappShareButton } from 'react-share';
-
 
8
import { addNotification } from '../../redux/notification/notification.actions'
7
import { useRef } from 'react';
9
import { useDispatch } from 'react-redux'
Línea 8... Línea 10...
8
 
10
 
Línea -... Línea 11...
-
 
11
export default function PostView({ post = {} }) {
-
 
12
 
-
 
13
    const [shareUrl, setShareUrl] = useState()
-
 
14
    const dispatch = useDispatch()
-
 
15
 
-
 
16
    const getShareUrl = new Promise((resolve, reject) => {
-
 
17
        axios.get(post.share_external_url)
-
 
18
            .then(({ data }) => {
-
 
19
                if (!data.success) {
-
 
20
                    dispatch(addNotification({ style: 'danger', msg: data.data }))
-
 
21
                    setShareOptions(false)
-
 
22
                    return reject(data.data)
-
 
23
                }
-
 
24
                setShareUrl(data.data)
-
 
25
                return resolve(data.data)
-
 
26
            })
-
 
27
            .catch((err) => reject(err))
9
export default function PostView({ post = {} }) {
28
    });
10
 
29
 
11
    const baseUrl = `/storage/type/post/code/${post.uuid}/filename/`
30
    const baseUrl = `/storage/type/post/code/${post.uuid}/filename/`
Línea 12... Línea 31...
12
    const shareContainer = useRef(null)
31
    const shareContainer = useRef(null)
Línea 34... Línea 53...
34
                                    >
53
                                    >
35
                                        <BiShareAlt />
54
                                        <BiShareAlt />
36
                                    </button>
55
                                    </button>
37
                                    {shareOptions &&
56
                                    {shareOptions &&
38
                                        <div className="ext_share post" ref={shareContainer}>
57
                                        <div className="ext_share post" ref={shareContainer}>
39
                                            <FacebookShareButton url={post.share_external_url}>
58
                                            <FacebookShareButton beforeOnClick={getShareUrl} url={shareUrl}>
40
                                                <FacebookIcon size={32} round />
59
                                                <FacebookIcon size={32} round />
41
                                            </FacebookShareButton>
60
                                            </FacebookShareButton>
42
                                            <TwitterShareButton url={post.share_external_url}>
61
                                            <TwitterShareButton beforeOnClick={getShareUrl} url={shareUrl}>
43
                                                <TwitterIcon size={32} round />
62
                                                <TwitterIcon size={32} round />
44
                                            </TwitterShareButton>
63
                                            </TwitterShareButton>
45
                                            <TelegramShareButton url={post.share_external_url}>
64
                                            <TelegramShareButton beforeOnClick={getShareUrl} url={shareUrl}>
46
                                                <TelegramIcon size={32} round />
65
                                                <TelegramIcon size={32} round />
47
                                            </TelegramShareButton>
66
                                            </TelegramShareButton>
48
                                            <WhatsappShareButton url={post.share_external_url}>
67
                                            <WhatsappShareButton beforeOnClick={getShareUrl} url={shareUrl}>
49
                                                <WhatsappIcon size={32} round />
68
                                                <WhatsappIcon size={32} round />
50
                                            </WhatsappShareButton>
69
                                            </WhatsappShareButton>
51
                                            <RedditShareButton url={post.share_external_url}>
70
                                            <RedditShareButton beforeOnClick={getShareUrl} url={shareUrl}>
52
                                                <RedditIcon size={32} round />
71
                                                <RedditIcon size={32} round />
53
                                            </RedditShareButton>
72
                                            </RedditShareButton>
54
                                            <EmailShareButton url={post.share_external_url}>
73
                                            <EmailShareButton beforeOnClick={getShareUrl} url={shareUrl}>
55
                                                <EmailIcon size={32} round />
74
                                                <EmailIcon size={32} round />
56
                                            </EmailShareButton>
75
                                            </EmailShareButton>
57
                                        </div>
76
                                        </div>
58
                                    }
77
                                    }
59
                                </li>
78
                                </li>