Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 9837 Rev 9838
Línea 39... Línea 39...
39
    }
39
    }
40
  ])
40
  ])
Línea 41... Línea 41...
41
 
41
 
-
 
42
 
-
 
43
  const onSubmit = (data) => {
42
 
44
 
43
  const onSubmit = (data) => {
45
    const formData = new FormData()
44
    const submitData = {
46
    const submitData = {
45
      ...data,
47
      ...data,
46
      ...location,
48
      ...location,
47
      last_date: year,
49
      last_date: year,
Línea 48... Línea 50...
48
      status: isActive ? "a" : "i"
50
      status: isActive ? "a" : "i"
49
    }
51
    }
50
 
52
 
51
    if (!location.formatted_address) {
53
    if (!location.formatted_address) {
52
      return setInputErrors(prev => ({ ...prev, location: "Location empty" }))
54
      return setInputErrors(prev => ({ ...prev, location: "Es requerida una ubicación" }))
53
    }
55
    }
Línea 54... Línea 56...
54
    if (!year) {
56
    if (!year) {
-
 
57
      return setInputErrors(prev => ({ ...prev, year: "Este campo es requerido" }))
55
      return setInputErrors(prev => ({ ...prev, year: "Year empty" }))
58
    }
-
 
59
 
-
 
60
    Object.entries(submitData).forEach((entries) => {
-
 
61
      formData.append(entries[0], entries[1])
-
 
62
    })
-
 
63
 
-
 
64
    axios.post(actionLink, formData)
-
 
65
      .then(({ data }) => {
-
 
66
        if (!data.success) {
-
 
67
          dispatch(addNotification({
-
 
68
            style: "error",
-
 
69
            msg: "Ha ocurrido un error"
-
 
70
          }))
-
 
71
          return
-
 
72
        }
-
 
73
        dispatch(addNotification({
-
 
74
          style: "success",
-
 
75
          msg: `Registro ${action === "edit" ? "actualizado" : "guardado"}`
Línea 56... Línea -...
56
    }
-
 
57
 
-
 
58
    console.log(submitData)
76
        }))
Línea 59... Línea 77...
59
  }
77
        closeModal()
Línea 60... Línea 78...
60
 
78
      })
61
  useEffect(() => {
79
      .catch((err) => setError(err))
Línea 112... Línea 130...
112
                value={locationLabel}
130
                value={locationLabel}
113
                setValue={setLocationLabel}
131
                setValue={setLocationLabel}
114
                googleApiKey={googleApiKey}
132
                googleApiKey={googleApiKey}
115
                updateData={setLocation}
133
                updateData={setLocation}
116
              />
134
              />
-
 
135
              {inputErrors.location && <p>{inputErrors.location}</p>}
117
            </div>
136
            </div>
118
            <div className="form-group">
137
            <div className="form-group">
119
              <label>Industria</label>
138
              <label>Industria</label>
120
              <select name="industry_id" className="form-control" ref={register({ required: true })} onChange={(e) => setIndustry(e.target.value)}>
139
              <select name="industry_id" className="form-control" ref={register({ required: true })} onChange={(e) => setIndustry(e.target.value)}>
121
                {
140
                {
Línea 134... Línea 153...
134
                  setYear(new Intl.DateTimeFormat({ year: 'numeric', month: 'numeric', day: 'numeric' }).format(e.toDate()))
153
                  setYear(new Intl.DateTimeFormat({ year: 'numeric', month: 'numeric', day: 'numeric' }).format(e.toDate()))
135
                }
154
                }
136
                inputProps={{ className: 'form-control' }}
155
                inputProps={{ className: 'form-control' }}
137
                closeOnSelect
156
                closeOnSelect
138
              />
157
              />
139
 
-
 
-
 
158
              {inputErrors.year && <p>{inputErrors.year}</p>}
140
            </div>
159
            </div>
141
            <div className="form-group">
160
            <div className="form-group">
142
              <label>Descripción</label>
161
              <label>Descripción</label>
143
              <DescriptionInput
162
              <DescriptionInput
144
                setValue={setValue}
163
                setValue={setValue}