Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3182 Rev 3183
Línea 1... Línea -...
1
import { useState, useEffect } from 'react'
-
 
2
import { useDispatch, useSelector } from 'react-redux'
1
import { useDispatch, useSelector } from 'react-redux'
Línea 3... Línea 2...
3
 
2
 
4
import {
3
import {
5
  closeShareModal,
4
  closeShareModal,
6
  openShareModal
5
  openShareModal
Línea 7... Línea 6...
7
} from '@store/share-modal/shareModal.actions'
6
} from '@store/share-modal/shareModal.actions'
8
 
-
 
9
export function useShareModal() {
7
 
Línea 10... Línea 8...
10
  const [showConfirm, setShowConfirm] = useState(false)
8
export function useShareModal() {
11
  const dispatch = useDispatch()
9
  const dispatch = useDispatch()
-
 
10
 
Línea 12... Línea 11...
12
 
11
  const { isOpen, postUrl, modalType, feedType, feedSharedId } = useSelector(
Línea 13... Línea -...
13
  const { isOpen, postUrl, modalType, lastModalType, feedType, feedSharedId } =
-
 
14
    useSelector((state) => state.shareModal)
-
 
15
 
12
    (state) => state.shareModal
16
  const toggleConfirm = () => setShowConfirm(!showConfirm)
-
 
17
 
-
 
18
  const onConfirm = () => {
-
 
19
    setShowConfirm(false)
-
 
20
    dispatch(openShareModal(postUrl, modalType, feedType))
13
  )
21
  }
-
 
22
 
-
 
23
  const onReject = () => {
-
 
24
    setShowConfirm(false)
-
 
25
    dispatch(openShareModal(postUrl, lastModalType, feedType))
-
 
26
  }
-
 
27
 
-
 
28
  const close = () => {
-
 
29
    dispatch(closeShareModal())
-
 
30
  }
-
 
31
 
-
 
32
  useEffect(() => {
-
 
Línea 33... Línea 14...
33
    if (modalType !== lastModalType) {
14
 
34
      close()
15
  const closeModal = () => dispatch(closeShareModal())
35
      toggleConfirm()
16
 
36
    }
17
  const openModal = ({ url, modalType, feedType }) =>
37
  }, [modalType, lastModalType])
-
 
38
 
18
    dispatch(openShareModal(url, modalType, feedType))
39
  return {
19
 
40
    show: isOpen,
-
 
41
    postUrl,
-
 
42
    modalType,
20
  return {
43
    lastModalType,
21
    show: isOpen,
44
    feedType,
22
    postUrl,
45
    feedSharedId,
23
    modalType,