Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3416 Rev 3432
Línea 23... Línea 23...
23
    control,
23
    control,
24
    formState: { isSubmitting },
24
    formState: { isSubmitting },
25
    handleSubmit,
25
    handleSubmit,
26
  } = useForm();
26
  } = useForm();
Línea 27... Línea 27...
27
 
27
 
28
  const onSubmit = handleSubmit(async () => {
28
  const onSubmit = handleSubmit(async ({ cover }) => {
-
 
29
    try {
-
 
30
      const formData = new FormData();
-
 
31
      formData.append("cover", cover);
29
    try {
32
 
-
 
33
      const response = await axios.post(url, formData);
-
 
34
 
-
 
35
      const { data, success } = response.data;
-
 
36
 
-
 
37
      if (!success) throw new Error("Error al actualizar el portada");
30
      const newCover = await axios.post(url, cover);
38
 
31
      onChange(newCover);
39
      onChange(data);
32
      onClose();
40
      onClose();
33
    } catch (error) {
-
 
34
      dispatch(
-
 
35
        addNotification({
41
    } catch (error) {
36
          style: "danger",
42
      console.log(error);
37
          msg: "Error al actualizar el portada",
-
 
38
        })
-
 
39
      );
43
      dispatch(addNotification({ style: "danger", msg: error.message }));
40
    }
44
    }
Línea 41... Línea 45...
41
  });
45
  });
42
 
46