Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 7072 Rev 7073
Línea 27... Línea 27...
27
}) => {
27
}) => {
28
  const [settedReaction, setSettedReaction] = useState(defaultReaction)
28
  const [settedReaction, setSettedReaction] = useState(defaultReaction)
29
  const [showReactions, setShowReactions] = useState(false)
29
  const [showReactions, setShowReactions] = useState(false)
30
  const rectionBtn = useRef(null)
30
  const rectionBtn = useRef(null)
31
  const dispatch = useDispatch()
31
  const dispatch = useDispatch()
-
 
32
  useOutsideClick(rectionBtn, () => setShowReactions(false))
-
 
33
 
-
 
34
  const { icon: Icon } = settedReaction
Línea 32... Línea 35...
32
 
35
 
33
  const reactionsOptions = [
36
  const reactionsOptions = [
34
    {
37
    {
35
      type: 'r',
38
      type: 'r',
Línea 56... Línea 59...
56
      icon: FunIcon,
59
      icon: FunIcon,
57
      label: 'Me divierte',
60
      label: 'Me divierte',
58
    },
61
    },
59
  ]
62
  ]
Línea 60... Línea -...
60
 
-
 
61
  const { icon: Icon } = settedReaction
-
 
62
 
-
 
63
  useOutsideClick(rectionBtn, () => setShowReactions(false))
-
 
64
 
63
 
65
  const saveReaction = async (type) => {
64
  const saveReaction = (type) => {
66
    await axios.post(reactionTypesUrl[type]).then((res) => {
65
    axios.post(reactionTypesUrl[type]).then((res) => {
Línea 67... Línea 66...
67
      const { success, data } = res.data
66
      const { success, data } = res.data
68
 
67
 
69
      if (!success) {
68
      if (!success) {
Línea 70... Línea 69...
70
        dispatch(addNotification({ style: 'danger', msg: data }))
69
        dispatch(addNotification({ style: 'danger', msg: data }))
71
      }
70
      }
72
 
71
 
Línea 73... Línea -...
73
      const typeIndex = reactionsOptions.findIndex(
-
 
74
        (option) => option.type === type
-
 
75
      )
-
 
76
 
-
 
77
      console.log(typeIndex)
72
      const typeIndex = reactionsOptions.findIndex(
78
      console.log(reactionsOptions)
73
        (option) => option.type === type
79
      console.log(reactionsOptions[typeIndex])
74
      )
80
 
75
 
Línea 81... Línea 76...
81
      onChange(data.reactions)
76
      onChange(data.reactions)
82
      setSettedReaction(reactionsOptions[typeIndex])
77
      setSettedReaction(reactionsOptions[typeIndex])
83
    })
78
    })
Línea 84... Línea 79...
84
  }
79
  }
85
 
80
 
86
  const deleteReaction = async () => {
81
  const deleteReaction = () => {
Línea 103... Línea 98...
103
 
98
 
104
  useEffect(() => {
99
  useEffect(() => {
105
    const currentOption = reactionsOptions.find(
100
    const currentOption = reactionsOptions.find(
106
      (reaction) => reaction.icon === currentReaction
101
      (reaction) => reaction.icon === currentReaction
-
 
102
    )
107
    )
103
 
108
    if (!currentOption) {
104
    if (!currentOption) {
109
      setSettedReaction(defaultReaction)
105
      setSettedReaction(defaultReaction)
110
      return
106
      return