Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 9682 Rev 9685
Línea 2... Línea 2...
2
import { useForm } from 'react-hook-form'
2
import { useForm } from 'react-hook-form'
3
import axios from 'axios'
3
import axios from 'axios'
Línea 4... Línea 4...
4
 
4
 
Línea 5... Línea 5...
5
const FormView = ({ actionLink }) => {
5
const FormView = ({ actionLink }) => {
6
 
-
 
7
  const { handleSubmit, register } = useForm()
-
 
8
 
-
 
9
  const onSubmit = (data) => {
-
 
10
    axios.post(actionLink, data)
-
 
11
      .then(({ data }) => {
-
 
12
        if (!data.success) {
-
 
13
          console.log("Ocurrio un error")
-
 
14
        }
-
 
15
 
-
 
16
        console.log(data.data)
-
 
17
      })
-
 
Línea 18... Línea 6...
18
      .catch(err => console.log(err))
6
 
19
  }
7
  const { handleSubmit } = useForm()
20
 
8
 
21
  return (
9
  return (
22
    <section className="content">
10
    <section className="content">
23
      <div className="row" >
11
      <div className="row" >
24
        <div className="col-xs-12 col-md-12">
12
        <div className="col-xs-12 col-md-12">
25
          <form onSubmit={handleSubmit(onSubmit)}>
13
          <form onSubmit={handleSubmit}>
26
            <div className="form-group">
14
            <div className="form-group">
Línea 27... Línea 15...
27
              <label>Nombre</label>
15
              <label>Nombre</label>
28
              <input type="text" name="name" className="form-control" ref={register} />
16
              <input type="text" name="name" className="form-control" />
29
            </div>
17
            </div>