Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3280 Rev 3281
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React, { useState } from 'react'
2
import { Controller, useForm } from 'react-hook-form'
2
import { Controller, useForm } from 'react-hook-form'
3
import { useDispatch, useSelector } from 'react-redux'
3
import { useDispatch, useSelector } from 'react-redux'
Línea -... Línea 4...
-
 
4
 
4
 
5
import { axios } from '@utils'
5
import { useShareModal } from '@hooks'
-
 
6
import { addFeed } from '@store/feed/feed.actions'
6
import { useShareModal } from '@hooks'
7
import { feedTypes } from '@store/feed/feed.types'
7
import { feedTypes } from '@store/feed/feed.types'
8
import { addNotification } from '@store/notification/notification.actions'
8
import { addFeed, addFeedSuccess } from '@store/feed/feed.actions'
-
 
9
import { shareModalTypes } from '@store/share-modal/shareModal.types'
Línea -... Línea 10...
-
 
10
import { addNotification } from '@store/notification/notification.actions'
9
import { shareModalTypes } from '@store/share-modal/shareModal.types'
11
 
10
 
12
import Form from '@components/common/form'
11
import Modal from '@components/UI/modal/Modal'
13
import Modal from '@components/UI/modal/Modal'
12
import Select from '@components/UI/inputs/Select'
14
import Select from '@components/UI/inputs/Select'
13
import Ckeditor from '@components/common/ckeditor/Ckeditor'
15
import Ckeditor from '@components/common/ckeditor/Ckeditor'
14
import DropzoneComponent from '@components/dropzone/DropzoneComponent'
16
import DropzoneComponent from '@components/dropzone/DropzoneComponent'
15
import FormErrorFeedback from '@components/UI/form/FormErrorFeedback'
-
 
Línea 16... Línea 17...
16
import ConfirmModal from './ConfirmModal'
17
import FormErrorFeedback from '@components/UI/form/FormErrorFeedback'
17
import Form from '@components/common/form'
18
import ConfirmModal from './ConfirmModal'
18
 
19
 
19
const recomendationText = {
20
const recomendationText = {
Línea 55... Línea 56...
55
 
56
 
Línea 56... Línea 57...
56
  const toggleConfirm = () => setShowConfirm(!showConfirm)
57
  const toggleConfirm = () => setShowConfirm(!showConfirm)
57
 
58
 
-
 
59
  const onSubmit = handleSubmit(async (feed) => {
-
 
60
    try {
-
 
61
      const form = new FormData()
58
  const onSubmit = handleSubmit(async (feed) => {
62
      Object.entries(feed).forEach(([key, value]) => form.append(key, value))
-
 
63
 
-
 
64
      const response = await axios.post(postUrl, form)
-
 
65
      const { data, success } = response.data
-
 
66
 
-
 
67
      if (!success) {
-
 
68
        const errorMessage =
-
 
69
          typeof data === 'string'
-
 
70
            ? data
-
 
71
            : 'Ha ocurrido un error al publicar, inténtalo de nuevo más tarde.'
-
 
72
        throw new Error(errorMessage)
-
 
73
      }
Línea 59... Línea 74...
59
    try {
74
 
60
      await dispatch(addFeed(postUrl, feed, feedSharedId))
75
      const newFeed = data
61
 
76
 
62
      dispatch(
77
      dispatch(
63
        addNotification({
78
        addNotification({
64
          style: 'success',
79
          style: 'success',
-
 
80
          msg: 'La publicación ha sido compartida'
-
 
81
        })
65
          msg: 'Post publicado correctamente'
82
      )
66
        })
83
      dispatch(addFeedSuccess(newFeed, feedSharedId))
67
      )
84
 
68
      reset()
85
      reset()
69
      closeModal()
86
      closeModal()