Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3177 Rev 3178
Línea 11... Línea 11...
11
  closeShareModal,
11
  closeShareModal,
12
  openShareModal
12
  openShareModal
13
} from '@store/share-modal/shareModal.actions'
13
} from '@store/share-modal/shareModal.actions'
Línea 14... Línea 14...
14
 
14
 
15
import Modal from '@components/UI/modal/Modal'
-
 
16
import Form from '@components/common/form'
15
import Modal from '@components/UI/modal/Modal'
17
import Select from '@components/UI/inputs/Select'
16
import Select from '@components/UI/inputs/Select'
18
import Ckeditor from '@components/UI/Ckeditor'
17
import Ckeditor from '@components/UI/Ckeditor'
19
import DropzoneComponent from '@components/dropzone/DropzoneComponent'
18
import DropzoneComponent from '@components/dropzone/DropzoneComponent'
20
import FormErrorFeedback from '@components/UI/form/FormErrorFeedback'
19
import FormErrorFeedback from '@components/UI/form/FormErrorFeedback'
Línea 39... Línea 38...
39
    formState: { errors, isSubmitting },
38
    formState: { errors, isSubmitting },
40
    register,
39
    register,
41
    unregister,
40
    unregister,
42
    handleSubmit,
41
    handleSubmit,
43
    setValue,
42
    setValue,
44
    clearErrors,
43
    reset,
45
    watch
44
    watch
46
  } = useForm({
45
  } = useForm({
47
    defaultValues:
46
    defaultValues:
48
      modalType !== shareModalTypes.POST && modalType !== shareModalTypes.SHARE
47
      modalType !== shareModalTypes.POST && modalType !== shareModalTypes.SHARE
49
        ? {
48
        ? {
Línea 63... Línea 62...
63
 
62
 
Línea 64... Línea 63...
64
  const toggleConfirmModal = () => setShowConfirmModal(!showConfirmModal)
63
  const toggleConfirmModal = () => setShowConfirmModal(!showConfirmModal)
65
 
64
 
66
  const handleModalAccept = () => {
-
 
67
    setShowConfirmModal(false)
-
 
68
    setValue('description', '')
65
  const handleModalAccept = () => {
69
    setValue('file', '')
66
    setShowConfirmModal(false)
70
    clearErrors()
67
    reset()
Línea 71... Línea 68...
71
    dispatch(openShareModal(postUrl, modalType, feedType))
68
    dispatch(openShareModal(postUrl, modalType, feedType))
72
  }
69
  }
Línea 78... Línea 75...
78
    dispatch(openShareModal(postUrl, lastModalType, feedType))
75
    dispatch(openShareModal(postUrl, lastModalType, feedType))
79
  }
76
  }
Línea 80... Línea 77...
80
 
77
 
81
  const onUploadedHandler = (files) => {
78
  const onUploadedHandler = (files) => {
82
    setValue('file', files)
-
 
83
    clearErrors('file')
79
    setValue('file', files)
Línea 84... Línea 80...
84
  }
80
  }
85
 
-
 
86
  const onClose = () => {
81
 
87
    clearErrors()
82
  const onClose = () => {
Línea 88... Línea 83...
88
    dispatch(closeShareModal())
83
    dispatch(closeShareModal())
89
  }
84
  }
Línea 128... Línea 123...
128
      dispatch(addNotification({ style: 'danger', msg: error.message }))
123
      dispatch(addNotification({ style: 'danger', msg: error.message }))
129
    }
124
    }
130
  }
125
  }
Línea 131... Línea 126...
131
 
126
 
-
 
