Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16709 Rev 16710
Línea 55... Línea 55...
55
  const onSubmit = handleSubmit((data) => {
55
  const onSubmit = handleSubmit((data) => {
56
    setLoading(true)
56
    setLoading(true)
57
    const formData = new FormData()
57
    const formData = new FormData()
Línea 58... Línea 58...
58
 
58
 
59
    Object.entries(data).map(([entry, value]) => formData.append(entry, value))
-
 
Línea -... Línea 59...
-
 
59
    Object.entries(data).map(([entry, value]) => formData.append(entry, value))
-
 
60
 
-
 
61
    if (modalType === shareModalTypes.SURVEY) {
-
 
62
      const numberOfAnswers = Object.entries(data).filter((entry) =>
-
 
63
        entry[0].includes('answer')
-
 
64
      ).length
-
 
65
 
-
 
66
      formData.append('feed_content_type', 'fast-survey')
60
    console.log(data)
67
      formData.append('`number_of_answers', numberOfAnswers)
61
 
68
    }
62
    /* axios
69
    /* axios
63
      .post(postUrl, formData)
70
      .post(postUrl, formData)
64
      .then(({ data: response }) => {
71
      .then(({ data: response }) => {
Línea 125... Línea 132...
125
      unregister('description')
132
      unregister('description')
126
      register('date')
133
      register('date')
127
    }
134
    }
128
  }, [modalType])
135
  }, [modalType])
Línea 129... Línea -...
129
 
-
 
130
  useEffect(() => {
-
 
131
    console.log(errors)
-
 
132
  }, [errors])
-
 
133
 
136
 
134
  return (
137
  return (
135
    <Modal show={isOpen} onHide={closeModal}>
138
    <Modal show={isOpen} onHide={closeModal}>
136
      <form onSubmit={onSubmit} method="post">
139
      <form onSubmit={onSubmit} method="post">
137
        <Modal.Header closeButton>
140
        <Modal.Header closeButton>
Línea 198... Línea 201...
198
  )
201
  )
199
}
202
}
Línea 200... Línea 203...
200
 
203
 
201
const SurveyForm = ({ register, setValue }) => {
204
const SurveyForm = ({ register, setValue }) => {
202
  const [optionsNumber, setOptionsNumber] = useState(2)
-
 
Línea 203... Línea 205...
203
  const [selectedDate, setSelectedDate] = useState(null)
205
  const [optionsNumber, setOptionsNumber] = useState(2)
204
 
206
 
205
  const options = [
207
  const options = [
206
    { placeholder: 'Por ejemplo: transporte público' },
208
    { placeholder: 'Por ejemplo: transporte público' },
Línea 242... Línea 244...
242
            <option value="c">Compañía</option>
244
            <option value="c">Compañía</option>
243
            <option value="p">Público</option>
245
            <option value="p">Público</option>
244
          </select>
246
          </select>
245
        </div>
247
        </div>
246
        <div className="form-group col">
248
        <div className="form-group col">
247
          <label htmlFor="result">Resultado</label>
249
          <label htmlFor="result_type">Resultado</label>
248
          <select
250
          <select
249
            className="form-control"
251
            className="form-control"
250
            name="result"
252
            name="result_type"
251
            id="result"
253
            id="result_type"
252
            ref={register}
254
            ref={register}
253
          >
255
          >
254
            <option value="pr">Privado</option>
256
            <option value="pr">Privado</option>
255
            <option value="pu">Público</option>
257
            <option value="pu">Público</option>
256
          </select>
258
          </select>
Línea 268... Línea 270...
268
          ref={register({ required: true })}
270
          ref={register({ required: true })}
269
        />
271
        />
270
      </div>
272
      </div>
271
      {options.slice(0, optionsNumber).map((option, index) => (
273
      {options.slice(0, optionsNumber).map((option, index) => (
272
        <div className="form-group" key={index}>
274
        <div className="form-group" key={index}>
273
          <label htmlFor={`option-${index + 1}`}>Opción {index + 1}*</label>
275
          <label htmlFor={`answer${index + 1}`}>Opción {index + 1}*</label>
274
          {index > 1 && (
276
          {index > 1 && (
275
            <button className="btn" onClick={removeOption}>
277
            <button className="btn" onClick={removeOption}>
276
              Eliminar
278
              Eliminar
277
            </button>
279
            </button>
278
          )}
280
          )}
279
          <input
281
          <input
280
            type="text"
282
            type="text"
281
            className="form-control"
283
            className="form-control"
282
            placeholder={option.placeholder}
284
            placeholder={option.placeholder}
283
            maxLength={30}
285
            maxLength={30}
284
            id={`option-${index + 1}`}
286
            id={`answer${index + 1}`}
285
            name={`option-${index + 1}`}
287
            name={`answer${index + 1}`}
286
            ref={register({ required: true })}
288
            ref={register({ required: true })}
287
          />
289
          />
288
        </div>
290
        </div>
289
      ))}
291
      ))}
290
      {optionsNumber < options.length && (
292
      {optionsNumber < options.length && (
291
        <button className="btn btn-outline-primary rounded" onClick={addOption}>
293
        <button className="btn btn-outline-primary rounded" onClick={addOption}>
292
          Añadir opción
294
          Añadir opción
293
        </button>
295
        </button>
294
      )}
296
      )}
-
 
297
      <div className="form-group">
-
 
298
        <label htmlFor="question">Duración</label>
295
      <Datetime
299
        <Datetime
296
        dateFormat="DD/MM/YYYY"
300
          dateFormat="DD/MM/YYYY"
297
        timeFormat="HH:mm"
301
          timeFormat="HH:mm"
298
        value={selectedDate}
302
          value={selectedDate}
299
        onChange={setSelectedDate}
303
          onChange={(e) => setValue('date', e.day)}
300
        isValidDate={(current) =>
304
          isValidDate={(current) =>
301
          current.isBefore(calculateMaxDate()) &&
305
            current.isBefore(calculateMaxDate()) &&
302
          current.isAfter(calculateMinDate())
306
            current.isAfter(calculateMinDate())
303
        } // Se valida que la fecha esté entre la fecha mínima y la fecha máxima
307
          } // Se valida que la fecha esté entre la fecha mínima y la fecha máxima
304
        timeConstraints={{
308
          timeConstraints={{
305
          hours: { max: 23 },
309
            hours: { max: 23 },
306
          minutes: { max: 59 }
310
            minutes: { max: 59 }
307
        }}
311
          }}
308
      />
312
        />
-
 
313
      </div>
309
    </>
314
    </>
310
  )
315
  )
311
}
316
}
Línea 312... Línea 317...
312
 
317