127
  useEffect(() => {
-
 
128
    if ((watchedFile || watchedDescription) && modalType !== lastModalType) {
-
 
129
      onClose()
-
 
130
      toggleConfirmModal()
-
 
131
    }
132
  useEffect(() => {
132
 
133
    if (watchedFile !== undefined) {
133
    if (watchedFile !== undefined) {
134
      register('file', { required: 'El archivo es requerido' })
134
      register('file', { required: 'El archivo es requerido' })
135
    } else {
135
    } else {
136
      unregister('file')
136
      unregister('file')
137
    }
-
 
138
 
-
 
139
    if ((watchedFile || watchedDescription) && modalType !== lastModalType) {
-
 
140
      onClose()
-
 
141
      toggleConfirmModal()
-
 
142
    }
137
    }
Línea 143... Línea 138...
143
  }, [modalType])
138
  }, [modalType])
144
 
139
 
145
  return (
140
  return (
146
    <>
141
    <>
147
      <Modal
142
      <Modal
148
        show={isOpen}
143
        show={isOpen}
149
        title={labels.share_a_post}
144
        title={labels.share_a_post}
150
        labelAccept={labels.send}
145
        labelAccept={labels.send}
-
 
146
        labelReject={labels.cancel}
151
        labelReject={labels.cancel}
147
        loading={isSubmitting}
152
        loading={isSubmitting}
-
 
153
        onClose={onClose}
148
        onAccept={handleSubmit(onSubmit)}
154
        formId='share-form'
-
 
155
      >
149
        onClose={onClose}
156
        <Form onSubmit={handleSubmit(onSubmit)} id='share-form'>
150
      >
157
          {feedType === feedTypes.DASHBOARD && (
151
        {feedType === feedTypes.DASHBOARD && (
158
            <Select
152
          <Select
159
              name='shared_with'
-
 
160
              defaultValue='p'
-
 
161
              control={control}
-
 
162
              options={[
-
 
163
                { name: labels.public, value: 'p' },
-
 
164
                { name: labels.connections, value: 'c' }
-
 
165
              ]}
-
 
166
            />
-
 
167
          )}
-
 
168
 
-
 
169
          <Ckeditor
153
            name='shared_with'
-
 
154
            defaultValue='p'
-
 
155
            control={control}
-
 
156
            options={[
-
 
157
              { name: labels.public, value: 'p' },
-
 
158
              { name: labels.connections, value: 'c' }
-
 
159
            ]}
-
 
160
          />
-
 
161
        )}
-
 
162
 
-
 
163
        <Ckeditor
170
            name='description'
164
          name='description'
171
            control={control}
165
          control={control}
-
 
166
          rules={{ required: 'La descripción es requerida' }}
-
 
167
          error={errors.description?.message}
-
 
168
        />
-
 
169
 
-
 
170
        {![shareModalTypes.POST, shareModalTypes.SHARE].includes(modalType) && (
-
 
171
          <DropzoneComponent
-
 
172
            modalType={modalType}
-
 
173
            onUploaded={onUploadedHandler}
172
            rules={{ required: 'La descripción es requerida' }}
174
            settedFile={watch('file')}
-
 
175
            recomendationText={recomendationText[modalType] ?? ''}
Línea 173... Línea -...
173
            error={errors.description?.message}
-
 
174
          />
-
 
175
 
-
 
176
          {![shareModalTypes.POST, shareModalTypes.SHARE].includes(
-
 
177
            modalType
-
 
178
          ) && (
-
 
179
            <DropzoneComponent
-
 
180
              modalType={modalType}
-
 
181
              onUploaded={onUploadedHandler}
-
 
182
              settedFile={watch('file')}
-
 
183
              recomendationText={recomendationText[modalType] ?? ''}
-
 
184
            />
176
          />
185
          )}
177
        )}
186
 
178
 
187
          {errors.file && (
-
 
188
            <FormErrorFeedback>{errors.file.message}</FormErrorFeedback>
179
        {errors.file && (
189
          )}
180
          <FormErrorFeedback>{errors.file.message}</FormErrorFeedback>
190
        </Form>
181
        )}
191
      </Modal>
182
      </Modal>
192
      <ConfirmModal
183
      <ConfirmModal